diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-07-02 19:12:53 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-07-02 19:12:53 +0000 |
| commit | 2948231e0f3dfaab58e68c74d13c36b84c70ff2a (patch) | |
| tree | 586d51a18e346097d990e2b3fd6b77aa89deea21 /src/runtime/c/gu | |
| parent | c0a0859566dedd0f73b20285ea1d38aa15728c6b (diff) | |
hash function for abstract syntax trees
Diffstat (limited to 'src/runtime/c/gu')
| -rw-r--r-- | src/runtime/c/gu/string.c | 10 | ||||
| -rw-r--r-- | src/runtime/c/gu/string.h | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/runtime/c/gu/string.c b/src/runtime/c/gu/string.c index 7ffd43068..7655b32ab 100644 --- a/src/runtime/c/gu/string.c +++ b/src/runtime/c/gu/string.c @@ -367,15 +367,15 @@ gu_string_is_prefix(GuString s1, GuString s2) return true; } -GuWord -gu_string_hash(GuString s) +GuHash +gu_string_hash(GuHash h, GuString s) { if (s.w_ & 1) { - return s.w_; + return h*101 + s.w_; } size_t len = gu_string_length(s); uint8_t* data = gu_string_long_data(s); - return gu_hash_bytes(0, data, len); + return gu_hash_bytes(h, data, len); } bool @@ -403,7 +403,7 @@ gu_string_hasher_hash(GuHasher* self, const void* p) { (void) self; const GuString* sp = p; - return gu_string_hash(*sp); + return gu_string_hash(0, *sp); } static bool diff --git a/src/runtime/c/gu/string.h b/src/runtime/c/gu/string.h index 37cb56ac2..a8376d335 100644 --- a/src/runtime/c/gu/string.h +++ b/src/runtime/c/gu/string.h @@ -78,8 +78,8 @@ gu_string_is_prefix(GuString s1, GuString s2); #if defined(GU_HASH_H_) && !defined(GU_STRING_H_HASH_) #define GU_STRING_H_HASH_ -uintptr_t -gu_string_hash(GuString s); +GuHash +gu_string_hash(GuHash h, GuString s); extern GuHasher gu_string_hasher[1]; |
