-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[RDY] Extend 'generic_factory' + aliases + use the factory to manage terrain objects #16368
[RDY] Extend 'generic_factory' + aliases + use the factory to manage terrain objects #16368
Conversation
Things probably became a wee bit faster.
Things became a bit cleaner semantically (no mess with pairs and pointers).
…ching, converting)
They're gonna replace the conversion table.
static const T dummy{}; | ||
return dummy; | ||
const T &obj( const string_id<T> &id ) const { | ||
static int_id<T> i_id; |
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.
Why is this static?
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.
To prevent constructing the object on each obj()
invocation. It gets reassigned anyway (x2).
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.
But it's confusing and error prone. Constructing (and initializing) a single int
(which is all that int_id
contains) shouldn't take any time.
I actually suspect this will prevent the compiler from certain optimizations: a non-static variable (especially since this is effectively only an `int) can be put into a register. The static variable must be in main memory and may need to be loaded again and again.
Also: the compiler may see that id is immediately (and unconditionally) overwritten in find
and may skip the initialization.
In short: looks like premature optimization.
All set. |
d66e065
to
7b31689
Compare
"No Fungal Mod" overrides a terrain type. Before, it would silently do it, now it complains about duplicates. |
It should. Terrain objects probably don't have |
No fungal mod is bundled as official mod, it needs to be handled correctly. |
I found two terrain objects there. Fix them here or in a different PR? |
Here |
OK. Give me a couple of minutes. |
Continues #15977.
generic_factory
class became responsible for routine id operations (converting, validating, caching (b393d7c), checking (2ae3eff)) and now supports aliases (0cb8184)generic_factory
doesn't expose the map object (a9a5db3) and doesn't construct a vector for iterating purposes. It returns the internal vector instead (be7deb4). Should be faster.ter_t
) are now managed using the factory (bea6b17). This means they can be properly modded.WIP becauseIt's done.ter_t::load()
doesn't usegeneric_factory
loading features yet. Also, I'm going to refactorter_t
checking to make it use it's own functionter_t::check()
.