LuaTechnology.level is not consistent

Things that already exist in the current mod API
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: LuaTechnology.level is not consistent

Post by eradicator »

PyroFire wrote:
Tue Oct 01, 2019 11:13 am
There is only ever one optimization goal.
Less CPU cycles.
It doesn't matter what it looks like to get the cycles cost down, particularly in this case.
No there are many different optimization goals. CPU usage, Memory usage size, Memory bandwidth usage, Maintanability, Code complexity, etcpp. Many of which preclude each other.
PyroFire wrote:
Tue Oct 01, 2019 11:13 am
eradicator wrote:
Sun Sep 29, 2019 9:55 am
Technology research state does not change "several times per tick". Whatever you're doing there is the wrong approach to the problem and you need to fix the approach, not the "solution".
No, but you may need to call research_level for several different researches under several different functions in the same operation depending on what you're doing - Typically if you need to act based on the research level.
Sounds like premature optimization. You're optimizing for some hypothetical edge case. If that actually was a problem it would be more cpu efficient to cache the result and update the cache in on_technology_researched (sacrificing memory and code complexity). If it *isn't* a problem then the cache is premature optimization again.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Already exists”