-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
Fix allocation on tickables #279
Fix allocation on tickables #279
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/hadashia/vcontainer/CTKEgrG73cUsuiH1fJsgipwsdqmG |
readonly EntryPointExceptionHandler exceptionHandler; | ||
bool disposed; | ||
|
||
public FixedTickableLoopItem( | ||
IEnumerable<IFixedTickable> entries, | ||
EntryPointExceptionHandler exceptionHandler) | ||
{ | ||
this.entries = entries; | ||
this.entries = entries.ToList(); |
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.
I think it would be better if ToList()
was removed.
( It is not clearly that no copying will occur
This class is internal and has no use case other than being passed an IReadOnlyList<T>
.
In this case, why not keep IReadOnlyList<T>
as an argument, and use for
and []
operator instead of foreach
?
( for ...
statement is exactly the same as the implementation of List<>.GetEnumerator. )
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.
In this case, why not keep IReadOnlyList as an argument, and use for and [] operator instead of foreach ?
I like that!
Assert.That(() => | ||
{ | ||
tickableLoopItem.MoveNext(); | ||
}, Is.Not.AllocatingGCMemory()); |
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.
👍
Thanks for the review! |
This makes sense. Thanks! |
When using Tickable, GC Allocation of 40 bytes per frame was occurring.
IEnumerable<T>.GetEnumerator()
causes an implicit cast, I think.To solve this problem, I modified the LoopItem to explicitly hold the List inside.
I'd like you to see if it looks OK. 🙏