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

Configure Feed

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

eval: refactor branchMask (#565)

tiny refactor to make the code more succint. Based on a comment in #562.

Co-authored-by: Keegan Carruthers-Smith <keegan.csmith@gmail.com>

+5 -8
+3 -6
eval.go
··· 568 568 // branches containing the docID and matching the branch filter. Otherwise, it 569 569 // returns all branches containing docID. 570 570 func (d *indexData) gatherBranches(docID uint32, mt matchTree, known map[matchTree]bool) []string { 571 - repoIdx := d.repos[docID] 572 - 573 571 var mask uint64 574 572 visitMatches(mt, known, func(mt matchTree) { 575 573 bq, ok := mt.(*branchQueryMatchTree) ··· 577 575 return 578 576 } 579 577 580 - // bq.masks[repoIdx]: the branches we are filtering on 581 - // bq.branchMask(): the branches of the current file 582 - mask = mask | (bq.masks[repoIdx] & bq.branchMask()) 578 + mask = mask | bq.branchMask() 583 579 }) 584 580 585 581 if mask == 0 { ··· 588 584 589 585 var branches []string 590 586 id := uint32(1) 587 + branchNames := d.branchNames[d.repos[docID]] 591 588 for mask != 0 { 592 589 if mask&0x1 != 0 { 593 - branches = append(branches, d.branchNames[repoIdx][uint(id)]) 590 + branches = append(branches, branchNames[uint(id)]) 594 591 } 595 592 id <<= 1 596 593 mask >>= 1
+2 -2
matchtree.go
··· 182 182 } 183 183 184 184 func (t *branchQueryMatchTree) branchMask() uint64 { 185 - return t.fileMasks[t.docID] 185 + return t.fileMasks[t.docID] & t.masks[t.repos[t.docID]] 186 186 } 187 187 188 188 type symbolRegexpMatchTree struct { ··· 676 676 } 677 677 678 678 func (t *branchQueryMatchTree) matches(cp *contentProvider, cost int, known map[matchTree]bool) (bool, bool) { 679 - return t.branchMask()&t.masks[t.repos[t.docID]] != 0, true 679 + return t.branchMask() != 0, true 680 680 } 681 681 682 682 func (t *regexpMatchTree) matches(cp *contentProvider, cost int, known map[matchTree]bool) (bool, bool) {