You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JavaScript has a garbage collector.. we gotta live with it.
In the original code, temporary vectors and similar where created on the stack without problems.
If we use new objects everytime, we'll just push work for the garbage collector.
Flyover has 2 solutions for this:
Making functions take an extra out-parameter
Adding static variables to the classes and reusing these variables when doing internal computations.
The former is fine.
The latter, however, is a but ugly to work with and compare code. This also allows to access these static variables from other classes, which flyover does a lot with the b2Vec2 static attributes. This requires you to have a good eye on these to avoid accidental double use.
In order to make the code easier to compare to upstream, I used top-level constants instead in some places, but that approach isn't perfect either:
JavaScript has a garbage collector.. we gotta live with it.
In the original code, temporary vectors and similar where created on the stack without problems.
If we use new objects everytime, we'll just push work for the garbage collector.
Flyover has 2 solutions for this:
The former is fine.
The latter, however, is a but ugly to work with and compare code. This also allows to access these static variables from other classes, which flyover does a lot with the b2Vec2 static attributes. This requires you to have a good eye on these to avoid accidental double use.
In order to make the code easier to compare to upstream, I used top-level constants instead in some places, but that approach isn't perfect either:
When I'm talking about double use, I mean something like:
Both functions use b2Vec2.s_t0, causing loss of data.
The goal of this task would be to evaluate the best approach to encapsulate the temp variables, so they can't easily get used in two places at once.
Then when implementing these changes, ensure, that no public temporary variables get shared over multiple modules.
The text was updated successfully, but these errors were encountered: