-
Notifications
You must be signed in to change notification settings - Fork 85
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
Closure killer iterate segment lanes #1162
Conversation
…sed enumerator that returns LaneId and LaneIndex.
…rect foreach and as a base line for further improvement.
# Conflicts: # TLM/TLM/State/Flags.cs # TLM/TLM/Traffic/Impl/SegmentEnd.cs Also did a rename from LaneIdAndLaneIndex to LaneIdAndIndex.
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.
Looks good
is this code used in performance critical part of the code? |
I think so. I'd have to double check since I made the changes some time ago. |
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
|
||
[Benchmark] | ||
public void Foreach_Direct() { | ||
foreach (var item in new GetSegmentLaneIdsEnumerable(0, testLanes.Length, testLanes)) { |
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.
Does that by any reason get optimized out? Or you benchmark in debug mode?
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.
what do you mean?
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.
Empty loop body could be optimized out? Not sure how C# compiler handles empty loops
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.
Foreach won't be optimized because it may have side effects
Killed IterateSegmentLanes with struct enumerators to simplify code and remove heap allocations.