You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2020/01/09 10:33:39 UTC

[GitHub] [incubator-brpc] pexeer commented on a change in pull request #1009: bugfix to the hash function HashInts32.

pexeer commented on a change in pull request #1009: bugfix to the hash function HashInts32.
URL: https://github.com/apache/incubator-brpc/pull/1009#discussion_r364665770
 
 

 ##########
 File path: src/butil/containers/hash_tables.h
 ##########
 @@ -129,8 +129,10 @@ using BUTIL_HASH_NAMESPACE::hash_set;
 //
 // Contact danakj@chromium.org for any questions.
 inline std::size_t HashInts32(uint32_t value1, uint32_t value2) {
-  uint64_t value1_64 = value1;
-  uint64_t hash64 = (value1_64 << 32) | value2;
+  uint64_t short_random1 = 842304669U;
+  uint64_t short_random2 = 619063811U;
+
+  uint64_t hash64 =  short_random1 * value1 + short_random2 * value2;
 
 Review comment:
   good idea!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org