Skip to content

Commit

Permalink
Modified unnecessary type conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
gou-jjjj committed Jan 17, 2024
1 parent f0297a5 commit 0acef62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion datastruct/lock/lock_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (locks *Locks) spread(hashCode uint32) uint32 {
panic("dict is nil")
}
tableSize := uint32(len(locks.table))
return (tableSize - 1) & uint32(hashCode)
return (tableSize - 1) & hashCode
}

// Lock obtains exclusive lock for writing
Expand Down
6 changes: 3 additions & 3 deletions datastruct/sortedset/sortedset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 {
panic("illegal start " + strconv.FormatInt(start, 10))
}
Expand All @@ -91,12 +91,12 @@ func (sortedSet *SortedSet) ForEachByRank(start int64, stop int64, desc bool, co
if desc {
node = sortedSet.skiplist.tail
if start > 0 {
node = sortedSet.skiplist.getByRank(int64(size - start))
node = sortedSet.skiplist.getByRank(size - start)
}
} else {
node = sortedSet.skiplist.header.level[0].forward
if start > 0 {
node = sortedSet.skiplist.getByRank(int64(start + 1))
node = sortedSet.skiplist.getByRank(start + 1)
}
}

Expand Down

0 comments on commit 0acef62

Please sign in to comment.