Skip to content

Commit

Permalink
Various formatting fixes and small cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
joto committed Dec 3, 2018
1 parent dc5d08d commit 6e4fc2e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions include/osmium/memory/collection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace osmium {
}

CollectionIterator<TMember> operator++(int) {
CollectionIterator<TMember> tmp(*this);
CollectionIterator<TMember> tmp{*this};
operator++();
return tmp;
}
Expand All @@ -85,7 +85,7 @@ namespace osmium {
}

bool operator!=(const CollectionIterator<TMember>& rhs) const noexcept {
return m_data != rhs.m_data;
return !(*this == rhs);
}

unsigned char* data() const noexcept {
Expand Down Expand Up @@ -123,11 +123,11 @@ namespace osmium {
using const_reference = const TMember&;
using iterator = CollectionIterator<TMember>;
using const_iterator = CollectionIterator<const TMember>;
using size_type = size_t;
using size_type = std::size_t;

static constexpr osmium::item_type itemtype = TCollectionItemType;

constexpr static bool is_compatible_to(osmium::item_type t) noexcept {
constexpr static bool is_compatible_to(const osmium::item_type t) noexcept {
return t == itemtype;
}

Expand All @@ -154,19 +154,19 @@ namespace osmium {
}

iterator begin() noexcept {
return iterator(data() + sizeof(Collection<TMember, TCollectionItemType>));
return iterator{data() + sizeof(Collection<TMember, TCollectionItemType>)};
}

iterator end() noexcept {
return iterator(data() + byte_size());
return iterator{data() + byte_size()};
}

const_iterator cbegin() const noexcept {
return const_iterator(data() + sizeof(Collection<TMember, TCollectionItemType>));
return const_iterator{data() + sizeof(Collection<TMember, TCollectionItemType>)};
}

const_iterator cend() const noexcept {
return const_iterator(data() + byte_size());
return const_iterator{data() + byte_size()};
}

const_iterator begin() const noexcept {
Expand Down
6 changes: 3 additions & 3 deletions include/osmium/memory/item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace osmium {

protected:

explicit Item(item_size_type size = 0, item_type type = item_type()) noexcept :
explicit Item(item_size_type size = 0, item_type type = item_type{}) noexcept :
m_size(size),
m_type(type),
m_removed(false),
Expand Down Expand Up @@ -176,7 +176,7 @@ namespace osmium {
return m_removed;
}

void set_removed(bool removed) noexcept {
void set_removed(const bool removed) noexcept {
m_removed = removed;
}

Expand All @@ -189,7 +189,7 @@ namespace osmium {
return diff_chars[m_diff];
}

void set_diff(diff_indicator_type diff) noexcept {
void set_diff(const diff_indicator_type diff) noexcept {
m_diff = uint16_t(diff);
}

Expand Down
6 changes: 3 additions & 3 deletions include/osmium/memory/item_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace osmium {
namespace detail {

template <typename T>
constexpr inline bool type_is_compatible(osmium::item_type t) noexcept {
constexpr inline bool type_is_compatible(const osmium::item_type t) noexcept {
return T::is_compatible_to(t);
}

Expand Down Expand Up @@ -120,7 +120,7 @@ namespace osmium {
}

ItemIterator<TMember> operator++(int) noexcept {
ItemIterator<TMember> tmp(*this);
ItemIterator<TMember> tmp{*this};
operator++();
return tmp;
}
Expand Down Expand Up @@ -223,7 +223,7 @@ namespace osmium {
*
* Complexity: Linear in the number of items.
*/
size_t size() const noexcept {
std::size_t size() const noexcept {
if (m_begin == m_end) {
return 0;
}
Expand Down
14 changes: 7 additions & 7 deletions include/osmium/osm/tag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ namespace osmium {
template <typename TMember>
friend class osmium::memory::CollectionIterator;

static unsigned char* after_null(unsigned char* ptr) {
static unsigned char* after_null(unsigned char* ptr) noexcept {
return reinterpret_cast<unsigned char*>(std::strchr(reinterpret_cast<char*>(ptr), 0) + 1);
}

static const unsigned char* after_null(const unsigned char* ptr) {
static const unsigned char* after_null(const unsigned char* ptr) noexcept {
return reinterpret_cast<const unsigned char*>(std::strchr(reinterpret_cast<const char*>(ptr), 0) + 1);
}

unsigned char* next() {
unsigned char* next() noexcept {
return after_null(after_null(data()));
}

const unsigned char* next() const {
const unsigned char* next() const noexcept {
return after_null(after_null(data()));
}

Expand All @@ -82,18 +82,18 @@ namespace osmium {
return reinterpret_cast<const char*>(data());
}

const char* value() const {
const char* value() const noexcept {
return reinterpret_cast<const char*>(after_null(data()));
}

}; // class Tag

inline bool operator==(const Tag& lhs, const Tag& rhs) {
inline bool operator==(const Tag& lhs, const Tag& rhs) noexcept {
return !std::strcmp(lhs.key(), rhs.key()) &&
!std::strcmp(lhs.value(), rhs.value());
}

inline bool operator<(const Tag& lhs, const Tag& rhs) {
inline bool operator<(const Tag& lhs, const Tag& rhs) noexcept {
const auto c = std::strcmp(lhs.key(), rhs.key());
return (c == 0 ? std::strcmp(lhs.value(), rhs.value()) : c) < 0;
}
Expand Down

0 comments on commit 6e4fc2e

Please sign in to comment.