-
Notifications
You must be signed in to change notification settings - Fork 235
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
Special case common sort
usages
#1255
Conversation
Tangential question... Regarding: (if (>= left right) (break)))
(if (< lo right)
(sort-help a lo right before?))
(if (< left hi)
(sort-help a left hi before?))) I've been wondering why In my own code I tend to use |
Below are the numbers I got on a Linux box. master (8df7364):
branch (cdd7083):
|
@sogaiu I am using |
Perhaps this is a bit like when one doesn't use braces in some spots in C when one can get away with it...increasing the chances of errors later if one forgets to make an appropriate modification when an additional line / form might need to be added? :) |
Right. I see |
Because it creates an unnecessary scoping. A micro-optimization at best, but measurable. "Don't prematurely over-optimize... but don't intentionally under-optimize either."
For my own projects, I always use braces, even for single statement bodies. When contributing to projects that are not my own, I try to match the given style as closely as possible. An |
I guess it would seem that the specific situation would matter. If measurements suggest it would help, that makes sense. Otherwise, it doesn't seem like a clear winner to me. Particularly in languages without source step debugging where the expectation appears to be to modify one's source when investigating things, I think I'd prefer to use So in the case of this PR, may be it makes sense based on measurements. |
Actually, I doesn't seem to make a difference anymore. Perhaps the recent compiler optimizations have made the point moot. We're free to use Regarding the frequent use in |
Ah, thanks for sharing this info. I guess what's tricky is that with folks like you optimizing things (thanks BTW!), it might be a never-ending game of figuring out what to write...oh, may be that's a feature? :) |
Just for reference Anyway, LGTM. |
<
,>
) to use vm ops directly.median-of-three
to use 2.667 comparisons on average, rather than 5. It's not as clever, but it is faster.The result is approximately 3x faster for these usages, and roughly unchanged for others.
master:
branch: