-
Notifications
You must be signed in to change notification settings - Fork 72
fix: silent precendence #455
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
Conversation
78d1775
to
ec33e9f
Compare
ec33e9f
to
05b91b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great rewrite of shouldBeSame
👍
src/ast.js
Outdated
buffer = result.what; | ||
result.what = result.what.left; | ||
this.swapLocations(result, result, result.what, parser); | ||
const subject = result.kind === "cast" ? "what" : "expr"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be great to rename what
property to expr
on cast
nodes, that way would be more consistent grammatically speaking - the next release will be stable so it's the last chance to introduce breaking changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping you'd suggest that 😉 done!
src/ast.js
Outdated
(result.kind === "silent" && | ||
result.expr && | ||
!result.expr.parenthesizedExpression) | ||
["silent", "cast"].includes(result.kind) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I'm a bit maniac, could you rewrite the condition to be more optimized as this function is runned over all nodes it may impact a bit :
(result.kind == 'silent' || result.kind == 'cast') && ...
NB : The property check costs less than a function call and a lookup because you have only 2 entries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! Might be a good idea to add performance testing in the future 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it has something similar :
PASS test/perf.test.js
● Console
console.log test/perf.test.js:42
+ Tokens speed => 205.15K/sec
console.log test/perf.test.js:56
+ Reading speed => 437.1K/sec
console.log test/perf.test.js:101
+ Nodes speed => 79.69K/sec
console.log test/perf.test.js:115
+ Overall speed => 211.43K/sec
It's not kilobytes but thousands of tokens or nodes dependending on what is tested.
The problem is that depends on the CPU & RAM frequency (disk does not enter into account) so you can't really know automatically it you break/degrade something - any idea is welcome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I have no experience with performance testing myself, but I saw that in prettier/prettier
something similar is done based on Benchmark.js.
25951da
to
d46ad9c
Compare
d46ad9c
to
f03c3e7
Compare
@ichiriac What do you think, is this ready to be merged? 🚀 |
Change
silent
to be handled exactly the same way ascast
is handled. Also refactorshouldBeSame
for better error reporting.Fixes #195
Fixes #355