Skip to content

Commit 32c87ac

Browse files
vsemozhetbytaddaleax
authored andcommitted
benchmark: fix some RegExp nits
* Take RegExp creation out of cycle. * use test(), not match() in boolean context. PR-URL: #13551 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 70432f2 commit 32c87ac

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

benchmark/buffers/buffer-write.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function main(conf) {
5252
var buff = new clazz(8);
5353
var fn = `write${conf.type}`;
5454

55-
if (fn.match(/Int/))
55+
if (/Int/.test(fn))
5656
benchInt(buff, fn, len, noAssert);
5757
else
5858
benchFloat(buff, fn, len, noAssert);

benchmark/common.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ function Benchmark(fn, configs, options) {
4040
Benchmark.prototype._parseArgs = function(argv, configs) {
4141
const cliOptions = {};
4242
const extraOptions = {};
43+
const validArgRE = /^(.+?)=([\s\S]*)$/;
4344
// Parse configuration arguments
4445
for (const arg of argv) {
45-
const match = arg.match(/^(.+?)=([\s\S]*)$/);
46+
const match = arg.match(validArgRE);
4647
if (!match) {
4748
console.error(`bad argument: ${arg}`);
4849
process.exit(1);

benchmark/crypto/cipher-stream.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var bench = common.createBenchmark(main, {
1111

1212
function main(conf) {
1313
var api = conf.api;
14-
if (api === 'stream' && process.version.match(/^v0\.[0-8]\./)) {
14+
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
1515
console.error('Crypto streams not available until v0.10');
1616
// use the legacy, just so that we can compare them.
1717
api = 'legacy';

benchmark/crypto/hash-stream-creation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var bench = common.createBenchmark(main, {
1515

1616
function main(conf) {
1717
var api = conf.api;
18-
if (api === 'stream' && process.version.match(/^v0\.[0-8]\./)) {
18+
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
1919
console.error('Crypto streams not available until v0.10');
2020
// use the legacy, just so that we can compare them.
2121
api = 'legacy';

benchmark/crypto/hash-stream-throughput.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var bench = common.createBenchmark(main, {
1414

1515
function main(conf) {
1616
var api = conf.api;
17-
if (api === 'stream' && process.version.match(/^v0\.[0-8]\./)) {
17+
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
1818
console.error('Crypto streams not available until v0.10');
1919
// use the legacy, just so that we can compare them.
2020
api = 'legacy';

0 commit comments

Comments
 (0)