in reply to optimization - exists should return a reference

It's not all that bad an idea. Chances are you want this optimization when the values in a hash ARE references. So the source pseudocode would be:
if (SvTYPE(hash_value) == SvREF) return hash_value; else return new_SV_ref(hash_value);
I like it. I could try to write it, if you'd like.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: optimization - exists should return a reference
by John M. Dlugosz (Monsignor) on Jan 16, 2003 at 03:33 UTC
    Good point.

    Sure, try it. Even if limited and not ready for general population, you can show some concrete numbers on the performance differences.