Pressing 'a' for use item menu in attached save takes ~7 seconds for menu to open.
I have managed to locate what is causing the slowness.
iuse_actor.cpp:
ret_val<bool> iuse_transform::can_use( const Character &p, const item &, bool,
const tripoint & ) const
line 261 currently
adding simple return on the beginning of that method makes the action almost instant
I don't know what it does exactly but I think it gathers and checks whole new inventory from all items around. And it does it for all items(?).
Steps to reproduce the behavior:
It should take far less time to open that menu.
That's quite a lot of items.
The attached save link is no longer available, but I can still reproduce this in 0.E-6107-g 973dd89c37
spawn, w item, Everything, (quantity 1).Eat menu - it comes up almost instantly, though it's ~12 pages longactivate menu - it takes 15-20 seconds to generate the ~21 pagesI just took a quick look at it and something looks suspicious:
Character::can_pickVolume(item const&, bool) is called five times in different places (I assume for the same items).


Can somebody who's more familiar with item management check that out?
So I tried adding a simple cache to pickup_inventory_preset::get_denial:
mutable std::unordered_map<const item*, std::string> denial_cache;
And it speeds up activation menu opening at least by half (1.1 seconds -> 0.5 seconds).
Before

After

@KorGgenT, can you evaluate this idea? I'm not sure about the lifetime of pickup_inventory_preset and whether using a cache there won't break something.
Most helpful comment
So I tried adding a simple cache to
pickup_inventory_preset::get_denial:And it speeds up activation menu opening at least by half (1.1 seconds -> 0.5 seconds).
Before

After

@KorGgenT, can you evaluate this idea? I'm not sure about the lifetime of
pickup_inventory_presetand whether using a cache there won't break something.