summaryrefslogtreecommitdiff
path: root/dump.c
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 /dump.c
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 'dump.c')
-rw-r--r--dump.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/dump.c b/dump.c
index 5ee69101e1..75f0fb4b09 100644
--- a/dump.c
+++ b/dump.c
@@ -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);
}