Skip to content

Commit

Permalink
benchmark: use let instead of var in url
Browse files Browse the repository at this point in the history
PR-URL: #31794
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
dnlup authored and addaleax committed Mar 30, 2020
1 parent 108e91f commit 148df0a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions benchmark/url/legacy-vs-whatwg-url-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {

function useLegacy(data) {
const len = data.length;
var result = url.parse(data[0]); // Avoid dead code elimination
let result = url.parse(data[0]); // Avoid dead code elimination
bench.start();
for (let i = 0; i < len; ++i) {
result = url.parse(data[i]);
Expand All @@ -24,7 +24,7 @@ function useLegacy(data) {

function useWHATWGWithBase(data) {
const len = data.length;
var result = new URL(data[0][0], data[0][1]); // Avoid dead code elimination
let result = new URL(data[0][0], data[0][1]); // Avoid dead code elimination
bench.start();
for (let i = 0; i < len; ++i) {
const item = data[i];
Expand All @@ -36,7 +36,7 @@ function useWHATWGWithBase(data) {

function useWHATWGWithoutBase(data) {
const len = data.length;
var result = new URL(data[0]); // Avoid dead code elimination
let result = new URL(data[0]); // Avoid dead code elimination
bench.start();
for (let i = 0; i < len; ++i) {
result = new URL(data[i]);
Expand All @@ -47,8 +47,8 @@ function useWHATWGWithoutBase(data) {

function main({ e, method, type, withBase }) {
withBase = withBase === 'true';
var noDead; // Avoid dead code elimination.
var data;
let noDead; // Avoid dead code elimination.
let data;
switch (method) {
case 'legacy':
data = common.bakeUrlData(type, e, false, false);
Expand Down
6 changes: 3 additions & 3 deletions benchmark/url/legacy-vs-whatwg-url-serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
function useLegacy(data) {
const obj = url.parse(data[0]);
const len = data.length;
var noDead = url.format(obj);
let noDead = url.format(obj);
bench.start();
for (let i = 0; i < len; i++) {
noDead = data[i].toString();
Expand All @@ -25,7 +25,7 @@ function useLegacy(data) {
function useWHATWG(data) {
const obj = new URL(data[0]);
const len = data.length;
var noDead = obj.toString();
let noDead = obj.toString();
bench.start();
for (let i = 0; i < len; i++) {
noDead = data[i].toString();
Expand All @@ -37,7 +37,7 @@ function useWHATWG(data) {
function main({ type, e, method }) {
const data = common.bakeUrlData(type, e, false, false);

var noDead; // Avoid dead code elimination.
let noDead; // Avoid dead code elimination.
switch (method) {
case 'legacy':
noDead = useLegacy(data);
Expand Down
4 changes: 2 additions & 2 deletions benchmark/url/whatwg-url-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const bench = common.createBenchmark(main, {

function setAndGet(data, prop) {
const len = data.length;
var result = data[0][prop];
let result = data[0][prop];
bench.start();
for (let i = 0; i < len; ++i) {
result = data[i][prop];
Expand All @@ -24,7 +24,7 @@ function setAndGet(data, prop) {

function get(data, prop) {
const len = data.length;
var result = data[0][prop];
let result = data[0][prop];
bench.start();
for (let i = 0; i < len; ++i) {
result = data[i][prop]; // get
Expand Down

0 comments on commit 148df0a

Please sign in to comment.