Modify unnecessary type conversions

This commit is contained in:
GouJie
2024-01-17 14:09:58 +08:00
committed by finley
parent e4c9563776
commit b63deb62bd
2 changed files with 4 additions and 4 deletions

View File

@@ -39,7 +39,7 @@ func (locks *Locks) spread(hashCode uint32) uint32 {
panic("dict is nil") panic("dict is nil")
} }
tableSize := uint32(len(locks.table)) tableSize := uint32(len(locks.table))
return (tableSize - 1) & uint32(hashCode) return (tableSize - 1) & hashCode
} }
// Lock obtains exclusive lock for writing // Lock obtains exclusive lock for writing

View File

@@ -78,7 +78,7 @@ func (sortedSet *SortedSet) GetRank(member string, desc bool) (rank int64) {
// ForEachByRank visits each member which rank within [start, stop), sort by ascending order, rank starts from 0 // ForEachByRank visits each member which rank within [start, stop), sort by ascending order, rank starts from 0
func (sortedSet *SortedSet) ForEachByRank(start int64, stop int64, desc bool, consumer func(element *Element) bool) { func (sortedSet *SortedSet) ForEachByRank(start int64, stop int64, desc bool, consumer func(element *Element) bool) {
size := int64(sortedSet.Len()) size := sortedSet.Len()
if start < 0 || start >= size { if start < 0 || start >= size {
panic("illegal start " + strconv.FormatInt(start, 10)) panic("illegal start " + strconv.FormatInt(start, 10))
} }
@@ -91,12 +91,12 @@ func (sortedSet *SortedSet) ForEachByRank(start int64, stop int64, desc bool, co
if desc { if desc {
node = sortedSet.skiplist.tail node = sortedSet.skiplist.tail
if start > 0 { if start > 0 {
node = sortedSet.skiplist.getByRank(int64(size - start)) node = sortedSet.skiplist.getByRank(size - start)
} }
} else { } else {
node = sortedSet.skiplist.header.level[0].forward node = sortedSet.skiplist.header.level[0].forward
if start > 0 { if start > 0 {
node = sortedSet.skiplist.getByRank(int64(start + 1)) node = sortedSet.skiplist.getByRank(start + 1)
} }
} }