diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-12-13 15:20:58 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-12-13 15:20:58 -0300 |
commit | 7c39ebd05cbead99ead5b29021d8b83468a39d4d (patch) | |
tree | f4b7eb19700b30784ddf19c65d6fbaee2ac127ea /core | |
parent | 39f345a9ae12d99cee50059293fc9dc8eee4ef41 (diff) |
-hash dictionaries properly instead of using pointer, fixes #2880
Diffstat (limited to 'core')
-rw-r--r-- | core/dictionary.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/core/dictionary.cpp b/core/dictionary.cpp index b2d31f230d..c544573629 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -160,7 +160,20 @@ void Dictionary::_unref() const { } uint32_t Dictionary::hash() const { - return hash_djb2_one_64(make_uint64_t(_p)); + uint32_t h=hash_djb2_one_32(Variant::DICTIONARY); + + List<Variant> keys; + get_key_list(&keys); + + for (List<Variant>::Element *E=keys.front();E;E=E->next()) { + + h = hash_djb2_one_32( E->get().hash(), h); + h = hash_djb2_one_32( operator[](E->get()).hash(), h); + + } + + + return h; } Array Dictionary::keys() const { |