Use __traits(isSame) for min,maxElement#6144
Merged
dlang-bot merged 2 commits intodlang:masterfrom Mar 16, 2018
Merged
Conversation
Contributor
|
Thanks for your pull request, @wilzbach! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
n8sh
reviewed
Feb 11, 2018
| { | ||
| foreach (const i; 0 .. r.length) | ||
|
|
||
| // direct access via a random access range is faster |
Member
There was a problem hiding this comment.
Is this really true? Looping over an index is faster than repeated empty/front/popFront()?
Contributor
Author
There was a problem hiding this comment.
Yes, D ranges have an overhead of ~20-50% for arrays. It's pretty bad for e.g. joiner (see https://gist.github.com/wilzbach/ffd5d20639766a831fd4b1962572897a), but it's a problem here too.
Check also #4265
The reason is that the compiler can inline the commands a lot better for native arrays and even do vectorization better than for the generic loop.
JackStouffer
approved these changes
Mar 16, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
__traits(isSame, a, b)rocks :)The specialization was discussed in #4265 and merged in #5001.
Use https://github.com/dlang/phobos/pull/6144/files?w=1 for a nicer diff.