From 37f9df003b5d021a4956df3ae8431fd6a0c40c69 Mon Sep 17 00:00:00 2001 From: Christopher Monsanto Date: Fri, 1 May 2020 07:53:00 -0400 Subject: [PATCH] Optimize tools/deflopt slightly --- tools/deflopt/deflopt.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/deflopt/deflopt.js b/tools/deflopt/deflopt.js index bd3d22e6..33388736 100644 --- a/tools/deflopt/deflopt.js +++ b/tools/deflopt/deflopt.js @@ -16,8 +16,11 @@ Number of files rewritten : 0 Total number of bytes saved: 0 2,097,357 cycles. */ -function parse(statusLine, output) { - const re = new RegExp(statusLine + " *: *([0-9]+)"); + +const PROCESSED_RE = /Number of files processed : *([0-9]+)/; +const REWRITTEN_RE = /Number of files rewritten : *([0-9]+)/; + +function parse(re, output) { const m = output.match(re); if (!m) { throw new Error(`Can't match output: ` + output); @@ -38,7 +41,7 @@ export function deflopt(exe, file) { // Wine doesn't even like it when the current directory is on fuse! // What a persnickety program! cwd: '/'}); - const processed = parse("Number of files processed", output); - const rewritten = parse("Number of files rewritten", output); + const processed = parse(PROCESSED_RE, output); + const rewritten = parse(REWRITTEN_RE, output); return {processed, rewritten}; }