diff --git a/indra/CMakeLists.txt b/indra/CMakeLists.txt index 64b54baa30b393c2b877737c73adb8ea53384bdb..301ff27e050ebbe70b7b4708524e2f4a7b5c809d 100644 --- a/indra/CMakeLists.txt +++ b/indra/CMakeLists.txt @@ -11,6 +11,12 @@ project(${ROOT_PROJECT_NAME}) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) + +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + include(Variables) include(BuildVersion) diff --git a/indra/deps/CMakeLists.txt b/indra/deps/CMakeLists.txt index 023579a5c4a098dbce16b3a64b81c9313fd05e78..8441942167c299685f0ba904031969678879a51a 100644 --- a/indra/deps/CMakeLists.txt +++ b/indra/deps/CMakeLists.txt @@ -6,18 +6,16 @@ include(FetchContent) set(CMAKE_FOLDER "Third Party") set(CMAKE_POSITION_INDEPENDENT_CODE ON) - FetchContent_Declare( - meshoptimizer - GIT_REPOSITORY https://github.com/zeux/meshoptimizer.git - GIT_TAG v0.14 - ) - +FetchContent_Declare( + meshoptimizer + GIT_REPOSITORY https://github.com/zeux/meshoptimizer.git + GIT_TAG v0.14 + ) FetchContent_Declare( robin-hood-hashing GIT_REPOSITORY https://git.alchemyviewer.org/alchemy/thirdparty/robin-hood-hashing.git GIT_TAG alchemy ) - # FetchContent_Declare( # Catch2 # GIT_REPOSITORY https://github.com/catchorg/Catch2.git @@ -33,25 +31,25 @@ FetchContent_Declare( # GIT_REPOSITORY https://github.com/nlohmann/json.git # GIT_TAG v3.7.3 # ) -# FetchContent_Declare( -# absl -# GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git -# GIT_TAG cde2e2410e58c884b3bf5f67c6511e6266036249 -# ) - -# # This is a hack because absl has dumb cmake -# set(OLD_BUILD_TEST ${BUILD_TESTING}) -# set(BUILD_TESTING OFF) -# FetchContent_MakeAvailable(absl) -# set(BUILD_TESTING ${OLD_BUILD_TEST}) +FetchContent_Declare( + absl + GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git + GIT_TAG 3c2bed2e77a8b77ce3092e3f75140dd21879bdba + ) -# # Supress warnings inside abseil under MSVC -# if(WINDOWS) -# target_compile_options(absl_strings PRIVATE /wd4018) -# target_compile_options(absl_str_format_internal PRIVATE /wd4018) -# target_compile_options(absl_flags_usage_internal PRIVATE /wd4018) -# endif() +# This is a hack because absl has dumb cmake +set(OLD_BUILD_TEST ${BUILD_TESTING}) +set(BUILD_TESTING OFF) +FetchContent_MakeAvailable(absl) +set(BUILD_TESTING ${OLD_BUILD_TEST}) +# Supress warnings inside abseil under MSVC +if(WINDOWS) + target_compile_options(absl_strings PRIVATE /wd4018) + target_compile_options(absl_str_format_internal PRIVATE /wd4018) + target_compile_options(absl_flags_usage_internal PRIVATE /wd4018) + target_compile_options(absl_random_internal_distribution_test_util PRIVATE /wd4723) +endif() # if (BUILD_TESTING) # FetchContent_MakeAvailable(Catch2) @@ -60,7 +58,6 @@ FetchContent_Declare( # #Download the rest of the libraries # FetchContent_MakeAvailable(fmt) FetchContent_MakeAvailable(meshoptimizer) -FetchContent_MakeAvailable(robin-hood-hashing) # # Typically you don't care so much for a third party library's tests to be # # run from your own project's code. diff --git a/indra/llappearance/llavatarappearance.h b/indra/llappearance/llavatarappearance.h index 47098bee21f01dc36adb1dfab9f93ea2b93433da..e1777c33a538eda80984ecaa74d54f90bfe08fa0 100644 --- a/indra/llappearance/llavatarappearance.h +++ b/indra/llappearance/llavatarappearance.h @@ -35,7 +35,7 @@ #include "llviewervisualparam.h" #include "llxmltree.h" -#include <robin_hood.h> +#include <absl/container/flat_hash_map.h> class LLTexLayerSet; class LLTexGlobalColor; @@ -140,7 +140,7 @@ class LLAvatarAppearance : public LLCharacter LLVector3 mHeadOffset; // current head position LLAvatarJoint *mRoot; - typedef robin_hood::unordered_map<std::string, LLJoint*> joint_map_t; + typedef absl::flat_hash_map<std::string, LLJoint*> joint_map_t; joint_map_t mJointMap; typedef std::map<std::string, LLVector3> joint_state_map_t; diff --git a/indra/llcharacter/llanimationstates.h b/indra/llcharacter/llanimationstates.h index 32693d66e1f1f337ac92d75ce6e7bbc9bad50675..7a999e86ade09639bea386c81d75b91e3d55b2f1 100644 --- a/indra/llcharacter/llanimationstates.h +++ b/indra/llcharacter/llanimationstates.h @@ -28,7 +28,7 @@ #define LL_LLANIMATIONSTATES_H #include <map> -#include <robin_hood.h> +#include <absl/container/flat_hash_map.h> #include "llstringtable.h" #include "lluuid.h" @@ -204,7 +204,7 @@ class LLAnimationLibrary private: LLStringTable mAnimStringTable; - typedef robin_hood::unordered_map<LLUUID, char *> anim_map_t; + typedef absl::flat_hash_map<LLUUID, char *> anim_map_t; anim_map_t mAnimMap; public: diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h index 04a76e725c406891e77b3e876f37c3b46f9b660c..4f13debe9835b05d59e5855c1c031277684b9be7 100644 --- a/indra/llcharacter/llcharacter.h +++ b/indra/llcharacter/llcharacter.h @@ -39,7 +39,7 @@ #include "llpointer.h" #include "llrefcount.h" -#include <robin_hood.h> +#include <absl/container/flat_hash_map.h> class LLPolyMesh; @@ -268,7 +268,7 @@ class LLCharacter protected: LLMotionController mMotionController; - typedef robin_hood::unordered_map<std::string, void *> animation_data_map_t; + typedef absl::flat_hash_map<std::string, void *> animation_data_map_t; animation_data_map_t mAnimationData; F32 mPreferredPelvisHeight; diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h index 675d0c4408954da8453f53e9bf0d697caac6f577..7cc7537a19063fcbb98059c1f0258b67702e1cce 100644 --- a/indra/llcharacter/llkeyframemotion.h +++ b/indra/llcharacter/llkeyframemotion.h @@ -43,7 +43,7 @@ #include "v3math.h" #include "llbvhconsts.h" -#include <robin_hood.h> +#include <absl/container/flat_hash_map.h> class LLKeyframeDataCache; class LLVFS; @@ -444,7 +444,7 @@ class LLKeyframeDataCache LLKeyframeDataCache(){}; ~LLKeyframeDataCache(); - typedef robin_hood::unordered_map<LLUUID, class LLKeyframeMotion::JointMotionList*> keyframe_data_map_t; + typedef absl::flat_hash_map<LLUUID, class LLKeyframeMotion::JointMotionList*> keyframe_data_map_t; static keyframe_data_map_t sKeyframeDataMap; static void addKeyframeData(const LLUUID& id, LLKeyframeMotion::JointMotionList*); diff --git a/indra/llcharacter/llmotioncontroller.h b/indra/llcharacter/llmotioncontroller.h index 51db86f73ffc49ecaa03734a41f2ad4a1004b4cc..3052f6395e6f9284dc7ec141f86f07e8899b1091 100644 --- a/indra/llcharacter/llmotioncontroller.h +++ b/indra/llcharacter/llmotioncontroller.h @@ -40,7 +40,9 @@ #include "llstatemachine.h" #include "llstring.h" -#include <robin_hood.h> +#include "absl/container/node_hash_map.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" //----------------------------------------------------------------------------- // Class predeclaration @@ -75,7 +77,7 @@ class LLMotionRegistry protected: - typedef robin_hood::unordered_map<LLUUID, LLMotionConstructor> motion_map_t; + typedef absl::node_hash_map<LLUUID, LLMotionConstructor> motion_map_t; motion_map_t mMotionTable; }; @@ -210,7 +212,7 @@ class LLMotionController // Once an animations is loaded, it will be initialized and put on the mLoadedMotions list. // Any animation that is currently playing also sits in the mActiveMotions list. - typedef robin_hood::unordered_map<LLUUID, LLMotion*> motion_map_t; + typedef absl::flat_hash_map<LLUUID, LLMotion*> motion_map_t; motion_map_t mAllMotions; motion_set_t mLoadingMotions; diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index a937c5c9608a1ce8829229fe5ca0f150e9646a76..4190d17e1f0b9d77e16f45059668add52ca7a3de 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -300,7 +300,8 @@ target_link_libraries( ${BOOST_SYSTEM_LIBRARY} ${GOOGLE_PERFTOOLS_LIBRARIES} ${URIPARSER_LIBRARIES} - robin_hood + absl::flat_hash_map + absl::node_hash_map ) if (DARWIN) diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 9a6124b504adb0e93f94fb782903fb8ff5c75602..51abb6dc009ec4af13a1fac55013a42ea6fecd6b 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -44,8 +44,8 @@ # include <io.h> #endif // !LL_WINDOWS #include <vector> -#include <robin_hood.h> #include "string.h" +#include <absl/container/flat_hash_map.h> #include "llapp.h" #include "llapr.h" @@ -498,7 +498,7 @@ namespace LLError LevelMap mClassLevelMap; LevelMap mFileLevelMap; LevelMap mTagLevelMap; - robin_hood::unordered_map<std::string, unsigned int> mUniqueLogMessages; + absl::flat_hash_map<std::string, unsigned int> mUniqueLogMessages; LLError::FatalFunction mCrashFunction; LLError::TimeFunction mTimeFunction; diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index 9610562a210f6e53baeab606c5041ffc41fc6ec0..004005265fb6c2b4429073ce6d6f8a1c00d2eb97 100644 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -34,7 +34,7 @@ #include <boost/shared_ptr.hpp> #include <boost/type_traits/is_convertible.hpp> #include <boost/type_traits/is_enum.hpp> -#include <robin_hood.h> +#include <absl/container/node_hash_map.h> #include "llerror.h" #include "llstl.h" @@ -649,7 +649,7 @@ namespace LLInitParam void aggregateBlockData(BlockDescriptor& src_block_data); void addParam(ParamDescriptorPtr param, const char* name); - typedef robin_hood::unordered_node_map<std::string, ParamDescriptorPtr> param_map_t; + typedef absl::node_hash_map<std::string, ParamDescriptorPtr> param_map_t; typedef std::vector<ParamDescriptorPtr> param_list_t; typedef std::list<ParamDescriptorPtr> all_params_list_t; typedef std::vector<std::pair<param_handle_t, ParamDescriptor::validation_func_t> > param_validation_list_t; diff --git a/indra/llcommon/llpounceable.h b/indra/llcommon/llpounceable.h index 4d5f841f523596261e02939eec746759e1b38cf4..37ee88e0edcf30dc399f526c6b97e6354cf0229b 100644 --- a/indra/llcommon/llpounceable.h +++ b/indra/llcommon/llpounceable.h @@ -41,7 +41,7 @@ #include <boost/type_traits/remove_pointer.hpp> #include <boost/utility/value_init.hpp> #include <boost/signals2/signal.hpp> -#include <robin_hood.h> +#include <absl/container/node_hash_map.h> // Forward declare the user template, since we want to be able to point to it // in some of its implementation classes. @@ -86,7 +86,7 @@ class LLPounceableQueueSingleton: // instance will call on the SAME LLPounceableQueueSingleton instance -- // given how class statics work. We must keep a separate queue for each // LLPounceable instance. Use a hash map for that. - typedef robin_hood::unordered_node_map<owner_ptr, signal_t> map_t; + typedef absl::node_hash_map<owner_ptr, signal_t> map_t; public: // Disambiguate queues belonging to different LLPounceables. diff --git a/indra/llcommon/llstaticstringtable.h b/indra/llcommon/llstaticstringtable.h index 0cc77824d1c17bbeae5d6f810a129745a19e0683..7053ae3f17002393882a4338e054db238dd44724 100644 --- a/indra/llcommon/llstaticstringtable.h +++ b/indra/llcommon/llstaticstringtable.h @@ -29,7 +29,8 @@ #define LL_STATIC_STRING_TABLE_H #include "lldefs.h" -#include <robin_hood.h> +#include "absl/hash/hash.h" +#include "absl/container/flat_hash_map.h" #include "llstl.h" class LLStaticHashedString @@ -51,7 +52,7 @@ class LLStaticHashedString size_t makehash(const std::string& s) { - return robin_hood::hash<std::string>{}(s); + return absl::Hash<std::string>{}(s); } std::string string; @@ -65,10 +66,7 @@ struct LLStaticStringHasher }; template< typename MappedObject > -class LL_COMMON_API LLStaticStringTable - : public robin_hood::unordered_map< LLStaticHashedString, MappedObject, LLStaticStringHasher > -{ -}; +using LLStaticStringTable = absl::flat_hash_map<LLStaticHashedString, MappedObject, LLStaticStringHasher>; #endif diff --git a/indra/llcommon/lluuid.h b/indra/llcommon/lluuid.h index 8acfca950467cd28cf8fb04869eabb7547d3e57b..916d53274be0284d795036d11305ec8e6ea2bb7c 100644 --- a/indra/llcommon/lluuid.h +++ b/indra/llcommon/lluuid.h @@ -35,7 +35,7 @@ #include "llpreprocessor.h" #include <immintrin.h> -#include <robin_hood.h> +#include "absl/hash/hash.h" class LLMutex; @@ -179,9 +179,14 @@ class LL_COMMON_API LLUUID inline size_t hash() const { - return robin_hood::hash_bytes(mData, UUID_BYTES); + return absl::Hash<LLUUID>{}(*this); } // END BOOST + + template <typename H> + friend H AbslHashValue(H h, const LLUUID& id) { + return H::combine_contiguous(std::move(h), id.mData, UUID_BYTES); + } // xor functions. Useful since any two random uuids xored together // will yield a determinate third random unique id that can be @@ -265,16 +270,6 @@ namespace boost { }; } -namespace robin_hood { - template<> struct hash<LLUUID> - { - size_t operator()(const LLUUID& id) const - { - return id.hash(); - } - }; -} - /* * Sub-classes for keeping transaction IDs and asset IDs * straight. diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index ecbb5820aa61d3ffe7e884432e9b710d1094da59..3c12d66ff619059d9ea6d1691deadbbc344e4520 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -32,7 +32,9 @@ #include "llavatarname.h" // for convenience #include "llsingleton.h" #include <boost/signals2.hpp> -#include <robin_hood.h> +#include <absl/container/flat_hash_map.h> +#include <absl/container/node_hash_map.h> + #include <set> class LLSD; @@ -174,18 +176,18 @@ class LLAvatarNameCache : public LLSingleton<LLAvatarNameCache> // Agent IDs that have been requested, but with no reply. // Maps agent ID to frame time request was made. - typedef robin_hood::unordered_map<LLUUID, F64> pending_queue_t; + typedef absl::flat_hash_map<LLUUID, F64> pending_queue_t; pending_queue_t mPendingQueue; // Callbacks to fire when we received a name. // May have multiple callbacks for a single ID, which are // represented as multiple slots bound to the signal. // Avoid copying signals via pointers. - typedef robin_hood::unordered_map<LLUUID, callback_signal_t*> signal_map_t; + typedef absl::flat_hash_map<LLUUID, callback_signal_t* > signal_map_t; signal_map_t mSignalMap; // The cache at last, i.e. avatar names we know about. - typedef robin_hood::unordered_node_map<LLUUID, LLAvatarName> cache_t; + typedef absl::node_hash_map<LLUUID, LLAvatarName> cache_t; cache_t mCache; // Time when unrefreshed cached names were checked last. diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index 2b3640e79ada9fc606b189e222e6b7447c70d173..5a27eeb89b7ed812a07bad1aedf8085ccb18017b 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -33,7 +33,7 @@ #include <immintrin.h> #include "llsd.h" -#include <robin_hood.h> +#include "absl/hash/hash.h" class LLMaterialID { @@ -141,18 +141,15 @@ class LLMaterialID inline size_t hash() const { - size_t seed = 0; - for (U8 i = 0; i < 4; ++i) - { - seed ^= static_cast<size_t>(mID[i * 4]) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast<size_t>(mID[i * 4 + 1]) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast<size_t>(mID[i * 4 + 2]) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast<size_t>(mID[i * 4 + 3]) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - return robin_hood::hash_bytes(mID, MATERIAL_ID_SIZE); + return absl::Hash<LLMaterialID>{}(*this); } // END BOOST + template <typename H> + friend H AbslHashValue(H h, const LLMaterialID& id) { + return H::combine_contiguous(std::move(h), id.mID, MATERIAL_ID_SIZE); + } + const U8* get() const; void set(const void* pMemory); void clear(); @@ -190,15 +187,5 @@ namespace boost { }; } -namespace robin_hood { - template<> struct hash<LLMaterialID> - { - size_t operator()(const LLMaterialID& id) const - { - return id.hash(); - } - }; -} - #endif // LL_LLMATERIALID_H diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h index b692238c5e924cc4f52f3829fae8924144a804ee..9d03a82ff45e5921a41e610f7fa75309b02f4ca9 100644 --- a/indra/llrender/llfontfreetype.h +++ b/indra/llrender/llfontfreetype.h @@ -27,7 +27,7 @@ #ifndef LL_LLFONTFREETYPE_H #define LL_LLFONTFREETYPE_H -#include <robin_hood.h> +#include <absl/container/flat_hash_map.h> #include "llpointer.h" #include "llstl.h" @@ -160,7 +160,7 @@ class LLFontFreetype final : public LLRefCount, public LLTrace::MemTrackable<LLF bool getKerningCache(U32 left_glyph, U32 right_glyph, F32& kerning) const; void setKerningCache(U32 left_glyph, U32 right_glyph, F32 kerning) const; - mutable robin_hood::unordered_map<U64, F32> mKerningCache; + mutable absl::flat_hash_map<U64, F32> mKerningCache; std::string mName; @@ -181,7 +181,7 @@ class LLFontFreetype final : public LLRefCount, public LLTrace::MemTrackable<LLF BOOL mIsFallback; font_vector_t mFallbackFonts; // A list of fallback fonts to look for glyphs in (for Unicode chars) - typedef robin_hood::unordered_map<llwchar, LLFontGlyphInfo*> char_glyph_info_map_t; + typedef absl::flat_hash_map<llwchar, LLFontGlyphInfo*> char_glyph_info_map_t; mutable char_glyph_info_map_t mCharGlyphInfoMap; // Information about glyph location in bitmap mutable LLFontBitmapCache* mFontBitmapCachep; diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 4b8762d0acece18e9a161c0d83b58a2cfae760c2..f52a6be5192b4dc3532ac3df8d26e270a61285ff 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -1644,7 +1644,7 @@ void clear_glerror() // // Static members -robin_hood::unordered_map<LLGLenum, LLGLboolean> LLGLState::sStateMap; +absl::flat_hash_map<LLGLenum, LLGLboolean> LLGLState::sStateMap; GLboolean LLGLDepthTest::sDepthEnabled = GL_FALSE; // OpenGL default GLenum LLGLDepthTest::sDepthFunc = GL_LESS; // OpenGL default diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index e3e9ef39373ea6a5a2c527829a8a9521637112aa..79a60abef242035cb9239d46b8dfcd2de1074e18 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -30,7 +30,7 @@ // This file contains various stuff for handling gl extensions and other gl related stuff. #include <string> -#include <robin_hood.h> +#include <absl/container/flat_hash_map.h> #include <list> #include "llerror.h" @@ -274,7 +274,7 @@ class LLGLState static void checkClientArrays(const std::string& msg = "", U32 data_mask = 0); protected: - static robin_hood::unordered_map<LLGLenum, LLGLboolean> sStateMap; + static absl::flat_hash_map<LLGLenum, LLGLboolean> sStateMap; public: enum { CURRENT_STATE = -2 }; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index db0734b49d8452bb2d08c9457fec58bb730de283..f5650a61227e70b5d54ca73501aaf22b0a78b4cd 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -146,7 +146,7 @@ LLMaterialMgr::LLMaterialMgr(): mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()); mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_MATERIALS); - mMaterials.insert(std::pair<LLMaterialID, LLMaterialPtr>(LLMaterialID::null, LLMaterialPtr(NULL))); + mMaterials.emplace(std::pair<LLMaterialID, LLMaterialPtr>(LLMaterialID::null, LLMaterialPtr(NULL))); gIdleCallbacks.addFunction(&LLMaterialMgr::onIdle, NULL); LLWorld::instance().setRegionRemovedCallback(boost::bind(&LLMaterialMgr::onRegionRemoved, this, _1)); } @@ -158,16 +158,16 @@ LLMaterialMgr::~LLMaterialMgr() bool LLMaterialMgr::isGetPending(const LLUUID& region_id, const LLMaterialID& material_id) const { - get_pending_map_t::const_iterator itPending = mGetPending.find(pending_material_t(region_id, material_id)); + auto itPending = mGetPending.find(pending_material_t(region_id, material_id)); return (mGetPending.end() != itPending) && (LLFrameTimer::getTotalSeconds() < itPending->second + MATERIALS_POST_TIMEOUT); } void LLMaterialMgr::markGetPending(const LLUUID& region_id, const LLMaterialID& material_id) { - get_pending_map_t::iterator itPending = mGetPending.find(pending_material_t(region_id, material_id)); + auto itPending = mGetPending.find(pending_material_t(region_id, material_id)); if (mGetPending.end() == itPending) { - mGetPending.insert(std::pair<pending_material_t, F64>(pending_material_t(region_id, material_id), LLFrameTimer::getTotalSeconds())); + mGetPending.emplace(pending_material_t(region_id, material_id), LLFrameTimer::getTotalSeconds()); } else { @@ -194,7 +194,7 @@ const LLMaterialPtr LLMaterialMgr::get(const LLUUID& region_id, const LLMaterial if (mGetQueue.end() == itQueue) { LL_DEBUGS("Materials") << "mGetQueue add region " << region_id << " pending " << material_id << LL_ENDL; - std::pair<get_queue_t::iterator, bool> ret = mGetQueue.insert(std::pair<LLUUID, material_queue_t>(region_id, material_queue_t())); + std::pair<get_queue_t::iterator, bool> ret = mGetQueue.emplace(std::pair<LLUUID, material_queue_t>(region_id, material_queue_t())); itQueue = ret.first; } itQueue->second.insert(material_id); @@ -227,7 +227,7 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL if (mGetQueue.end() == itQueue) { LL_DEBUGS("Materials") << "mGetQueue inserting region "<<region_id << LL_ENDL; - std::pair<get_queue_t::iterator, bool> ret = mGetQueue.insert(std::pair<LLUUID, material_queue_t>(region_id, material_queue_t())); + std::pair<get_queue_t::iterator, bool> ret = mGetQueue.emplace(std::pair<LLUUID, material_queue_t>(region_id, material_queue_t())); itQueue = ret.first; } LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; @@ -238,7 +238,7 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); if (itCallback == mGetCallbacks.end()) { - std::pair<get_callback_map_t::iterator, bool> ret = mGetCallbacks.insert(std::pair<LLMaterialID, get_callback_t*>(material_id, new get_callback_t())); + std::pair<get_callback_map_t::iterator, bool> ret = mGetCallbacks.emplace(std::pair<LLMaterialID, get_callback_t*>(material_id, new get_callback_t())); itCallback = ret.first; } connection = itCallback->second->connect(cb);; @@ -268,7 +268,7 @@ boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const if (mGetQueue.end() == itQueue) { LL_DEBUGS("Materials") << "mGetQueue inserting region "<<region_id << LL_ENDL; - std::pair<get_queue_t::iterator, bool> ret = mGetQueue.insert(std::pair<LLUUID, material_queue_t>(region_id, material_queue_t())); + std::pair<get_queue_t::iterator, bool> ret = mGetQueue.emplace(std::pair<LLUUID, material_queue_t>(region_id, material_queue_t())); itQueue = ret.first; } LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; @@ -283,7 +283,7 @@ boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair); if (itCallback == mGetTECallbacks.end()) { - std::pair<get_callback_te_map_t::iterator, bool> ret = mGetTECallbacks.insert(std::pair<TEMaterialPair, get_callback_te_t*>(te_mat_pair, new get_callback_te_t())); + std::pair<get_callback_te_map_t::iterator, bool> ret = mGetTECallbacks.emplace(te_mat_pair, new get_callback_te_t()); itCallback = ret.first; } connection = itCallback->second->connect(cb); @@ -321,7 +321,7 @@ boost::signals2::connection LLMaterialMgr::getAll(const LLUUID& region_id, LLMat getall_callback_map_t::iterator itCallback = mGetAllCallbacks.find(region_id); if (mGetAllCallbacks.end() == itCallback) { - std::pair<getall_callback_map_t::iterator, bool> ret = mGetAllCallbacks.insert(std::pair<LLUUID, getall_callback_t*>(region_id, new getall_callback_t())); + std::pair<getall_callback_map_t::iterator, bool> ret = mGetAllCallbacks.emplace(std::pair<LLUUID, getall_callback_t*>(region_id, new getall_callback_t())); itCallback = ret.first; } return itCallback->second->connect(cb);; @@ -333,14 +333,14 @@ void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial& if (mPutQueue.end() == itQueue) { LL_DEBUGS("Materials") << "mPutQueue insert object " << object_id << LL_ENDL; - auto ret = mPutQueue.insert(std::pair<LLUUID, facematerial_map_t>(object_id, facematerial_map_t())); + auto ret = mPutQueue.emplace(std::pair<LLUUID, facematerial_map_t>(object_id, facematerial_map_t())); itQueue = ret.first; } facematerial_map_t::iterator itFace = itQueue->second.find(te); if (itQueue->second.end() == itFace) { - itQueue->second.insert(std::pair<U8, LLMaterial>(te, material)); + itQueue->second.emplace(std::pair<U8, LLMaterial>(te, material)); } else { @@ -365,7 +365,7 @@ void LLMaterialMgr::setLocalMaterial(const LLUUID& region_id, LLMaterialPtr mate } LL_DEBUGS("Materials") << "region " << region_id << "new local material id " << material_id << LL_ENDL; - mMaterials.insert(std::pair<LLMaterialID, LLMaterialPtr>(material_id, material_ptr)); + mMaterials.emplace(material_id, material_ptr); setMaterialCallbacks(material_id, material_ptr); @@ -380,7 +380,7 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL { LL_DEBUGS("Materials") << "new material" << LL_ENDL; LLMaterialPtr newMaterial(new LLMaterial(material_data)); - std::pair<material_map_t::const_iterator, bool> ret = mMaterials.insert(std::pair<LLMaterialID, LLMaterialPtr>(material_id, newMaterial)); + std::pair<material_map_t::const_iterator, bool> ret = mMaterials.emplace(std::make_pair(material_id, newMaterial)); itMaterial = ret.first; } @@ -827,7 +827,7 @@ void LLMaterialMgr::processGetAllQueue() LLCoros::instance().launch("LLMaterialMgr::processGetAllQueueCoro", boost::bind(&LLMaterialMgr::processGetAllQueueCoro, this, region_id)); - mGetAllPending.insert(std::pair<LLUUID, F64>(region_id, LLFrameTimer::getTotalSeconds())); + mGetAllPending.emplace(std::pair<LLUUID, F64>(region_id, LLFrameTimer::getTotalSeconds())); mGetAllQueue.erase(itRegion); // Invalidates region_id } } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 31e7fa19170fe586ee00c4da56733e55124190ee..ab48249acf22a03f2bf0b2d1cb0b36303570b51b 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -33,18 +33,19 @@ #include "httprequest.h" #include "httpheaders.h" #include "httpoptions.h" - -#include <boost/unordered_map.hpp> +#include "absl/container/flat_hash_map.h" +#include "absl/container/node_hash_map.h" +#include "absl/container/flat_hash_set.h" class LLViewerRegion; -class LLMaterialMgr : public LLSingleton<LLMaterialMgr> +class LLMaterialMgr final : public LLSingleton<LLMaterialMgr> { LLSINGLETON(LLMaterialMgr); virtual ~LLMaterialMgr(); public: - typedef std::map<LLMaterialID, LLMaterialPtr> material_map_t; + typedef absl::node_hash_map<LLMaterialID, LLMaterialPtr> material_map_t; typedef boost::signals2::signal<void (const LLMaterialID&, const LLMaterialPtr)> get_callback_t; const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); @@ -89,41 +90,31 @@ class LLMaterialMgr : public LLSingleton<LLMaterialMgr> class TEMaterialPair { public: - U32 te; LLMaterialID materialID; + template <typename H> + friend H AbslHashValue(H h, const TEMaterialPair& m) { + return H::combine(std::move(h), m.materialID, m.te); + } + bool operator==(const TEMaterialPair& b) const { return (materialID == b.materialID) && (te == b.te); } + bool operator<(const TEMaterialPair& b) const { return (te < b.te) ? TRUE : (materialID < b.materialID);} }; - friend inline bool operator<( - const LLMaterialMgr::TEMaterialPair& lhs, - const LLMaterialMgr::TEMaterialPair& rhs) - { - return (lhs.te < rhs.te) ? TRUE : - (lhs.materialID < rhs.materialID); - } - - struct TEMaterialPairHasher - { - enum { bucket_size = 8 }; - size_t operator()(const TEMaterialPair& key_value) const { return *((size_t*)key_value.materialID.get()); } // cheesy, but effective - bool operator()(const TEMaterialPair& left, const TEMaterialPair& right) const { return left < right; } - }; - - typedef std::set<LLMaterialID> material_queue_t; - typedef std::map<LLUUID, material_queue_t> get_queue_t; + typedef absl::flat_hash_set<LLMaterialID> material_queue_t; + typedef absl::flat_hash_map<LLUUID, material_queue_t> get_queue_t; typedef std::pair<const LLUUID, LLMaterialID> pending_material_t; - typedef std::map<const pending_material_t, F64> get_pending_map_t; - typedef std::map<LLMaterialID, get_callback_t*> get_callback_map_t; + typedef absl::flat_hash_map<const pending_material_t, F64> get_pending_map_t; + typedef absl::flat_hash_map<LLMaterialID, get_callback_t*> get_callback_map_t; - typedef boost::unordered_map<TEMaterialPair, get_callback_te_t*, TEMaterialPairHasher> get_callback_te_map_t; - typedef std::set<LLUUID> getall_queue_t; - typedef std::map<LLUUID, F64> getall_pending_map_t; - typedef std::map<LLUUID, getall_callback_t*> getall_callback_map_t; - typedef std::map<U8, LLMaterial> facematerial_map_t; - typedef std::map<LLUUID, facematerial_map_t> put_queue_t; + typedef absl::flat_hash_map<TEMaterialPair, get_callback_te_t*> get_callback_te_map_t; + typedef absl::flat_hash_set<LLUUID> getall_queue_t; + typedef absl::flat_hash_map<LLUUID, F64> getall_pending_map_t; + typedef absl::flat_hash_map<LLUUID, getall_callback_t*> getall_callback_map_t; + typedef absl::flat_hash_map<U8, LLMaterial> facematerial_map_t; + typedef absl::flat_hash_map<LLUUID, facematerial_map_t> put_queue_t; get_queue_t mGetQueue; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index dfccc2ba1649adff88a27510d6c4cc866edd0039..2c6a0c3a31417cec22ea3f67c5d3b9af9ffcd143 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -144,11 +144,13 @@ #include "rlvlocks.h" // [/RLVa:KB] +#include <absl/container/flat_hash_map.h> + using namespace LLAvatarAppearanceDefines; typedef LLPointer<LLViewerObject> LLViewerObjectPtr; -static robin_hood::unordered_map<std::string, LLStringExplicit> sDefaultItemLabels; +static absl::flat_hash_map<std::string, LLStringExplicit> sDefaultItemLabels; BOOL enable_land_build(void*); BOOL enable_object_build(void*); diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index c7c5b6534a8201d9147937fb8be89de9ab0c9349..fb054bf4097611f50a50af8a1811feac17c7a7fb 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -98,8 +98,8 @@ extern LLPipeline gPipeline; // Statics for object lookup tables. U32 LLViewerObjectList::sSimulatorMachineIndex = 1; // Not zero deliberately, to speed up index check. -robin_hood::unordered_map<U64, U32> LLViewerObjectList::sIPAndPortToIndex; -robin_hood::unordered_node_map<U64, LLUUID> LLViewerObjectList::sIndexAndLocalIDToUUID; +absl::flat_hash_map<U64, U32> LLViewerObjectList::sIPAndPortToIndex; +absl::node_hash_map<U64, LLUUID> LLViewerObjectList::sIndexAndLocalIDToUUID; LLViewerObjectList::LLViewerObjectList() { diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index 2a3016b1cea53ebe03a9fc187e811ebdc7509595..79ca0d0dd8d622ee5ca76b799a665a35d26f4499 100644 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -40,7 +40,8 @@ #include "llcoros.h" // system includes -#include <boost/unordered_map.hpp> +#include <absl/container/flat_hash_map.h> +#include <absl/container/node_hash_map.h> class LLCamera; class LLNetMap; @@ -213,7 +214,7 @@ class LLViewerObjectList uuid_set_t mDeadObjects; - robin_hood::unordered_map<LLUUID, LLPointer<LLViewerObject> > mUUIDObjectMap; + absl::flat_hash_map<LLUUID, LLPointer<LLViewerObject> > mUUIDObjectMap; //set of objects that need to update their cost uuid_set_t mStaleObjectCost; @@ -228,9 +229,9 @@ class LLViewerObjectList S32 mCurLazyUpdateIndex; static U32 sSimulatorMachineIndex; - static robin_hood::unordered_map<U64, U32> sIPAndPortToIndex; + static absl::flat_hash_map<U64, U32> sIPAndPortToIndex; - static robin_hood::unordered_node_map<U64, LLUUID> sIndexAndLocalIDToUUID; + static absl::node_hash_map<U64, LLUUID> sIndexAndLocalIDToUUID; std::set<LLViewerObject *> mSelectPickList;