-
Notifications
You must be signed in to change notification settings - Fork 26
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
Refactor base machine production loop #397
Conversation
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.
didn't test but looks good 👍
if powered then | ||
meta:set_int("src_time", meta:get_int("src_time") + round(def.speed*10)) | ||
src_time = src_time + math.floor(def.speed * 10 + 0.5) |
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.
(just fyi, not really an issue here) i tried "inlining" some of the builtin functions and got a few percent more performance out of it if they are called often (for example here: https://github.com/BuckarooBanzay/mapsync/blob/master/encoding.lua#L1)
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.
Yeah, thought that for a moment too when I removed round(n)
function but most of time this loop is executed something like twice or so unless someone add some extreme def.speed
machine. Of course this times number of active machine in world but even then would still be very low.
I guess that could even be done later like for everything at once and make it kinda like a style rule rather than based on sometimes questionable benefit.
I did actually think a bit about optimizations too: this probably could be rewritten to grab all ingredients at once, calculate iterations beforehand, process recipes directly and modify inventories only once. (through I'm not gonna go there just yet 😅)
Click for detailed source code test coverage reportTest coverage report for Technic CNC 87.49% in 11/14 files:
Test coverage report for technic chests 44.99% in 6/6 files:
Test coverage report for technic 67.06% in 97/98 files:
Raw test runner output for geeks:CNC:
Chests:
Technic:
|
A little bit of fairly simple refactoring to make it a bit cleaner and while at it also reduce unnecessary things done in (potential) loop.