mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-21 22:36:39 +00:00
More efficient slice-insert - less copying, less garbage
This commit is contained in:
@@ -26,7 +26,9 @@ func (a IDList) Add(ids ...string) IDList {
|
||||
continue
|
||||
}
|
||||
// It a new element, insert it in order.
|
||||
a = append(a[:i], append(IDList{s}, a[i:]...)...)
|
||||
a = append(a, "")
|
||||
copy(a[i+1:], a[i:])
|
||||
a[i] = s
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user