mirror of
https://github.com/fluencelabs/redis
synced 2025-06-20 20:46:31 +00:00
Optimize repeated keyname hashing.
(Change cherry-picked and modified by @antirez from a larger commit provided by @oranagra in PR #3223).
This commit is contained in:
@ -3640,15 +3640,15 @@ struct sentinelLeader {
|
||||
/* Helper function for sentinelGetLeader, increment the counter
|
||||
* relative to the specified runid. */
|
||||
int sentinelLeaderIncr(dict *counters, char *runid) {
|
||||
dictEntry *de = dictFind(counters,runid);
|
||||
dictEntry *existing, *de;
|
||||
uint64_t oldval;
|
||||
|
||||
if (de) {
|
||||
oldval = dictGetUnsignedIntegerVal(de);
|
||||
dictSetUnsignedIntegerVal(de,oldval+1);
|
||||
de = dictAddRaw(counters,runid,&existing);
|
||||
if (existing) {
|
||||
oldval = dictGetUnsignedIntegerVal(existing);
|
||||
dictSetUnsignedIntegerVal(existing,oldval+1);
|
||||
return oldval+1;
|
||||
} else {
|
||||
de = dictAddRaw(counters,runid);
|
||||
serverAssert(de != NULL);
|
||||
dictSetUnsignedIntegerVal(de,1);
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user