in reply to Re: state preserving uniq
in thread state preserving uniq

And that can be sped up even more...
perl -ne 'print if 1 == ++$s{lc $_}'
(The difference is that you don't have to create temporary variables.)

Replies are listed 'Best First'.
Re: Re: Re: state preserving uniq
by xmath (Hermit) on Mar 01, 2003 at 16:22 UTC
    Although I can't test it right now, I sincerely doubt that your version is faster, especially if you compare the optrees:

    While your version does save copying the old integer value to a temporary (you realize the temporary sv is allocated at compile-time, right?), it takes two extra ops, which I'm pretty sure costs more cpu time.

    And in any case the difference is too minimal (especially compared to lowercasing the string and doing a hash lookup) to justify adding to the code complexity