diff --git a/include/Nazara/Core/String.hpp b/include/Nazara/Core/String.hpp index 56d7cee9f..cb38105eb 100644 --- a/include/Nazara/Core/String.hpp +++ b/include/Nazara/Core/String.hpp @@ -323,4 +323,6 @@ namespace std NAZARA_API void swap(NzString& lhs, NzString& rhs); } +#include + #endif // NAZARA_STRING_HPP diff --git a/include/Nazara/Core/String.inl b/include/Nazara/Core/String.inl new file mode 100644 index 000000000..5225e5dce --- /dev/null +++ b/include/Nazara/Core/String.inl @@ -0,0 +1,33 @@ +// Copyright (C) 2013 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include + +namespace std +{ + template<> + struct hash + { + public: + size_t operator()(const NzString& str) const + { + // Algorithme DJB2 + // http://www.cse.yorku.ca/~oz/hash.html + + size_t h = 5381; + if (!str.IsEmpty()) + { + const char* ptr = str.GetConstBuffer(); + + do + h = ((h << 5) + h) + *ptr; + while (*++ptr); + } + + return h; + } + }; +} + +#include diff --git a/src/Nazara/Core/PluginManager.cpp b/src/Nazara/Core/PluginManager.cpp index 03859b8ea..7cc63288b 100644 --- a/src/Nazara/Core/PluginManager.cpp +++ b/src/Nazara/Core/PluginManager.cpp @@ -8,8 +8,8 @@ #include #include #include -#include #include +#include #include namespace @@ -18,7 +18,7 @@ namespace using PluginUnload = void (*)(); std::list s_directories; - std::map s_plugins; + std::unordered_map s_plugins; NzString s_pluginFiles[] = { diff --git a/src/Nazara/Graphics/Loaders/OBJ/MTLParser.hpp b/src/Nazara/Graphics/Loaders/OBJ/MTLParser.hpp index 09ca9ab30..340de75f5 100644 --- a/src/Nazara/Graphics/Loaders/OBJ/MTLParser.hpp +++ b/src/Nazara/Graphics/Loaders/OBJ/MTLParser.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include class NzMTLParser { @@ -49,7 +49,7 @@ class NzMTLParser void Warning(const NzString& message); void UnrecognizedLine(bool error = false); - std::map m_materials; + std::unordered_map m_materials; NzInputStream& m_stream; NzString m_currentLine; bool m_keepLastLine; diff --git a/src/Nazara/Graphics/Loaders/OBJ/OBJParser.cpp b/src/Nazara/Graphics/Loaders/OBJ/OBJParser.cpp index 2fa0fd682..0fc61e5fc 100644 --- a/src/Nazara/Graphics/Loaders/OBJ/OBJParser.cpp +++ b/src/Nazara/Graphics/Loaders/OBJ/OBJParser.cpp @@ -7,8 +7,8 @@ #include #include #include -#include #include +#include #include NzOBJParser::NzOBJParser(NzInputStream& stream) : @@ -98,7 +98,7 @@ bool NzOBJParser::Parse() m_positions.reserve(100); m_texCoords.reserve(100); - std::map>> meshes; + std::unordered_map>> meshes; std::vector* currentMesh = &meshes[meshName][matName]; @@ -348,7 +348,7 @@ bool NzOBJParser::Parse() } } - std::map materials; + std::unordered_map materials; unsigned int matCount = 0; for (auto meshIt : meshes) diff --git a/src/Nazara/Renderer/GLSLShader.hpp b/src/Nazara/Renderer/GLSLShader.hpp index 1633fdd6c..54f350af4 100644 --- a/src/Nazara/Renderer/GLSLShader.hpp +++ b/src/Nazara/Renderer/GLSLShader.hpp @@ -13,6 +13,7 @@ #include #include #include +#include class NzResource; @@ -68,7 +69,7 @@ class NzGLSLShader : public NzAbstractShader, NzResourceListener const NzTexture* texture; }; - mutable std::map m_idCache; ///FIXME: unordered_map + mutable std::unordered_map m_idCache; std::map m_textures; ///FIXME: unordered_map GLuint m_program; GLuint m_shaders[nzShaderType_Max+1]; diff --git a/src/Nazara/Utility/Animation.cpp b/src/Nazara/Utility/Animation.cpp index 3cb82975e..976ae3ea0 100644 --- a/src/Nazara/Utility/Animation.cpp +++ b/src/Nazara/Utility/Animation.cpp @@ -6,13 +6,13 @@ #include #include #include -#include #include +#include #include struct NzAnimationImpl { - std::map sequenceMap; + std::unordered_map sequenceMap; std::vector sequences; std::vector sequenceJoints; // Uniquement pour les animations squelettiques nzAnimationType type; diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index 4d54ec2c1..afdf1c6bd 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -18,9 +18,9 @@ #include #include #include -#include -#include #include +#include +#include #include NzMeshParams::NzMeshParams() @@ -48,7 +48,7 @@ bool NzMeshParams::IsValid() const struct NzMeshImpl { - std::map subMeshMap; + std::unordered_map subMeshMap; std::vector materials; std::vector subMeshes; nzAnimationType animationType; diff --git a/src/Nazara/Utility/Skeleton.cpp b/src/Nazara/Utility/Skeleton.cpp index 02855a051..cce73adb8 100644 --- a/src/Nazara/Utility/Skeleton.cpp +++ b/src/Nazara/Utility/Skeleton.cpp @@ -3,12 +3,12 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include +#include #include struct NzSkeletonImpl { - std::map jointMap; ///FIXME: unordered_map + std::unordered_map jointMap; std::vector joints; NzBoxf aabb; bool aabbUpdated = false;