From 6f7f8257bc29be548df0556eae2ca3109af9341c Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 23 Oct 2019 13:45:31 +0200 Subject: [PATCH] Slightly re-factor the String handling in `StatTimer` This uses template strings in a couple of spots, and a buffer in the `toString` method. --- src/display/display_utils.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/display/display_utils.js b/src/display/display_utils.js index d6f3ec385..86406eebd 100644 --- a/src/display/display_utils.js +++ b/src/display/display_utils.js @@ -387,14 +387,14 @@ class StatTimer { time(name) { if (name in this.started) { - warn('Timer is already running for ' + name); + warn(`Timer is already running for ${name}`); } this.started[name] = Date.now(); } timeEnd(name) { if (!(name in this.started)) { - warn('Timer has not been started for ' + name); + warn(`Timer has not been started for ${name}`); } this.times.push({ 'name': name, @@ -407,7 +407,7 @@ class StatTimer { toString() { // Find the longest name for padding purposes. - let out = '', longest = 0; + let outBuf = [], longest = 0; for (const time of this.times) { const name = time.name; if (name.length > longest) { @@ -416,9 +416,9 @@ class StatTimer { } for (const time of this.times) { const duration = time.end - time.start; - out += `${time.name.padEnd(longest)} ${duration}ms\n`; + outBuf.push(`${time.name.padEnd(longest)} ${duration}ms\n`); } - return out; + return outBuf.join(''); } }