perf: use build-in min/max function instead
This commit is contained in:
parent
8bb64449ce
commit
3c8221f43f
|
@ -12,7 +12,6 @@ import (
|
|||
. "tinyrdm/backend/storage"
|
||||
"tinyrdm/backend/types"
|
||||
maputil "tinyrdm/backend/utils/map"
|
||||
mathutil "tinyrdm/backend/utils/math"
|
||||
redis2 "tinyrdm/backend/utils/redis"
|
||||
)
|
||||
|
||||
|
@ -1049,7 +1048,7 @@ func (c *connectionService) GetCmdHistory(pageNo, pageSize int) (resp types.JSRe
|
|||
} else {
|
||||
total := len(c.cmdHistory)
|
||||
startIndex := total / pageSize * (pageNo - 1)
|
||||
endIndex := mathutil.Min(startIndex+pageSize, total)
|
||||
endIndex := min(startIndex+pageSize, total)
|
||||
resp.Data = map[string]any{
|
||||
"list": c.cmdHistory[startIndex:endIndex],
|
||||
"pageNo": pageNo,
|
||||
|
|
|
@ -20,11 +20,6 @@ func MaxWithIndex[T Hashable](items ...T) (T, int) {
|
|||
return items[selIndex], selIndex
|
||||
}
|
||||
|
||||
func Max[T Hashable](items ...T) T {
|
||||
val, _ := MaxWithIndex(items...)
|
||||
return val
|
||||
}
|
||||
|
||||
// MinWithIndex 查找所有元素中的最小值
|
||||
func MinWithIndex[T Hashable](items ...T) (T, int) {
|
||||
selIndex := -1
|
||||
|
@ -40,11 +35,6 @@ func MinWithIndex[T Hashable](items ...T) (T, int) {
|
|||
return items[selIndex], selIndex
|
||||
}
|
||||
|
||||
func Min[T Hashable](items ...T) T {
|
||||
val, _ := MinWithIndex(items...)
|
||||
return val
|
||||
}
|
||||
|
||||
// Clamp 返回限制在minVal和maxVal范围内的value
|
||||
func Clamp[T Hashable](value T, minVal T, maxVal T) T {
|
||||
if minVal > maxVal {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue'
|
||||
import { ref, watch, nextTick } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import useDialog from 'stores/dialog'
|
||||
import usePreferencesStore from 'stores/preferences.js'
|
||||
|
@ -34,7 +34,7 @@ watch(
|
|||
() => dialogStore.preferencesDialogVisible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
nextTick().then(async () => initPreferences())
|
||||
nextTick().then(initPreferences)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue