Skip to content

Commit 05e2f2b

Browse files
committed
spanset: pass slice into mergeSpans by value
Epic: none Release note: none
1 parent d1137f9 commit 05e2f2b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pkg/kv/kvserver/spanset/merge.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import "slices"
1313
//
1414
// Returns true iff all of the spans are distinct.
1515
// The input spans are not safe for re-use.
16-
func mergeSpans(latches *[]Span) ([]Span, bool) {
17-
if len(*latches) == 0 {
18-
return *latches, true
16+
func mergeSpans(latches []Span) ([]Span, bool) {
17+
if len(latches) == 0 {
18+
return latches, true
1919
}
2020

2121
// Sort first on the start key and second on the end key. Note that we're
2222
// relying on empty EndKey sorting before other EndKeys.
23-
slices.SortFunc(*latches, func(s1, s2 Span) int {
23+
slices.SortFunc(latches, func(s1, s2 Span) int {
2424
if c := s1.Key.Compare(s2.Key); c != 0 {
2525
return c
2626
}
@@ -30,10 +30,10 @@ func mergeSpans(latches *[]Span) ([]Span, bool) {
3030
// We build up the resulting slice of merged spans in place. This is safe
3131
// because "r" grows by at most 1 element on each iteration, staying abreast
3232
// or behind the iteration over "latches".
33-
r := (*latches)[:1]
33+
r := latches[:1]
3434
distinct := true
3535

36-
for _, cur := range (*latches)[1:] {
36+
for _, cur := range latches[1:] {
3737
prev := &r[len(r)-1]
3838
if len(cur.EndKey) == 0 && len(prev.EndKey) == 0 {
3939
if cur.Key.Compare(prev.Key) != 0 {

pkg/kv/kvserver/spanset/spanset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func (s *SpanSet) Merge(s2 *SpanSet) {
216216
func (s *SpanSet) SortAndDedup() {
217217
for sa := SpanAccess(0); sa < NumSpanAccess; sa++ {
218218
for ss := SpanScope(0); ss < NumSpanScope; ss++ {
219-
s.spans[sa][ss], _ /* distinct */ = mergeSpans(&s.spans[sa][ss])
219+
s.spans[sa][ss], _ /* distinct */ = mergeSpans(s.spans[sa][ss])
220220
}
221221
}
222222
}

0 commit comments

Comments
 (0)