This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Merge UNI2 and UNIBRACK
authorFather Chrysostomos <sprout@cpan.org>
Tue, 3 Jul 2012 05:27:47 +0000 (22:27 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 3 Jul 2012 05:40:28 +0000 (22:40 -0700)
The only difference between them is the PL_expect assignment,
which can be controlled by a constant parameter that the C
compiler will optimise away.

toke.c

diff --git a/toke.c b/toke.c
index d9963a9..c0375ae 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -275,9 +275,9 @@ static const char* const lex_state_names[] = {
  * The UNIDOR macro is for unary functions that can be followed by the //
  * operator (such as C<shift // 0>).
  */
-#define UNI2(f,x) { \
+#define UNI3(f,x,have_x) { \
        pl_yylval.ival = f; \
-       PL_expect = x; \
+       if (have_x) PL_expect = x; \
        PL_bufptr = s; \
        PL_last_uni = PL_oldbufptr; \
        PL_last_lop_op = f; \
@@ -286,23 +286,14 @@ static const char* const lex_state_names[] = {
        s = PEEKSPACE(s); \
        return REPORT( *s=='(' ? (int)FUNC1 : (int)UNIOP ); \
        }
-#define UNI(f)    UNI2(f,XTERM)
-#define UNIDOR(f) UNI2(f,XTERMORDORDOR)
+#define UNI(f)    UNI3(f,XTERM,1)
+#define UNIDOR(f) UNI3(f,XTERMORDORDOR,1)
 #define UNIPROTO(f,optional) { \
        if (optional) PL_last_uni = PL_oldbufptr; \
        OPERATOR(f); \
        }
 
-#define UNIBRACK(f) { \
-       pl_yylval.ival = f; \
-       PL_bufptr = s; \
-       PL_last_uni = PL_oldbufptr; \
-       PL_last_lop_op = f; \
-       if (*s == '(') \
-           return REPORT( (int)FUNC1 ); \
-       s = PEEKSPACE(s); \
-       return REPORT( (*s == '(') ? (int)FUNC1 : (int)UNIOP ); \
-       }
+#define UNIBRACK(f) UNI3(f,0,0)
 
 /* grandfather return to old style */
 #define OLDLOP(f) \