handy.h: Improve definition of FITS_IN_8_BITS
authorKarl Williamson <public@khwilliamson.com>
Wed, 28 Sep 2011 21:39:03 +0000 (15:39 -0600)
committerKarl Williamson <public@khwilliamson.com>
Sat, 1 Oct 2011 15:58:10 +0000 (09:58 -0600)
Unoptimized, the new definition takes signficantly fewer machine
instructions than the old one

handy.h

diff --git a/handy.h b/handy.h
index a343691..6091097 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -577,10 +577,8 @@ patched there.  The file as of this writing is cpan/Devel-PPPort/parts/inc/misc
  * compiler to optimize it out if possible.  This is because Configure makes
  * sure that the machine has an 8-bit byte, so if c is stored in a byte, the
  * sizeof() guarantees that this evaluates to a constant true at compile time.
- * The use of the mask instead of '< 256' keeps gcc from complaining that it is
- * always true, when c's storage class is a byte. */
-#define FITS_IN_8_BITS(c) ((sizeof(c) == 1)                                    \
-                         || (((WIDEST_UTYPE)(c) & 0xFF) == (WIDEST_UTYPE)(c)))
+ */
+#define FITS_IN_8_BITS(c) ((sizeof(c) == 1) || !(((WIDEST_UTYPE)(c)) & ~0xFF))
 
 #ifdef EBCDIC
 #   define isASCII(c)    (FITS_IN_8_BITS(c) && (NATIVE_TO_UNI((U8) (c)) < 128))