[tpm] Breaking a string up into hash keys
uri at stemsystems.com
Sun Apr 14 09:59:46 PDT 2013
On 04/14/2013 12:44 PM, Rob Janes wrote:
> It's not a deep hash though. it's just composing a single key by
> joining with an obscure character that you're unlikely to find in a
> key normally.
i didn't say it was a deep hash. it is just a different way to get
multilevel hashes with simpler and faster code.
> Sure, it should work fine, and will probably be a lot speedier than
> lookups by loop or recursion. On the other hand, if there's a lot in
> the hash, this method could result in a lot of hash collisions and
> inefficient lookups. And, on the other other hand, to see that slow
> things down so much that this multidimensional thing will be slower
> than loop/recursion ...that would be a corner case.
one hash lookup will always beat a loop descending into a hash. and
normally i would never recommend this trick due to the requirement of
not allowing $; to be in the key. but given how almost all hash keys are
usually printable, this isn't a problem in most cases.
i doubt there would be any more collisions than with any hash design. a
flat hash will grow its bucket array as needed just like any other perl
hash which does that to lower collisions.
More information about the toronto-pm