Added std::hash for String, made use of unordered_map
Former-commit-id: 20f3d12bc3222873706949f0a7d0a131e237a247
This commit is contained in:
parent
3e82794b70
commit
3609f31708
|
|
@ -323,4 +323,6 @@ namespace std
|
|||
NAZARA_API void swap(NzString& lhs, NzString& rhs);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/String.inl>
|
||||
|
||||
#endif // NAZARA_STRING_HPP
|
||||
|
|
|
|||
|
|
@ -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 <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<>
|
||||
struct hash<NzString>
|
||||
{
|
||||
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 <Nazara/Core/DebugOff.hpp>
|
||||
|
|
@ -8,8 +8,8 @@
|
|||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace
|
||||
|
|
@ -18,7 +18,7 @@ namespace
|
|||
using PluginUnload = void (*)();
|
||||
|
||||
std::list<NzString> s_directories;
|
||||
std::map<NzString, NzDynLib*> s_plugins;
|
||||
std::unordered_map<NzString, NzDynLib*> s_plugins;
|
||||
|
||||
NzString s_pluginFiles[] =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
class NzMTLParser
|
||||
{
|
||||
|
|
@ -49,7 +49,7 @@ class NzMTLParser
|
|||
void Warning(const NzString& message);
|
||||
void UnrecognizedLine(bool error = false);
|
||||
|
||||
std::map<NzString, Material> m_materials;
|
||||
std::unordered_map<NzString, Material> m_materials;
|
||||
NzInputStream& m_stream;
|
||||
NzString m_currentLine;
|
||||
bool m_keepLastLine;
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
#include <Nazara/Core/Log.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <cstdio>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
NzOBJParser::NzOBJParser(NzInputStream& stream) :
|
||||
|
|
@ -98,7 +98,7 @@ bool NzOBJParser::Parse()
|
|||
m_positions.reserve(100);
|
||||
m_texCoords.reserve(100);
|
||||
|
||||
std::map<NzString, std::map<NzString, std::vector<Face>>> meshes;
|
||||
std::unordered_map<NzString, std::unordered_map<NzString, std::vector<Face>>> meshes;
|
||||
|
||||
std::vector<Face>* currentMesh = &meshes[meshName][matName];
|
||||
|
||||
|
|
@ -348,7 +348,7 @@ bool NzOBJParser::Parse()
|
|||
}
|
||||
}
|
||||
|
||||
std::map<NzString, unsigned int> materials;
|
||||
std::unordered_map<NzString, unsigned int> materials;
|
||||
unsigned int matCount = 0;
|
||||
|
||||
for (auto meshIt : meshes)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <Nazara/Renderer/OpenGL.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
class NzResource;
|
||||
|
||||
|
|
@ -68,7 +69,7 @@ class NzGLSLShader : public NzAbstractShader, NzResourceListener
|
|||
const NzTexture* texture;
|
||||
};
|
||||
|
||||
mutable std::map<NzString, GLint> m_idCache; ///FIXME: unordered_map
|
||||
mutable std::unordered_map<NzString, GLint> m_idCache;
|
||||
std::map<GLint, TextureSlot> m_textures; ///FIXME: unordered_map
|
||||
GLuint m_program;
|
||||
GLuint m_shaders[nzShaderType_Max+1];
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@
|
|||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Skeleton.hpp>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
struct NzAnimationImpl
|
||||
{
|
||||
std::map<NzString, unsigned int> sequenceMap;
|
||||
std::unordered_map<NzString, unsigned int> sequenceMap;
|
||||
std::vector<NzSequence> sequences;
|
||||
std::vector<NzSequenceJoint> sequenceJoints; // Uniquement pour les animations squelettiques
|
||||
nzAnimationType type;
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@
|
|||
#include <Nazara/Utility/StaticMesh.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
NzMeshParams::NzMeshParams()
|
||||
|
|
@ -48,7 +48,7 @@ bool NzMeshParams::IsValid() const
|
|||
|
||||
struct NzMeshImpl
|
||||
{
|
||||
std::map<NzString, unsigned int> subMeshMap;
|
||||
std::unordered_map<NzString, unsigned int> subMeshMap;
|
||||
std::vector<NzString> materials;
|
||||
std::vector<NzSubMesh*> subMeshes;
|
||||
nzAnimationType animationType;
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Skeleton.hpp>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
struct NzSkeletonImpl
|
||||
{
|
||||
std::map<NzString, unsigned int> jointMap; ///FIXME: unordered_map
|
||||
std::unordered_map<NzString, unsigned int> jointMap;
|
||||
std::vector<NzJoint> joints;
|
||||
NzBoxf aabb;
|
||||
bool aabbUpdated = false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue