| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Review requested:
|
Sorry, something went wrong.
|
Why? I won't block, but this is a cosmetic change that does not add any value in my opinion. It only adds noise to git blame. |
Sorry, something went wrong.
|
IIRC optional chaining is slightly faster. Quick and dirty JSBench shows a ~0.3-1% improvement in ops/sec: https://jsben.ch/znvKH |
Sorry, something went wrong.
|
The performance is the same: const Benchmark = require('benchmark');
const suite = new Benchmark.Suite();
const testBad = {};
suite.add('Optional chaining', function () {
let wow;
if (testBad?.id === '123') {
wow = 'ok';
}
return wow;
});
suite.add('Without optional chaining', function () {
let wow;
if (testBad && testBad.id && testBad.id === '123') {
wow = 'ok';
}
return wow;
});
suite.on('cycle', function (event) {
console.log(event.target.toString());
});
suite.on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').map('name'));
});
suite.run({ async: true });$ node index.js Optional chaining x 103,663,582 ops/sec ±6.25% (75 runs sampled) Without optional chaining x 106,320,156 ops/sec ±5.14% (76 runs sampled) Fastest is Without optional chaining,Optional chaining |
Sorry, something went wrong.
|
ahh interesting. In that case, then yes, this is purely cosmetic, but I still think that using optional chaining is more concise and readable than without, but if it adds too much noise, it's not a needed change, however I'd love to see some other opinions. |
Sorry, something went wrong.
There was a problem hiding this comment.
I won't block but i'd say this ought to be accompanied by a linter enforcement. And that's when this will be debated ;)
Sorry, something went wrong.
Codecov ReportAttention: Patch coverage is 93.33333% with 5 lines in your changes missing coverage. Please review.
@@ Coverage Diff @@
## main #55045 +/- ##
=======================================
Coverage 88.23% 88.24%
=======================================
Files 652 652
Lines 183855 183896 +41
Branches 35856 35856
=======================================
+ Hits 162227 162274 +47
+ Misses 14909 14908 -1
+ Partials 6719 6714 -5
|
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm
Sorry, something went wrong.
Sorry, something went wrong.
|
Going forward, has the project's stance on cosmetic changes changed? We've rejected dozens of patches like this in the past. I think that approving some while rejecting others is disrespectful to contributors who have theirs rejected. |
Sorry, something went wrong.
|
@anonrig I added a prefer-optional-chaining lint rule. Are you still blocking? |
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm
Sorry, something went wrong.
Sorry, something went wrong.
|
@anonrig Would you mind re-reviewing or dismissing the request changes, as your concerns were addressed? |
Sorry, something went wrong.
PR-URL: #55045 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
| Back | FazBrowse Home | New Git URL |
No description provided.