fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

build: use slices.Insert instead of several appends (#681)

I found the code a bit hard to read before, this I believe is more
clear. I was also hoping for an improvement in the benchmarks, but the
improvement was statistically insignificant.

Test Plan: go test

+12 -11
+12 -11
build/ctags.go
··· 22 22 "sync" 23 23 "time" 24 24 25 + "golang.org/x/exp/slices" 26 + 25 27 "github.com/sourcegraph/zoekt" 26 28 "github.com/sourcegraph/zoekt/ctags" 27 29 ) ··· 151 153 continue 152 154 } 153 155 154 - symOffsets = append( 155 - symOffsets[:i], 156 - append([]zoekt.DocumentSection{{Start: start, End: endSym}}, symOffsets[i:]...)..., 157 - ) 158 - symMetaData = append( 159 - symMetaData[:i], 160 - append( 161 - []*zoekt.Symbol{{Sym: t.Name, Kind: t.Kind, Parent: t.Parent, ParentKind: t.ParentKind}}, 162 - symMetaData[i:]..., 163 - )..., 164 - ) 156 + symOffsets = slices.Insert(symOffsets, i, zoekt.DocumentSection{ 157 + Start: start, 158 + End: endSym, 159 + }) 160 + symMetaData = slices.Insert(symMetaData, i, &zoekt.Symbol{ 161 + Sym: t.Name, 162 + Kind: t.Kind, 163 + Parent: t.Parent, 164 + ParentKind: t.ParentKind, 165 + }) 165 166 } 166 167 167 168 return symOffsets, symMetaData, nil