[CodeGenerator:] Cache static component index lookup into local var
See original GitHub issueExample:
// Before
public void AddPosition(IntVector2 newValue) {
var component = CreateComponent<PositionComponent>(CoreComponentsLookup.Position);
component.value = newValue;
AddComponent(CoreComponentsLookup.Position, component);
}
// After
public void AddPosition(IntVector2 newValue) {
var index = CoreComponentsLookup.Position;
var component = CreateComponent<PositionComponent>(index);
component.value = newValue;
AddComponent(index, component);
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
map lookups function calls Vs caching the lookup as a ...
I would just retrieve the value from the map directly. Leave it to the calling code to cache the value in a sensible...
Read more >The Elements of Cache Programming Style
The idea is to modify data structures and code just slightly, trying to use the cache more effectively. Hopefully I will achieve two...
Read more >Strange caching of Web Page card viewing local static ...
I am using an AppDaemon Python script to create a static web page in /config/www/my_location/index.html . This updates index.html every hour ...
Read more >Caching — list of Rust libraries/crates ...
Crates to store the results of previous computations in order to reuse the results. ... access to local and remote cargo registry indices....
Read more >Static Lookup Cache
It queries the cache based on the lookup condition for each row that passes into the transformation. When the lookup condition is true,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ooh. Yes I know that. I overlooked the second use of the lookup variable lol. faster by 1 statement. 👍
The difference is that the new variable
indexis used twice. The compiler won’t reuse the same variable for that as it doesn’t know whatCoreComponentsLookup.Positiondoes. It could have side effects for example.