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

Avoid allocations when generating RadarSignatureCells. #14438

Merged
merged 1 commit into from Dec 11, 2017

Conversation

Projects
None yet
4 participants
@RoosterDragon
Member

RoosterDragon commented Nov 27, 2017

The RadarWidget can supply a reusable buffer to each trait to avoid individual traits having to return new enumerables. Additionally, this allows the two traits to avoid LINQ and further allocations as they can manually enumerate and populate the buffer themselves.

@penev92

This looks good overall, I just want to hear some opinions on the question of using ref to explicitly state that the method is modifying the passed collection. I will not block the merge for that, but I want a ruling ( @pchote ).

Also if we go with the "loop twice so we do everything in one go" idea a very important thing to note is that the cells collection can grow a lot, which means that with no hard size set the repeated resizing of the list can defeat the entire purpose of the PR.

@pchote

This comment has been minimized.

Show comment
Hide comment
@pchote

pchote Nov 30, 2017

Member

I agree with @RoosterDragon's original approach. Using ref here is misleading.

Member

pchote commented Nov 30, 2017

I agree with @RoosterDragon's original approach. Using ref here is misleading.

@pchote pchote added this to the Next release milestone Dec 9, 2017

@pchote

LGTM, but two questions/requests about the method signature:

Show outdated Hide outdated OpenRA.Mods.Common/TraitsInterfaces.cs Outdated
Avoid allocations when generating RadarSignatureCells.
The RadarWidget can supply a reusable buffer to each trait to avoid individual traits having to return new enumerables. Additionally, this allows the two traits to avoid LINQ and further allocations as they can manually enumerate and populate the buffer themselves.
@pchote

pchote approved these changes Dec 11, 2017

@abcdefg30 abcdefg30 merged commit 0899d02 into OpenRA:bleed Dec 11, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@abcdefg30

This comment has been minimized.

Show comment
Hide comment
@abcdefg30
Member

abcdefg30 commented Dec 11, 2017

@RoosterDragon RoosterDragon deleted the RoosterDragon:alloc-radar-cells branch Dec 12, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment