On Fri, Apr 23, 2004 at 11:42:50PM +0100 Nicholas Clark wrote:

> On Tue, Apr 20, 2004 at 11:16:07AM +0200, Tassilo von Parseval wrote:
> > On Tue, Apr 20, 2004 at 09:18:12AM +0100 Nick Ing-Simmons wrote:
> 
> > > Would both give C "foo" calling sharepvn() on that would however look 
> > > up that string and return a pointer to shared copy.
> > > 
> > > This is used by perl's hashes etc. so that you can just compare 
> > > the PV values to get a fast proof of equality.
> > > 
> > > (You should unsharepvn() when you don't need it anymore - they are refcounted.)
> > 
> > Cool! So that's another treasure not to be found in perlapi.pod:
> > 
> >     #define Perl_sharepvn(sv, len, hash)
> > 
> > What about its third argument, though? It's an U32...so should 'hash' by
> > used as a sort of ID to unambiguously identify pointers? I suppose I
> > can't just set it to zero, can I?
> 
> 
> It returns a pointer to the string in the shared string table (inserting
> it if necessary). The shared string table is reference counted, so as Nick
> says you must unshare anything when you finish with it. The hash is a value
> calculated with PERL_HASH
> 
> Chasing the source code in hv.c, no it doesn't look like you can just use 0.

Thank you. I have to remember it when I might be in need of such a
pool/hash of shared strings. It sounds as though it can be used in some
imaginative way.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval

Reply via email to