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

Configure Feed

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

all: minor refactoring (#345)

An older refactoring moved toSizedDeltas and fromSizedDeltas from section.go to bits.go
but forgot to move the test. Cleaning this up here.

Also fixed a couple of typos, deleted stale comments etc.

author
mpimenov
committer
GitHub
date (May 19, 2022, 1:22 PM +0300) commit cdb50371 parent 92148cf9
+11 -32
+9
bits_test.go
··· 108 108 } 109 109 } 110 110 111 + func TestDeltas(t *testing.T) { 112 + in := []uint32{1, 72, 0xfff} 113 + out := toSizedDeltas(in) 114 + round := fromSizedDeltas(out, nil) 115 + if !reflect.DeepEqual(in, round) { 116 + t.Errorf("got %v, want %v", round, in) 117 + } 118 + } 119 + 111 120 func TestSizedDeltas(t *testing.T) { 112 121 encode := func(nums []uint32) []byte { 113 122 return toSizedDeltas(nums)
+1 -1
cmd/zoekt-sourcegraph-indexserver/merge.go
··· 163 163 // Exclude compound shards from being merge targets. Why? We want repositories in a 164 164 // compound shard to be ordered based on their priority. The easiest way to 165 165 // enforce this is to delete the compound shard once it drops below a certain 166 - // size (handeled by cleanup), reindex the repositories and merge them with other 166 + // size (handled by cleanup), reindex the repositories and merge them with other 167 167 // shards in the correct order. 168 168 if len(repos) > 1 { 169 169 return true
+1 -1
ngramoffset.go
··· 18 18 "sort" 19 19 ) 20 20 21 - // shrinkUint32Slice copies slices with excess capacity to precisely seized ones 21 + // shrinkUint32Slice copies slices with excess capacity to precisely sized ones 22 22 // to avoid wasting memory. It should be used on slices with long static durations. 23 23 func shrinkUint32Slice(a []uint32) []uint32 { 24 24 if cap(a)-len(a) < 32 {
-29
section_test.go
··· 1 - // Copyright 2016 Google Inc. All rights reserved. 2 - // 3 - // Licensed under the Apache License, Version 2.0 (the "License"); 4 - // you may not use this file except in compliance with the License. 5 - // You may obtain a copy of the License at 6 - // 7 - // http://www.apache.org/licenses/LICENSE-2.0 8 - // 9 - // Unless required by applicable law or agreed to in writing, software 10 - // distributed under the License is distributed on an "AS IS" BASIS, 11 - // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 - // See the License for the specific language governing permissions and 13 - // limitations under the License. 14 - 15 - package zoekt 16 - 17 - import ( 18 - "reflect" 19 - "testing" 20 - ) 21 - 22 - func TestDeltas(t *testing.T) { 23 - in := []uint32{1, 72, 0xfff} 24 - out := toSizedDeltas(in) 25 - round := fromSizedDeltas(out, nil) 26 - if !reflect.DeepEqual(in, round) { 27 - t.Errorf("got %v, want %v", round, in) 28 - } 29 - }
-1
stream/stream.go
··· 75 75 } 76 76 }() 77 77 78 - // mu protects aggStats and concurrent writes to the stream. 79 78 aggStats := zoekt.Stats{} 80 79 send := func(zsr *zoekt.SearchResult) { 81 80 err := eventWriter.event(eventMatches, zsr)