cachekv.GStore.Has currently calls Get internally on cache misses.
As a result, code paths using Has followed by Get pay gas for both operations even though only a single lookup is needed.
Current examples
- x/bank/keeper/send.go:getSendEnabled
- x/upgrade/keeper/keeper.go:getProtocolVersion
In particular, getSendEnabled is part of the SendCoins hot path and adds unnecessary gas cost per denom checked.
Possible improvement
- make cachekv.Has use parent.Has instead of parent.Get
- replace Has + Get patterns with a single Get where possible
cachekv.GStore.Has currently calls Get internally on cache misses.
As a result, code paths using Has followed by Get pay gas for both operations even though only a single lookup is needed.
Current examples
In particular, getSendEnabled is part of the SendCoins hot path and adds unnecessary gas cost per denom checked.
Possible improvement