From 4f8e1e58427147b7a9a784639e2170d34c5d3221 Mon Sep 17 00:00:00 2001 From: fujuntang <fujuntang@smartai.com> Date: 星期五, 19 十一月 2021 16:09:35 +0800 Subject: [PATCH] Optimize the logic to avoid the possible issue. --- src/shm/hashtable.cpp | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/src/shm/hashtable.cpp b/src/shm/hashtable.cpp index 2cc9e38..7162118 100755 --- a/src/shm/hashtable.cpp +++ b/src/shm/hashtable.cpp @@ -316,8 +316,15 @@ static size_t hashcode(int key) { + int val; - return key % MAPSIZE; + if (key < MAPSIZE) { + val = key; + } else { + val = key % MAPSIZE + START_KEY; + } + + return val; } /** -- Gitblit v1.8.0