develooper Front page | perl.perl5.porters | Postings from May 2010

Re: [perl #75350] PATCH: revamp ibcmp_utf8() for efficiency, clarity

Thread Previous | Thread Next
From:
demerphq
Date:
May 28, 2010 14:18
Subject:
Re: [perl #75350] PATCH: revamp ibcmp_utf8() for efficiency, clarity
Message ID:
AANLkTinya8cSI_mxTEFcdeLT5Mp_GVoTv8eKBMXcLpBk@mail.gmail.com
On 25 May 2010 20:24, karl williamson <perlbug-followup@perl.org> wrote:
> # New Ticket Created by  karl williamson
> # Please include the string:  [perl #75350]
> # in the subject line of all future correspondence about this issue.
> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=75350 >
>
>
> The first times I looked at this routine, it seemed incomprehensible.  I
> had to come back to it to fix a bug after working on other parts of Perl
> for a while, and it wasn't as foreign as before.  But I had to really
> understand it, so I started adding comments, and discovered that it was
> checking a number of things each time in the loop that could have  been
> figured out once.  So I ended up revamping it, keeping the same algorithm.

Somebody please figure out how to clone Karl so we have a backup. Thanks.

On a more serious note...

This looks much nicer to read than the original. ++ to you.

+Returns true if the strings s1 and s2 differ case-insensitively, false
+if they are equal case-insensitively.  Note that this is the complement of what
+you might expect (perhaps it would have been better to name it C<ibncmp_utf8>).

Seems to me that cmp routines always behave like this, they return -1
for inorder but different, 0 for different, and 1 for reverse order.

Anyway, the only other thing that occurs to me is that if it is going
to be rewritten, and reindented, could we lose the tabs please?

Besides these nits I vote apply.

Yves




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

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