提交 b949cc23 编写于 作者: A Alexander Kuzmenkov

Mark lookupResultGetKey/Mapped functions ALWAYS_INLINE.

They only do pointer arithmetics, so it makes sense to always inline
them.
上级 f3bde19b
......@@ -15,10 +15,10 @@ struct ClearableHashMapCell : public ClearableHashTableCell<Key, HashMapCell<Key
};
template<typename Key, typename Mapped, typename Hash>
auto lookupResultGetKey(ClearableHashMapCell<Key, Mapped, Hash> * cell) { return &cell->getFirst(); }
ALWAYS_INLINE inline auto lookupResultGetKey(ClearableHashMapCell<Key, Mapped, Hash> * cell) { return &cell->getFirst(); }
template<typename Key, typename Mapped, typename Hash>
auto lookupResultGetMapped(ClearableHashMapCell<Key, Mapped, Hash> * cell) { return &cell->getSecond(); }
ALWAYS_INLINE inline auto lookupResultGetMapped(ClearableHashMapCell<Key, Mapped, Hash> * cell) { return &cell->getSecond(); }
template
<
......
......@@ -49,10 +49,10 @@ struct ClearableHashTableCell : public BaseCell
};
template<typename Key, typename BaseCell>
auto lookupResultGetKey(ClearableHashTableCell<Key, BaseCell> * cell) { return &cell->key; }
ALWAYS_INLINE inline auto lookupResultGetKey(ClearableHashTableCell<Key, BaseCell> * cell) { return &cell->key; }
template<typename Key, typename BaseCell>
void * lookupResultGetMapped(ClearableHashTableCell<Key, BaseCell> *) { return nullptr; }
ALWAYS_INLINE inline void * lookupResultGetMapped(ClearableHashTableCell<Key, BaseCell> *) { return nullptr; }
template
<
......
......@@ -48,10 +48,12 @@ struct FixedHashMapCell
};
template<typename Key, typename Mapped, typename State>
void * lookupResultGetKey(FixedHashMapCell<Key, Mapped, State> *) { return nullptr; }
ALWAYS_INLINE inline void * lookupResultGetKey(FixedHashMapCell<Key, Mapped, State> *)
{ return nullptr; }
template<typename Key, typename Mapped, typename State>
auto lookupResultGetMapped(FixedHashMapCell<Key, Mapped, State> * cell) { return &cell->getSecond(); }
ALWAYS_INLINE inline auto lookupResultGetMapped(FixedHashMapCell<Key, Mapped, State> * cell)
{ return &cell->getSecond(); }
template <typename Key, typename Mapped, typename Allocator = HashTableAllocator>
class FixedHashMap : public FixedHashTable<Key, FixedHashMapCell<Key, Mapped>, Allocator>
......
......@@ -111,10 +111,12 @@ struct HashMapCell
};
template<typename Key, typename Mapped, typename Hash, typename State>
auto lookupResultGetKey(HashMapCell<Key, Mapped, Hash, State> * cell) { return &cell->getFirst(); }
ALWAYS_INLINE inline auto lookupResultGetKey(HashMapCell<Key, Mapped, Hash, State> * cell)
{ return &cell->getFirst(); }
template<typename Key, typename Mapped, typename Hash, typename State>
auto lookupResultGetMapped(HashMapCell<Key, Mapped, Hash, State> * cell) { return &cell->getSecond(); }
ALWAYS_INLINE inline auto lookupResultGetMapped(HashMapCell<Key, Mapped, Hash, State> * cell)
{ return &cell->getSecond(); }
template <typename Key, typename TMapped, typename Hash, typename TState = HashTableNoState>
......@@ -135,10 +137,12 @@ struct HashMapCellWithSavedHash : public HashMapCell<Key, TMapped, Hash, TState>
};
template<typename Key, typename Mapped, typename Hash, typename State>
auto lookupResultGetKey(HashMapCellWithSavedHash<Key, Mapped, Hash, State> * cell) { return &cell->getFirst(); }
ALWAYS_INLINE inline auto lookupResultGetKey(HashMapCellWithSavedHash<Key, Mapped, Hash, State> * cell)
{ return &cell->getFirst(); }
template<typename Key, typename Mapped, typename Hash, typename State>
auto lookupResultGetMapped(HashMapCellWithSavedHash<Key, Mapped, Hash, State> * cell) { return &cell->getSecond(); }
ALWAYS_INLINE inline auto lookupResultGetMapped(HashMapCellWithSavedHash<Key, Mapped, Hash, State> * cell)
{ return &cell->getSecond(); }
template <
......
......@@ -85,10 +85,12 @@ struct HashSetCellWithSavedHash : public HashTableCell<Key, Hash, TState>
};
template<typename Key, typename Hash, typename State>
auto lookupResultGetKey(HashSetCellWithSavedHash<Key, Hash, State> * cell) { return &cell->key; }
ALWAYS_INLINE inline auto lookupResultGetKey(HashSetCellWithSavedHash<Key, Hash, State> * cell)
{ return &cell->key; }
template<typename Key, typename Hash, typename State>
void * lookupResultGetMapped(HashSetCellWithSavedHash<Key, Hash, State> *) { return nullptr; }
ALWAYS_INLINE inline void * lookupResultGetMapped(HashSetCellWithSavedHash<Key, Hash, State> *)
{ return nullptr; }
template
<
......
......@@ -124,7 +124,7 @@ void set(T & x) { x = 0; }
* The default implementation of GetMapped that is used for the above case (2).
*/
template<typename PointerLike>
inline auto lookupResultGetMapped(PointerLike && ptr) { return &*ptr; }
ALWAYS_INLINE inline auto lookupResultGetMapped(PointerLike && ptr) { return &*ptr; }
/**
* Generic const wrapper for lookupResultGetMapped, that calls a non-const
......@@ -132,7 +132,7 @@ inline auto lookupResultGetMapped(PointerLike && ptr) { return &*ptr; }
* arithmetics.
*/
template<typename T>
auto lookupResultGetMapped(const T * obj)
ALWAYS_INLINE inline auto lookupResultGetMapped(const T * obj)
{
auto mapped_ptr = lookupResultGetMapped(const_cast<T *>(obj));
const auto const_mapped_ptr = mapped_ptr;
......@@ -208,10 +208,12 @@ struct HashTableCell
};
template<typename Key, typename Hash, typename State>
auto lookupResultGetKey(HashTableCell<Key, Hash, State> * cell) { return &cell->key; }
ALWAYS_INLINE inline auto lookupResultGetKey(HashTableCell<Key, Hash, State> * cell)
{ return &cell->key; }
template<typename Key, typename Hash, typename State>
void * lookupResultGetMapped(HashTableCell<Key, Hash, State> *) { return nullptr; }
ALWAYS_INLINE inline void * lookupResultGetMapped(HashTableCell<Key, Hash, State> *)
{ return nullptr; }
/**
* A helper function for HashTable::insert() to set the "mapped" value.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册