-
Notifications
You must be signed in to change notification settings - Fork 570
Remove unused variable in output #690
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
Hrm, one failure:
This passes fine on my local machine. Is this possibly related to #687? (Apologies if the answer should be obvious--I've not been following that issue at all, except reading headlines) |
Thanks for this PR, this is very interesting!
Yes, definitely looks related.
Can you elaborate on what will happen after the variable is no longer generated?
It would be nice to find the source commit where it's introduced, perhaps it'll help explain the original motivation. |
The line in question is constructed here. So by not adding |
It appears it was added in df432fe, where it was referenced in compiler/expressions.go, but then a few days later with 923aee9, that reference was removed, but the original declaration was left behind. |
Now that #687 is merged, I'm eager to rebase this PR and try CI again. |
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.
Thanks for providing the answers in the last 2 comments @flimzy, that's very helpful.
I've rebased and CI passed this time.
Based on the rationale provided, this change LGTM.
Thanks a lot for finding it, investigating it, and sending the PR!
TL;DR The
$ptr
variable in every output function appears never to be used, so this eliminates it. I expect it's an obsolete hold-over from some previous change.The story:
I noticed while playing with
uglifyjs
, a ton of warnings such as:Which piqued my curiosity, to see if GopherJS could possibly be made intelligent enough to eliminate this
$ptr
value from the output when it's not used.Looking at the output of one of my compiled projects, I saw many examples such as:
Some grepping further revealed that the only time we ever set the variable is in lines such as:
which is just restoring the function state after returning from a possibly-blocking function call.
I found no other use of this variable, so I removed it, and re-compiled me project, both with and without the
-m
flag, and got the following size reductions:$ptr
bytesMy project appears to run perfectly with the modification; I look forward to the CI test results as well.