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

chore: remove unnecessary eslint override #5493

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

Cangit
Copy link
Contributor

@Cangit Cangit commented Jun 1, 2024

in decorate.js

Checklist

Copy link
Member

@gurgunday gurgunday left a comment

Choose a reason for hiding this comment

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

Btw I no longer measure a difference between var and let, but don’t see why that change was combined with this PR

@Cangit
Copy link
Contributor Author

Cangit commented Jun 1, 2024

Sorry, should have made that change more clear. But yes, var should be unnecessary, and that in turn makes the eslint-disable-next-line no-var unnecessary.

Copy link
Member

@gurgunday gurgunday left a comment

Choose a reason for hiding this comment

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

If anyone wants to bench it:

function benchmarkVarLoop(iterations) {
  let sum = 0;
  const startTime = performance.now();
  for (var i = 0; i < iterations; i++) {
    sum += i;
  }
  const endTime = performance.now();
  return endTime - startTime;
}

function benchmarkLetLoop(iterations) {
  let sum = 0;
  const startTime = performance.now();
  for (let i = 0; i < iterations; i++) {
    sum += i;
  }
  const endTime = performance.now();
  return endTime - startTime;
}

function runBenchmarks() {
  const iterations = 1000000;

  const varDuration = benchmarkVarLoop(iterations);
  console.log(`var loop duration: ${varDuration} ms`);

  const letDuration = benchmarkLetLoop(iterations);
  console.log(`let loop duration: ${letDuration} ms`);

  if (varDuration < letDuration) {
    console.log("var is faster than let in this benchmark.");
  } else if (varDuration > letDuration) {
    console.log("let is faster than var in this benchmark.");
  } else {
    console.log("var and let have the same performance in this benchmark.");
  }
}

runBenchmarks();

@gurgunday gurgunday merged commit a00f3ca into fastify:main Jun 2, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants