neotest: preallocate coverage blocks list

And always use pointers for coverage block processing, dereference is
excessive in this context.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
Anna Shaleva 2024-10-15 15:18:45 +03:00
parent 49f2e1dc64
commit c747bb8ff7

View file

@ -154,7 +154,7 @@ func writeCoverageReport(w io.Writer) {
} }
} }
func processCover() map[documentName][]coverBlock { func processCover() map[documentName][]*coverBlock {
documents := make(map[documentName]struct{}) documents := make(map[documentName]struct{})
for _, scriptRawCoverage := range rawCoverage { for _, scriptRawCoverage := range rawCoverage {
for _, documentName := range scriptRawCoverage.debugInfo.Documents { for _, documentName := range scriptRawCoverage.debugInfo.Documents {
@ -162,7 +162,7 @@ func processCover() map[documentName][]coverBlock {
} }
} }
cover := make(map[documentName][]coverBlock) cover := make(map[documentName][]*coverBlock)
for documentName := range documents { for documentName := range documents {
mappedBlocks := make(map[int]*coverBlock) mappedBlocks := make(map[int]*coverBlock)
@ -197,9 +197,9 @@ func processCover() map[documentName][]coverBlock {
} }
} }
var blocks []coverBlock var blocks = make([]*coverBlock, 0, len(mappedBlocks))
for _, b := range mappedBlocks { for _, b := range mappedBlocks {
blocks = append(blocks, *b) blocks = append(blocks, b)
} }
cover[documentName] = blocks cover[documentName] = blocks
} }