Move strhash to string_utils.h

This commit is contained in:
baldurk
2016-02-07 18:48:56 +01:00
parent 79819d4f94
commit 49f81a6499
3 changed files with 21 additions and 18 deletions
-18
View File
@@ -359,24 +359,6 @@ D3D11DebugManager::~D3D11DebugManager()
//////////////////////////////////////////////////////
// debug/replay functions
static uint32_t strhash(const char *str, uint32_t seed = 5381)
{
if(str == NULL) return seed;
uint32_t hash = seed;
int c = *str;
str++;
while(c)
{
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
c = *str;
str++;
}
return hash;
}
string D3D11DebugManager::GetShaderBlob(const char *source, const char *entry, const uint32_t compileFlags, const char *profile, ID3DBlob **srcblob)
{
uint32_t hash = strhash(source);
+18
View File
@@ -28,6 +28,24 @@
#include <ctype.h>
#include <wctype.h>
uint32_t strhash(const char *str, uint32_t seed)
{
if(str == NULL) return seed;
uint32_t hash = seed;
int c = *str;
str++;
while(c)
{
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
c = *str;
str++;
}
return hash;
}
string strlower(const string& str)
{
string newstr(str);
+3
View File
@@ -24,6 +24,7 @@
#pragma once
#include <stdint.h>
#include <string>
#include <vector>
using std::string;
@@ -35,6 +36,8 @@ std::wstring strlower(const std::wstring& str);
std::string strupper(const std::string& str);
std::wstring strupper(const std::wstring& str);
uint32_t strhash(const char *str, uint32_t existingHash = 5381);
template<class strType> strType basename(const strType &path)
{
strType base = path;