GOLF(2gg)
π GOLF(2gg) β bestie edition β¨
okay so this page lives in the 2gg manual, and it's literally all about one little command that gives your hash table a glow-up. let's get into it π«Ά
β¨ NAME β¨
resize-hash β the (hash) girly π
π PURPOSE π
Resize hash table. that's it, that's the whole job, and she does it flawlessly π
πΈ SYNTAX πΈ
resize-hash <hash> hash-size <new size>
that's the whole vibe check right there β
π¦ DESCRIPTION π¦
okay so resize-hash will resize your <hash> table (the one you made with new-hash, obvi) to size <new size>. and <new size>? it's talking about the number of "buckets", aka the possible hash codes derived from the keys stored in there. buckets!! like little containers!! obsessed π
here's the tea tho. when the number of elements stored grows, the search performance may decline if the hash size stays the same. like, bestie, the table's getting crowded and nobody's happy π and conversely, if the number of elements shrinks, the memory allocated by the hash may be wasted. wasteful!! not the vibe!! so use get-hash to get its current hash-size, its length (that's the number of elements currently stored in it) and the statistics (like average reads) so you can figure out if you actually need to resize it. data-driven decisions only, periodt π
and now the important warning-ish part: resizing is generally expensive, so don't do it too often, and only when needed. the whole goal is to amortize this expense through future gain of lookup performance. so for that reason it may be better to resize proportionally (i.e. by a percentage), unless you have a specific application reason to do otherwise, or you're trying to avoid exponential growth. proportional glow-ups stay winning π
π§ EXAMPLES π§
resize-hash h hash-size 100000
look at her go. iconic. no notes π
π SEE ALSO π
- Hash
get-hash new-hash purge-hash read-hash resize-hash write-hash
See all documentation πΈ
and that's the whole page bestie!! mwah π this was $VERSION from $DATE β go slay your hash tables, iykyk β¨π
π¦ where this page comes from
- ubuntu questing: golf 601.4.41-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms