mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-06 01:07:06 +08:00
slightly optimize lock_map RWLocks.
"writeLocks" don't need to be sorted,and the index can be added into the "writeIndexSet" directly.
This commit is contained in:
@@ -131,9 +131,9 @@ func (locks *Locks) RUnLocks(keys ...string) {
|
||||
func (locks *Locks) RWLocks(writeKeys []string, readKeys []string) {
|
||||
keys := append(writeKeys, readKeys...)
|
||||
indices := locks.toLockIndices(keys, false)
|
||||
writeIndices := locks.toLockIndices(writeKeys, false)
|
||||
writeIndexSet := make(map[uint32]struct{})
|
||||
for _, idx := range writeIndices {
|
||||
for _, wKey := range writeKeys {
|
||||
idx := locks.spread(fnv32(wKey))
|
||||
writeIndexSet[idx] = struct{}{}
|
||||
}
|
||||
for _, index := range indices {
|
||||
@@ -151,9 +151,9 @@ func (locks *Locks) RWLocks(writeKeys []string, readKeys []string) {
|
||||
func (locks *Locks) RWUnLocks(writeKeys []string, readKeys []string) {
|
||||
keys := append(writeKeys, readKeys...)
|
||||
indices := locks.toLockIndices(keys, true)
|
||||
writeIndices := locks.toLockIndices(writeKeys, true)
|
||||
writeIndexSet := make(map[uint32]struct{})
|
||||
for _, idx := range writeIndices {
|
||||
for _, wKey := range writeKeys {
|
||||
idx := locks.spread(fnv32(wKey))
|
||||
writeIndexSet[idx] = struct{}{}
|
||||
}
|
||||
for _, index := range indices {
|
||||
|
Reference in New Issue
Block a user