benchmark: fix some RegExp nits
* Take RegExp creation out of cycle. * use test(), not match() in boolean context. PR-URL: https://github.com/nodejs/node/pull/13551 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
a2ed3a9c88
commit
8beff64851
@ -52,7 +52,7 @@ function main(conf) {
|
||||
var buff = new clazz(8);
|
||||
var fn = `write${conf.type}`;
|
||||
|
||||
if (fn.match(/Int/))
|
||||
if (/Int/.test(fn))
|
||||
benchInt(buff, fn, len, noAssert);
|
||||
else
|
||||
benchFloat(buff, fn, len, noAssert);
|
||||
|
@ -40,9 +40,10 @@ function Benchmark(fn, configs, options) {
|
||||
Benchmark.prototype._parseArgs = function(argv, configs) {
|
||||
const cliOptions = {};
|
||||
const extraOptions = {};
|
||||
const validArgRE = /^(.+?)=([\s\S]*)$/;
|
||||
// Parse configuration arguments
|
||||
for (const arg of argv) {
|
||||
const match = arg.match(/^(.+?)=([\s\S]*)$/);
|
||||
const match = arg.match(validArgRE);
|
||||
if (!match) {
|
||||
console.error(`bad argument: ${arg}`);
|
||||
process.exit(1);
|
||||
|
@ -11,7 +11,7 @@ var bench = common.createBenchmark(main, {
|
||||
|
||||
function main(conf) {
|
||||
var api = conf.api;
|
||||
if (api === 'stream' && process.version.match(/^v0\.[0-8]\./)) {
|
||||
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
|
||||
console.error('Crypto streams not available until v0.10');
|
||||
// use the legacy, just so that we can compare them.
|
||||
api = 'legacy';
|
||||
|
@ -15,7 +15,7 @@ var bench = common.createBenchmark(main, {
|
||||
|
||||
function main(conf) {
|
||||
var api = conf.api;
|
||||
if (api === 'stream' && process.version.match(/^v0\.[0-8]\./)) {
|
||||
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
|
||||
console.error('Crypto streams not available until v0.10');
|
||||
// use the legacy, just so that we can compare them.
|
||||
api = 'legacy';
|
||||
|
@ -14,7 +14,7 @@ var bench = common.createBenchmark(main, {
|
||||
|
||||
function main(conf) {
|
||||
var api = conf.api;
|
||||
if (api === 'stream' && process.version.match(/^v0\.[0-8]\./)) {
|
||||
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
|
||||
console.error('Crypto streams not available until v0.10');
|
||||
// use the legacy, just so that we can compare them.
|
||||
api = 'legacy';
|
||||
|
Loading…
x
Reference in New Issue
Block a user