This PR contains logic fixes to recycle_waifs
reproduction steps:
Load stock Lambdacore.
@create #1 called "generic waif",waif
@corify waif as waif
@verb waif:new tnt
@program waif:new
Paste the following code:
set_task_perms(caller_perms());
w = new_waif();
w:initialize();
return w;
Once the verb saves, eval $waif:new();
Expected: E_VRBNF; got panic.
The issue is that we were previously calling recycled_waifs:erase, which was invalidating the current iterator.
Create a vector which stores a list of all waifs to be recycled. After we mark them for recycle, iterate through that vector and free/remove them from the map.
I also took the opportunity to update the map on both recycled_waifs and waif_class_count to be an unordered_map. These are true hashes (and pointers can be hashed), so the amount of indexing and setting done will be sped up by a decent amount.
reproduction steps:
Load stock Lambdacore.
@create #1 called "generic waif",waif
@corify waif as waif
@verb waif:new tnt
@program waif:new
Paste the following code:
set_task_perms(caller_perms());
w = new_waif();
w:initialize();
return w;
Once the verb saves, eval $waif:new();
Expected: E_VRBNF; got panic.
The issue is that we were previously calling recycled_waifs:erase, which was invalidating the current iterator.
Create a vector which stores a list of all waifs to be recycled. After we mark them for recycle, iterate through that vector and free/remove them from the map.
I also took the opportunity to update the map on both recycled_waifs and waif_class_count to be an unordered_map. These are true hashes (and pointers can be hashed), so the amount of indexing and setting done will be sped up by a decent amount.
This PR contains logic fixes to
recycle_waifs
reproduction steps: