diff options
author | Karl Williamson <khw@cpan.org> | 2014-08-21 17:29:10 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2014-08-22 12:14:59 -0600 |
commit | 305b86516461e93877909338ac3642c6ac09b651 (patch) | |
tree | d5d7b3c47a3af1537ffb549ee3eacf937bcd9571 /dump.c | |
parent | b51533f3c738c0d34d686dc15720c781f1043802 (diff) | |
download | perl-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 'dump.c')
-rw-r--r-- | dump.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -2139,7 +2139,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo Perl_dump_indent(aTHX_ level, file, " TARGLEN = %"IVdf"\n", (IV)LvTARGLEN(sv)); Perl_dump_indent(aTHX_ level, file, " TARG = 0x%"UVxf"\n", PTR2UV(LvTARG(sv))); Perl_dump_indent(aTHX_ level, file, " FLAGS = %"IVdf"\n", (IV)LvFLAGS(sv)); - if (LvTYPE(sv) != 't' && LvTYPE(sv) != 'T') + if (isALPHA_FOLD_NE(LvTYPE(sv), 't')) do_sv_dump(level+1, file, LvTARG(sv), nest+1, maxnest, dumpops, pvlim); } |