1
0
forked from 0ad/0ad

Removes unused fnv_lc_hash, also file paths case sensitive so we can't use the function.

This was SVN commit r26010.
This commit is contained in:
Vladislav Belov 2021-11-25 16:58:04 +00:00
parent 25ce179cbc
commit 265a2246f0
3 changed files with 5 additions and 50 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games.
/* Copyright (C) 2021 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -20,12 +20,9 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* Fowler/Noll/Vo string hash
*/
#include "precompiled.h"
#include "lib/fnv_hash.h"
// FNV1-A hash - good for strings.
// if len = 0 (default), treat buf as a C-string;
@ -62,7 +59,6 @@ u32 fnv_hash(const void* buf, size_t len)
return h;
}
// FNV1-A hash - good for strings.
// if len = 0 (default), treat buf as a C-string;
// otherwise, hash <len> bytes of buf.
@ -97,37 +93,3 @@ u64 fnv_hash64(const void* buf, size_t len)
return h;
}
// special version for strings: first converts to lowercase
// (useful for comparing mixed-case filenames).
// note: still need <len>, e.g. to support non-0-terminated strings
u32 fnv_lc_hash(const char* str, size_t len)
{
u32 h = 0x811c9dc5u;
// give distinct values for different length 0 buffers.
// value taken from FNV; it has no special significance.
// expected case: string
if(!len)
{
while(*str)
{
h ^= tolower(*str++);
h *= 0x01000193u;
}
}
else
{
size_t bytes_left = len;
while(bytes_left != 0)
{
h ^= tolower(*str++);
h *= 0x01000193u;
bytes_left--;
}
}
return h;
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games.
/* Copyright (C) 2021 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -46,10 +46,4 @@ extern u32 fnv_hash(const void* buf, size_t len = 0);
/// 64-bit version of fnv_hash.
extern u64 fnv_hash64(const void* buf, size_t len = 0);
/**
* special version of fnv_hash for strings: first converts to lowercase
* (useful for comparing mixed-case filenames)
**/
extern u32 fnv_lc_hash(const char* str, size_t len = 0);
#endif // #ifndef INCLUDED_FNV_HASH
#endif // INCLUDED_FNV_HASH

View File

@ -32,8 +32,7 @@ public:
TS_ASSERT_EQUALS(fnv_hash(""), 0x811C9DC5u); // verify initial value
const u32 h1 = fnv_hash("abcdef");
TS_ASSERT_EQUALS(h1, 0xFF478A2A); // verify value for simple string
TS_ASSERT_EQUALS(fnv_hash ("abcdef", 6), h1); // same result if hashing buffer
TS_ASSERT_EQUALS(fnv_lc_hash("ABcDeF", 6), h1); // same result if case differs
TS_ASSERT_EQUALS(fnv_hash("abcdef", 6), h1); // same result if hashing buffer
TS_ASSERT_EQUALS(fnv_hash64(""), 0xCBF29CE484222325ull); // verify initial value
const u64 h2 = fnv_hash64("abcdef");