From b949cc232b1d70fe0a47bc36a1f807deeee70cdb Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov Date: Tue, 24 Sep 2019 22:03:10 +0300 Subject: [PATCH] Mark lookupResultGetKey/Mapped functions ALWAYS_INLINE. They only do pointer arithmetics, so it makes sense to always inline them. --- dbms/src/Common/HashTable/ClearableHashMap.h | 4 ++-- dbms/src/Common/HashTable/ClearableHashSet.h | 4 ++-- dbms/src/Common/HashTable/FixedHashMap.h | 6 ++++-- dbms/src/Common/HashTable/HashMap.h | 12 ++++++++---- dbms/src/Common/HashTable/HashSet.h | 6 ++++-- dbms/src/Common/HashTable/HashTable.h | 10 ++++++---- 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/dbms/src/Common/HashTable/ClearableHashMap.h b/dbms/src/Common/HashTable/ClearableHashMap.h index d1703394e14..e9f010cffe5 100644 --- a/dbms/src/Common/HashTable/ClearableHashMap.h +++ b/dbms/src/Common/HashTable/ClearableHashMap.h @@ -15,10 +15,10 @@ struct ClearableHashMapCell : public ClearableHashTableCell -auto lookupResultGetKey(ClearableHashMapCell * cell) { return &cell->getFirst(); } +ALWAYS_INLINE inline auto lookupResultGetKey(ClearableHashMapCell * cell) { return &cell->getFirst(); } template -auto lookupResultGetMapped(ClearableHashMapCell * cell) { return &cell->getSecond(); } +ALWAYS_INLINE inline auto lookupResultGetMapped(ClearableHashMapCell * cell) { return &cell->getSecond(); } template < diff --git a/dbms/src/Common/HashTable/ClearableHashSet.h b/dbms/src/Common/HashTable/ClearableHashSet.h index 4f079eddc78..240c32632a9 100644 --- a/dbms/src/Common/HashTable/ClearableHashSet.h +++ b/dbms/src/Common/HashTable/ClearableHashSet.h @@ -49,10 +49,10 @@ struct ClearableHashTableCell : public BaseCell }; template -auto lookupResultGetKey(ClearableHashTableCell * cell) { return &cell->key; } +ALWAYS_INLINE inline auto lookupResultGetKey(ClearableHashTableCell * cell) { return &cell->key; } template -void * lookupResultGetMapped(ClearableHashTableCell *) { return nullptr; } +ALWAYS_INLINE inline void * lookupResultGetMapped(ClearableHashTableCell *) { return nullptr; } template < diff --git a/dbms/src/Common/HashTable/FixedHashMap.h b/dbms/src/Common/HashTable/FixedHashMap.h index e0f1a2494e0..986b4af67c0 100644 --- a/dbms/src/Common/HashTable/FixedHashMap.h +++ b/dbms/src/Common/HashTable/FixedHashMap.h @@ -48,10 +48,12 @@ struct FixedHashMapCell }; template -void * lookupResultGetKey(FixedHashMapCell *) { return nullptr; } +ALWAYS_INLINE inline void * lookupResultGetKey(FixedHashMapCell *) +{ return nullptr; } template -auto lookupResultGetMapped(FixedHashMapCell * cell) { return &cell->getSecond(); } +ALWAYS_INLINE inline auto lookupResultGetMapped(FixedHashMapCell * cell) +{ return &cell->getSecond(); } template class FixedHashMap : public FixedHashTable, Allocator> diff --git a/dbms/src/Common/HashTable/HashMap.h b/dbms/src/Common/HashTable/HashMap.h index 1d9ca29b77a..f273d5bcdc7 100644 --- a/dbms/src/Common/HashTable/HashMap.h +++ b/dbms/src/Common/HashTable/HashMap.h @@ -111,10 +111,12 @@ struct HashMapCell }; template -auto lookupResultGetKey(HashMapCell * cell) { return &cell->getFirst(); } +ALWAYS_INLINE inline auto lookupResultGetKey(HashMapCell * cell) +{ return &cell->getFirst(); } template -auto lookupResultGetMapped(HashMapCell * cell) { return &cell->getSecond(); } +ALWAYS_INLINE inline auto lookupResultGetMapped(HashMapCell * cell) +{ return &cell->getSecond(); } template @@ -135,10 +137,12 @@ struct HashMapCellWithSavedHash : public HashMapCell }; template -auto lookupResultGetKey(HashMapCellWithSavedHash * cell) { return &cell->getFirst(); } +ALWAYS_INLINE inline auto lookupResultGetKey(HashMapCellWithSavedHash * cell) +{ return &cell->getFirst(); } template -auto lookupResultGetMapped(HashMapCellWithSavedHash * cell) { return &cell->getSecond(); } +ALWAYS_INLINE inline auto lookupResultGetMapped(HashMapCellWithSavedHash * cell) +{ return &cell->getSecond(); } template < diff --git a/dbms/src/Common/HashTable/HashSet.h b/dbms/src/Common/HashTable/HashSet.h index 9c25f7f906b..4b3aa5204ea 100644 --- a/dbms/src/Common/HashTable/HashSet.h +++ b/dbms/src/Common/HashTable/HashSet.h @@ -85,10 +85,12 @@ struct HashSetCellWithSavedHash : public HashTableCell }; template -auto lookupResultGetKey(HashSetCellWithSavedHash * cell) { return &cell->key; } +ALWAYS_INLINE inline auto lookupResultGetKey(HashSetCellWithSavedHash * cell) +{ return &cell->key; } template -void * lookupResultGetMapped(HashSetCellWithSavedHash *) { return nullptr; } +ALWAYS_INLINE inline void * lookupResultGetMapped(HashSetCellWithSavedHash *) +{ return nullptr; } template < diff --git a/dbms/src/Common/HashTable/HashTable.h b/dbms/src/Common/HashTable/HashTable.h index 03822996361..f13d6f6e3dd 100644 --- a/dbms/src/Common/HashTable/HashTable.h +++ b/dbms/src/Common/HashTable/HashTable.h @@ -124,7 +124,7 @@ void set(T & x) { x = 0; } * The default implementation of GetMapped that is used for the above case (2). */ template -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 -auto lookupResultGetMapped(const T * obj) +ALWAYS_INLINE inline auto lookupResultGetMapped(const T * obj) { auto mapped_ptr = lookupResultGetMapped(const_cast(obj)); const auto const_mapped_ptr = mapped_ptr; @@ -208,10 +208,12 @@ struct HashTableCell }; template -auto lookupResultGetKey(HashTableCell * cell) { return &cell->key; } +ALWAYS_INLINE inline auto lookupResultGetKey(HashTableCell * cell) +{ return &cell->key; } template -void * lookupResultGetMapped(HashTableCell *) { return nullptr; } +ALWAYS_INLINE inline void * lookupResultGetMapped(HashTableCell *) +{ return nullptr; } /** * A helper function for HashTable::insert() to set the "mapped" value.