develooper Front page | perl.perl5.porters | Postings from January 2001

hash keys (Re: Ideas for papers)

Thread Previous | Thread Next
From:
nick
Date:
January 17, 2001 15:28
Subject:
hash keys (Re: Ideas for papers)
Message ID:
E14J1xB-0006rN-00@roam1
Nicholas Clark <nick@ccl4.org> writes:
>On Sat, Jan 13, 2001 at 09:21:09AM -0700, Nathan Torkington wrote:
>>  - work out how to precalculate the hash values for things like
>>    UNIVERSAL and main:: and other commonly hashed strings, and see
>>    what kind of performance win results (if any)
>
>Did anyone on here suggest storing the computed hash key for a SV in the
>IV slot (in the same way that SVf_OOK stores the offset)? Or is my memory
>deceiving me?

There is a special "shared" SV which has SvFAKE_on and SvREADONLY.
It does that, but _also_ has SvPVX pointing to shared string in shared key
table. Thus when doing a hash lookup we compare SvPVX before doing strcmp().

>
>Either way, is it OK to meddle with the IV slot on a SV with SVf_READONLY set?

In general it is not safe. But making more use of 'shared' SVs for string 
litterals will help. sv.c etc. has been taught about those and can cope.

>Is it a sign that the value isn't mutable? Or that it's to be treated as if
>it's in read only memory?

The snag is IV slot may be in use for real, or abused for something already.

-- 
Nick Ing-Simmons


Thread Previous | Thread Next


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