handy.h: Add an enum typedef
authorKarl Williamson <public@khwilliamson.com>
Fri, 7 Dec 2012 04:01:29 +0000 (21:01 -0700)
committerKarl Williamson <public@khwilliamson.com>
Sun, 9 Dec 2012 19:08:28 +0000 (12:08 -0700)
This creates a copy of all the Posix character class numbers and puts
them in an enum.  This enum is for internal Perl core use only, and is
used so hopefully compilers can generate better code from future commits
that will make use of it.

handy.h

index 6af1400..f7cd8fe 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -764,6 +764,29 @@ patched there.  The file as of this writing is cpan/Devel-PPPort/parts/inc/misc
  * Latin1 range from the ALPHA bit only in two relatively unimportant
  * characters: the masculine and feminine ordinal indicators */
 
+#if defined(PERL_CORE) || defined(PERL_EXT)
+/* An enum version of the character class numbers, to help compilers
+ * optimize */
+typedef enum {
+    _CC_ENUM_ALNUMC         = _CC_ALNUMC,
+    _CC_ENUM_ALPHA          = _CC_ALPHA,
+    _CC_ENUM_DIGIT          = _CC_DIGIT,
+    _CC_ENUM_GRAPH          = _CC_GRAPH,
+    _CC_ENUM_LOWER          = _CC_LOWER,
+    _CC_ENUM_PRINT          = _CC_PRINT,
+    _CC_ENUM_PUNCT          = _CC_PUNCT,
+    _CC_ENUM_UPPER          = _CC_UPPER,
+    _CC_ENUM_WORDCHAR       = _CC_WORDCHAR,
+    _CC_ENUM_SPACE          = _CC_SPACE,
+    _CC_ENUM_BLANK          = _CC_BLANK,
+    _CC_ENUM_XDIGIT         = _CC_XDIGIT,
+    _CC_ENUM_CNTRL          = _CC_CNTRL,
+    _CC_ENUM_PSXSPC         = _CC_PSXSPC,
+    _CC_ENUM_ASCII          = _CC_ASCII,
+    _CC_ENUM_VERTSPACE      = _CC_VERTSPACE
+} _char_class_number;
+#endif
+
 #  ifdef DOINIT
 EXTCONST  U32 PL_charclass[] = {
 #    include "l1_char_class_tab.h"