Prechádzať zdrojové kódy

Do not need to typedef StringId32/64 for string hashing

Daniele Bartolini 13 rokov pred
rodič
commit
03b3a4869d

+ 2 - 2
src/Resource.h

@@ -43,8 +43,8 @@ enum ResourceState
 /// the index to the resource list where it is stored.
 struct ResourceId
 {
-	StringId32		name;
-	StringId32		type;
+	uint32_t		name;
+	uint32_t		type;
 	uint32_t		index;
 };
 

+ 3 - 3
src/ResourceLoader.h

@@ -33,9 +33,9 @@ private:
 	MallocAllocator		m_allocator;
 	Queue<ResourceId>	m_resources;
 	
-	StringId32			m_config_hash;
-	StringId32			m_texture_hash;
-	StringId32			m_mesh_hash;
+	uint32_t			m_config_hash;
+	uint32_t			m_texture_hash;
+	uint32_t			m_mesh_hash;
 };
 
 } // namespace crown

+ 2 - 2
src/ResourceManager.cpp

@@ -47,13 +47,13 @@ ResourceManager::~ResourceManager()
 //-----------------------------------------------------------------------------
 ResourceId ResourceManager::load(const char* name)
 {
-	StringId32 name_hash = string::Hash32(name);
+	uint32_t name_hash = string::Hash32(name);
 
 	return load(name_hash);
 }
 
 //-----------------------------------------------------------------------------
-ResourceId ResourceManager::load(StringId32 name)
+ResourceId ResourceManager::load(uint32_t name)
 {
 	// Search for an already existent resource
 	ResourceEntry* entry = std::find(m_resources.begin(), m_resources.end(), name);

+ 2 - 2
src/ResourceManager.h

@@ -43,7 +43,7 @@ struct ResourceEntry
 
 	void*			resource;
 
-	bool			operator==(const StringId32& name)
+	bool			operator==(const uint32_t& name)
 					{
 						return id.name == name;
 					}
@@ -65,7 +65,7 @@ public:
 							~ResourceManager();
 
 	ResourceId				load(const char* name);
-	ResourceId				load(StringId32 name);
+	ResourceId				load(uint32_t name);
 
 	void					unload(ResourceId name);
 	void					reload(ResourceId name);

+ 0 - 3
src/core/Types.h

@@ -38,9 +38,6 @@ typedef float					real;
 typedef double					real;
 #endif
 
-typedef uint32_t				StringId32;	// 32-bit string hash
-typedef uint32_t				StringId64;	// 64-bit string hash
-
 #ifndef NULL
 #ifdef __cplusplus
 #define NULL    0

+ 8 - 8
src/core/strings/String.h

@@ -38,10 +38,10 @@ namespace string
 
 static const char*		EMPTY = "";
 
-static StringId32		Hash32(const char* str);
-static StringId32		Hash32(const char* str, size_t len);
-static StringId64		Hash64(const char* str);
-static StringId64		Hash64(const char* str, size_t len);
+static uint32_t			Hash32(const char* str);
+static uint32_t			Hash32(const char* str, size_t len);
+static uint64_t			Hash64(const char* str);
+static uint64_t			Hash64(const char* str, size_t len);
 
 static bool				is_alpha(char c);
 static bool				is_digit(char c);
@@ -357,7 +357,7 @@ inline bool is_whitespace(char c)
 }
 
 //-----------------------------------------------------------------------------
-inline StringId32 Hash32(const char* str)
+inline uint32_t Hash32(const char* str)
 {
 	assert(str != NULL);
 
@@ -374,7 +374,7 @@ inline StringId32 Hash32(const char* str)
 }
 
 //-----------------------------------------------------------------------------
-inline StringId32 Hash32(const char* str, size_t len)
+inline uint32_t Hash32(const char* str, size_t len)
 {
 	assert(str != NULL);
 	assert(len <= string::strlen(str));
@@ -392,7 +392,7 @@ inline StringId32 Hash32(const char* str, size_t len)
 }
 
 //-----------------------------------------------------------------------------
-inline StringId64 Hash64(const char* str)
+inline uint64_t Hash64(const char* str)
 {
 	assert(str != NULL);
 
@@ -409,7 +409,7 @@ inline StringId64 Hash64(const char* str)
 }
 
 //-----------------------------------------------------------------------------
-inline StringId64 Hash64(const char* str, size_t len)
+inline uint64_t Hash64(const char* str, size_t len)
 {
 	assert(str != NULL);
 	assert(len <= string::strlen(str));