Pārlūkot izejas kodu

Switch to murmur2 hash for resource systems as well

Daniele Bartolini 13 gadi atpakaļ
vecāks
revīzija
b3a115a591
2 mainītis faili ar 10 papildinājumiem un 7 dzēšanām
  1. 5 4
      src/ResourceLoader.cpp
  2. 5 3
      src/ResourceManager.cpp

+ 5 - 4
src/ResourceLoader.cpp

@@ -44,10 +44,11 @@ ResourceLoader::ResourceLoader(Allocator& resource_allocator, ResourceArchive& a
 	m_loading_callback(NULL),
 	m_online_callback(NULL)
 {
-	m_config_hash = hash::fnv1a_32("config", string::strlen("config"));
-	m_texture_hash = hash::fnv1a_32("tga", string::strlen("tga"));
-	m_mesh_hash = hash::fnv1a_32("mesh", string::strlen("mesh"));
-	m_txt_hash = hash::fnv1a_32("txt", 3);
+	// FIXME hardcoded seed
+	m_config_hash = hash::murmur2_32("config", string::strlen("config"), 0);
+	m_texture_hash = hash::murmur2_32("tga", string::strlen("tga"), 0);
+	m_mesh_hash = hash::murmur2_32("mesh", string::strlen("mesh"), 0);
+	m_txt_hash = hash::murmur2_32("txt", 3, 0);
 }
 
 //-----------------------------------------------------------------------------

+ 5 - 3
src/ResourceManager.cpp

@@ -58,8 +58,9 @@ ResourceId ResourceManager::load(const char* name)
 	path::filename_without_extension(name, basename, 512);
 	path::extension(name, extension, 512);
 
-	uint32_t name_hash = hash::fnv1a_32(basename, string::strlen(basename));
-	uint32_t type_hash = hash::fnv1a_32(extension, string::strlen(extension));
+	// FIXME hardcoded seed
+	uint32_t name_hash = hash::murmur2_32(basename, string::strlen(basename), 0);
+	uint32_t type_hash = hash::murmur2_32(extension, string::strlen(extension), 0);
 
 	return load(name_hash, type_hash);
 }
@@ -184,7 +185,8 @@ void ResourceManager::online(ResourceId name, void* resource)
 
 	ResourceEntry& entry = m_resources[name.index];
 
-	if (name.type == hash::fnv1a_32("tga", 3))
+	// FIXME hardcoded seed
+	if (name.type == hash::murmur2_32("tga", 3, 0))
 	{
 		TextureResource::online((TextureResource*)resource);
 	}