summaryrefslogtreecommitdiff
path: root/utils.lst
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-08-21 17:29:10 -0600
committerKarl Williamson <khw@cpan.org>2014-08-22 12:14:59 -0600
commit305b86516461e93877909338ac3642c6ac09b651 (patch)
treed5d7b3c47a3af1537ffb549ee3eacf937bcd9571 /utils.lst
parentb51533f3c738c0d34d686dc15720c781f1043802 (diff)
downloadperl-305b86516461e93877909338ac3642c6ac09b651.tar.gz
Add and use macros for case-insensitive comparison
This adds to handy.h isALPHA_FOLD_EQ(c1,c2) which efficiently tests if c1 and c2 are the same character, case-insensitively. For example isALPHA_FOLD_EQ(c, 's') returns true if and only if <c> is 's' or 'S'. isALPHA_FOLD_NE() is also added by this commit. At least one of c1 and c2 must be known to be in [A-Za-z] or this macro doesn't work properly. (There is an assert for this in the macro in DEBUGGING builds). That is why the name includes "ALPHA", so you won't forget when using it. This functionality has been in regcomp.c for a while, under a different name. I had thought that the only reason to make it more generally available was potential speed gain, but recent gcc versions optimize to the same code, so I thought there wasn't any point to doing so. But I now think that using this makes things easier to read (and certainly shorter to type in). Once you grok what this macro does, it simplifies what you have to keep in your mind when reading logical expressions with multiple operands. That something can be either upper or lower case can be a distraction to understanding the larger point of the expression.
Diffstat (limited to 'utils.lst')
0 files changed, 0 insertions, 0 deletions