Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark: fix some RegExp nits #13551

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmark/buffers/buffer-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion benchmark/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not validArgRE.test(arg)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some match[capture_index] processing below.

if (!match) {
console.error(`bad argument: ${arg}`);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/crypto/cipher-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion benchmark/crypto/hash-stream-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion benchmark/crypto/hash-stream-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down