develooper Front page | perl.perl5.porters | Postings from March 2013

more efficient precomputed hash keys

March 28, 2013 12:38
more efficient precomputed hash keys
Message ID:
We currently use a somewhat circuitous method to cache keys for
constant key lookups.

The hash information is stored in magic attached to an SV which is
stored in a const op.

I can only guess why it works like this, possibly because we needed
the string due to rehashing, I'm not sure.

But it seems to me that now that rehashing is gone, we could fold this
down, and store a HEK instead. For instance we could at compile time
add the key to PL_strtab give it a refcount of 1, (so it is never
removed), and then store a pointer to that HEK. IMO this would
probably speed up constant key lookups.

Can anyone think of any gotchyas that might make this unfeasible?


perl -Mre=debug -e "/just|another|perl|hacker/" Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About