mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-25 09:01:40 +00:00
* More code compression for reagent holder (#79796) ## About The Pull Request Part 2 of #79686 where we trim down the size of `holder.dm` even further and in the process give some procs more advanced features as they get merged with their counterparts. **1. Removes & merges `get_multiple_reagent_amounts()` proc with `get_reagent_amount()`** The proc `get_multiple_reagent_amounts()` was only used by bio generator and 1 other item with its only use being finding the sum of all reagents present in the list returned by `typesof(datum/reagent/consumable/nutrient)`. Currently the approach is very inefficient because. - `typesof()` is an expensive call which returns a long list of reagents - `get_multiple_reagent_amounts()` would then use 2 nested for loops. One to loop over every reagent in this holder & another inner for loop to loop over every reagent returned by `typesof()` operator so the time complexity of this proc is overall multiplicative which in lamen terms means "Bad" We can replicate the same behaviour of `typesof()` by using the `type2parent()` proc and 1 more direct type check to get the exact same behaviour but with much faster results, therefore reducing overall code **2. Removes & merges `get_reagent()` proc with `has_reagent()`** The proc `has_reagent()` is way more advanced than `get_reagent()` with arguments requesting for a specific amount, metabolization and now even has a new argument i.e. `chemical flag`. `has_reagent()` has always returned the reagent reference directly and not a simple TRUE/FALSE so it is a perfect replacement for `get_reagent()`, therefore reducing overall code **3. Removes & merges `has_chemical_flag()` proc with `has_reagent()`** The proc `has_reagent()` can now look for a specific reagent with a specific chemical flag as well as mentioned above thus it can replace `has_chemical_flag()` therefore reducing overall code ## Changelog 🆑 code: Removes & merges `get_multiple_reagent_amounts()` proc with `get_reagent_amount()` inside reagent holder code: Removes & merges `get_reagent()` proc with `has_reagent()` inside reagent holder code: Removes & merges `has_chemical_flag()` proc with `has_reagent()` inside reagent holder refactor: Reagent holder code has been further compressed. Report bugs on github /🆑 * More code compression for reagent holder * Update hemophage_organs.dm --------- Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: Giz <13398309+vinylspiders@users.noreply.github.com>