From 35240cab0581cf5b96ed030279beefde7dcfea45 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 15 Jan 2019 10:04:34 -0800 Subject: [PATCH] test: refactor min() in test-hash-seed Replace min() function with Math.min(...). PR-URL: https://github.com/nodejs/node/pull/25522 Reviewed-By: Ali Ijaz Sheikh Reviewed-By: Luigi Pinca Reviewed-By: Refael Ackermann Reviewed-By: Richard Lau Reviewed-By: Minwoo Jung --- test/fixtures/guess-hash-seed.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/test/fixtures/guess-hash-seed.js b/test/fixtures/guess-hash-seed.js index ffcfd75aac54a3..8d69cf92490d20 100644 --- a/test/fixtures/guess-hash-seed.js +++ b/test/fixtures/guess-hash-seed.js @@ -1,13 +1,4 @@ 'use strict'; -function min(arr) { - let res = arr[0]; - for (let i = 1; i < arr.length; i++) { - const val = arr[i]; - if (val < res) - res = val; - } - return res; -} function run_repeated(n, fn) { const res = []; for (let i = 0; i < n; i++) res.push(fn()); @@ -118,11 +109,11 @@ let tester_set_treshold; // calibrate Set access times for accessing the full bucket / an empty bucket const pos_time = - min(run_repeated(10000, time_set_lookup.bind(null, tester_set, - positive_test_value))); + Math.min(...run_repeated(10000, time_set_lookup.bind(null, tester_set, + positive_test_value))); const neg_time = - min(run_repeated(10000, time_set_lookup.bind(null, tester_set, - negative_test_value))); + Math.min(...run_repeated(10000, time_set_lookup.bind(null, tester_set, + negative_test_value))); tester_set_treshold = (pos_time + neg_time) / 2; // console.log(`pos_time: ${pos_time}, neg_time: ${neg_time},`, // `threshold: ${tester_set_treshold}`);