File tree 1 file changed +4
-5
lines changed
1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 2
2
* File: util.h
3
3
* Description: Misc STL string utility functions.
4
4
* Author: Samuel Charron
5
- * Created: Mon Nov 18 2013
6
5
*
7
6
* (C) Copyright 2013, Google Inc.
8
7
* Licensed under the Apache License, Version 2.0 (the "License");
32
31
struct StringHash {
33
32
size_t operator ()(const std::string& s) const {
34
33
size_t hash_code = 0 ;
35
- const char * str = s.c_str ();
36
- for (int ch = 0 ; str[ch] != 0 ; ++ch) {
34
+ const uint8_t * str = reinterpret_cast < const uint8_t *>( s.c_str () );
35
+ for (unsigned ch = 0 ; str[ch] != 0 ; ++ch) {
37
36
hash_code += str[ch] << (ch % 24 );
38
37
}
39
38
return hash_code;
@@ -43,8 +42,8 @@ struct StringHash {
43
42
struct StringHash : public stdext ::hash_compare <std::string> {
44
43
size_t operator ()(const std::string& s) const {
45
44
size_t hash_code = 0 ;
46
- const char * str = s.c_str ();
47
- for (int ch = 0 ; str[ch] != 0 ; ++ch) {
45
+ const uint8_t * str = reinterpret_cast < const uint8_t *>( s.c_str () );
46
+ for (unsigned ch = 0 ; str[ch] != 0 ; ++ch) {
48
47
hash_code += str[ch] << (ch % 24 );
49
48
}
50
49
return hash_code;
You can’t perform that action at this time.
0 commit comments