Skip to content

Commit c4d55d2

Browse files
committed
use chained flatMap instead of nested
1 parent f5dbe13 commit c4d55d2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/extract.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,10 @@ export function extractGoResult(output: string): BenchmarkResult[] {
366366
const reExtractRegexp =
367367
/^(?<name>Benchmark\w+[\w()$%^&*-=|,[\]{}"#]*?)(?<procs>-\d+)?\s+(?<times>\d+)\s+(?<remainder>.+)$/;
368368

369-
// Process each section and flatten results
370-
return sections.flatMap(({ pkg, lines }) =>
371-
lines.flatMap((line) => {
369+
// Flatten sections into lines with package context, then process each line
370+
return sections
371+
.flatMap(({ pkg, lines }) => lines.map((line) => ({ pkg, line })))
372+
.flatMap(({ pkg, line }) => {
372373
const match = line.match(reExtractRegexp);
373374
if (!match?.groups) return [];
374375

@@ -392,8 +393,7 @@ export function extractGoResult(output: string): BenchmarkResult[] {
392393
unit,
393394
extra,
394395
}));
395-
}),
396-
);
396+
});
397397
}
398398

399399
function chunkPairs(arr: string[]): Array<[string, string]> {

0 commit comments

Comments
 (0)