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

more efficient precomputed hash keys

From:
demerphq
Date:
March 28, 2013 12:38
Subject:
more efficient precomputed hash keys
Message ID:
CANgJU+U3D6GH74-OYpO49ySLH7Zq=x6nU2hdugg+jvvSfLtD8w@mail.gmail.com
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?

cheers,
Yves



-- 
perl -Mre=debug -e "/just|another|perl|hacker/"



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About