-
Notifications
You must be signed in to change notification settings - Fork 51
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
hrp: small improvement in hrp parsing #199
Conversation
Thanks for taking the time to patch |
It's not a static variable, it's a local variable -- so in theory the stack "allocation" (which is just incrementing a pointer) will happen later. In practice I definitely expect the compiler to do this for us. But it's still good practice to do early checks first before making any "allocations", and this will protect us in case we later refactor the |
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.
ACK 3322ca4 successfully ran local tests
Excluding the obvious face palm static vs local. Turns out the thing I was trying to say was this patch doesn't change the stack frame (https://stackoverflow.com/questions/68023230/whats-the-difference-between-stack-pointer-and-frame-pointer-in-assembly-arm) Anyhow, my point was this is mostly a stylistic change, I was wondering if there was any other benefit I was missing? ACK 3322ca4 |
@tcharding in the context of a modern compiler it's purely stylistic. But as your SE link describes, in a naive compilation of the existing code, the stack pointer is moved before doing these checks (and then if they fail it's immediately moved back). While the changed code avoids moving it. The frame pointer, if it exists at all, behaves the same way in both cases. |
Ah nice, thanks. |
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.
ACK 3322ca4
In the HRP parsing function, we first test the following conditions with potential error outputs:
So we don't need to directly declare the
new
variable in case an error is thrown and this declaration becoming useless. We can wait for the checks to be ok before declaring this (very small improvement).