refactor: Directly swap variable values (#1970)

Signed-off-by: cuishuang <imcusg@gmail.com>
This commit is contained in:
cui fliter 2024-09-29 09:26:27 +08:00 committed by GitHub
parent 875aba849e
commit 5936bd1a83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 9 deletions

View File

@ -193,9 +193,7 @@ func bubSort(d []api_model.MessageData) []api_model.MessageData {
for i := 0; i < len(d); i++ {
for j := i + 1; j < len(d); j++ {
if d[i].Unixtime > d[j].Unixtime {
temp := d[i]
d[i] = d[j]
d[j] = temp
d[i], d[j] = d[j], d[i]
}
}
}

View File

@ -62,9 +62,7 @@ func (list TenantResList) Less(i, j int) bool {
}
func (list TenantResList) Swap(i, j int) {
temp := list[i]
list[i] = list[j]
list[j] = temp
list[i], list[j] = list[j], list[i]
}
//TenantAndResource tenant and resource strcut

View File

@ -367,9 +367,7 @@ func (m *MonitorMessageList) Less(i, j int) bool {
// Swap 交换索引为 i 和 j 的元素
func (m *MonitorMessageList) Swap(i, j int) {
tmp := (*m)[i]
(*m)[i] = (*m)[j]
(*m)[j] = tmp
(*m)[i], (*m)[j] = (*m)[j], (*m)[i]
}
//Pop Pop