Skip to content

Commit

Permalink
refactor: Directly swap variable values (#1970)
Browse files Browse the repository at this point in the history
Signed-off-by: cuishuang <[email protected]>
  • Loading branch information
cuishuang authored Sep 29, 2024
1 parent 875aba8 commit 5936bd1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
4 changes: 1 addition & 3 deletions api/handler/eventLog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions api/model/tenantResourceModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions eventlog/store/new_monitor_message_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5936bd1

Please sign in to comment.