quick-cache
quick-cache copied to clipboard
Shouldn't Weighter::weight return u64?
It seems weird that the limit for a single item is limited to u32 even though weight for the overall collection is expressed as u64. Is that an intentional design choice to limit the weight for a given entry to 4 GiB?
That was intentional in order to avoid dealing with the possibility of overflow.
I think overflows could be revisited if it's not too annoying to handle or even have the internal weight tracking be u128.
I see. Wouldn't overflows just be a checked_sub/checked_add if you want to enforce panic (slightly slower in optimized builds) or just normal math & leave it to be the users problem (i.e. panic in debug, but "bad things happen" in release)?