@@ -136,13 +136,19 @@ func (m *memoryStore) list(prefix string, limit, offset uint) []string {
|
||||
|
||||
if limit != 0 || offset != 0 {
|
||||
sort.Slice(allKeys, func(i, j int) bool { return allKeys[i] < allKeys[j] })
|
||||
min := func(i, j uint) uint {
|
||||
if i < j {
|
||||
return i
|
||||
sort.Slice(allKeys, func(i, j int) bool { return allKeys[i] < allKeys[j] })
|
||||
end := len(allKeys)
|
||||
if limit > 0 {
|
||||
calcLimit := int(offset + limit)
|
||||
if calcLimit < end {
|
||||
end = calcLimit
|
||||
}
|
||||
return j
|
||||
}
|
||||
return allKeys[offset:min(limit, uint(len(allKeys)))]
|
||||
|
||||
if int(offset) >= end {
|
||||
return nil
|
||||
}
|
||||
return allKeys[offset:end]
|
||||
}
|
||||
|
||||
return allKeys
|
||||
|
Reference in New Issue
Block a user