Skip to content

Commit

Permalink
neotest: preallocate coverage blocks list
Browse files Browse the repository at this point in the history
And always use pointers for coverage block processing, dereference is
excessive in this context.

Signed-off-by: Anna Shaleva <[email protected]>
  • Loading branch information
AnnaShaleva committed Oct 15, 2024
1 parent 49f2e1d commit c747bb8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/neotest/coverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ func writeCoverageReport(w io.Writer) {
}
}

func processCover() map[documentName][]coverBlock {
func processCover() map[documentName][]*coverBlock {
documents := make(map[documentName]struct{})
for _, scriptRawCoverage := range rawCoverage {
for _, documentName := range scriptRawCoverage.debugInfo.Documents {
documents[documentName] = struct{}{}
}
}

cover := make(map[documentName][]coverBlock)
cover := make(map[documentName][]*coverBlock)

for documentName := range documents {
mappedBlocks := make(map[int]*coverBlock)
Expand Down Expand Up @@ -197,9 +197,9 @@ func processCover() map[documentName][]coverBlock {
}
}

var blocks []coverBlock
var blocks = make([]*coverBlock, 0, len(mappedBlocks))
for _, b := range mappedBlocks {
blocks = append(blocks, *b)
blocks = append(blocks, b)
}
cover[documentName] = blocks
}
Expand Down

0 comments on commit c747bb8

Please sign in to comment.