sas Mon Dec 9 10:28:23 2002 EDT Modified files: /php4/ext/ircg ircg_scanner.c ircg_scanner.re Log: turn frequently called functions into macros to reduce function call and pointer dereference overhead. Index: php4/ext/ircg/ircg_scanner.c diff -u php4/ext/ircg/ircg_scanner.c:1.20 php4/ext/ircg/ircg_scanner.c:1.21 --- php4/ext/ircg/ircg_scanner.c:1.20 Sun Dec 1 01:30:01 2002 +++ php4/ext/ircg/ircg_scanner.c Mon Dec 9 10:28:23 2002 @@ -1,4 +1,4 @@ -/* Generated by re2c 0.5 on Sun Dec 1 07:27:15 2002 */ +/* Generated by re2c 0.5 on Mon Dec 9 16:23:46 2002 */ #line 1 "/lrg2/php4/ext/ircg/ircg_scanner.re" /* +----------------------------------------------------------------------+ @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ircg_scanner.c,v 1.20 2002/12/01 06:30:01 sas Exp $ */ +/* $Id: ircg_scanner.c,v 1.21 2002/12/09 15:28:23 sas Exp $ */ #include "php_ircg_alloc.h" @@ -78,10 +78,9 @@ #define STD_PARA ircg_msg_scanner *ctx, const char *start, const char *YYCURSOR #define STD_ARGS ctx, start, YYCURSOR -static inline void passthru(STD_PARA) -{ - smart_str_appendl_ex(ctx->result, start, YYCURSOR - start, 1); -} +#define PASSTHRU() do { + \ + smart_str_appendl_ex(result, start, YYCURSOR - start, 1); \ +} while (0) static inline void handle_scheme(STD_PARA) { @@ -186,10 +185,9 @@ } } -static void add_entity(STD_PARA, const char *entity) -{ - smart_str_appends_ex(ctx->result, entity, 1); -} +#define ADD_CONST(entity) do { + \ + smart_str_appends_ex(result, entity, 1); + \ +} while (0) void ircg_mirc_color(const char *msg, smart_str *result, size_t msg_len, int auto_links, int gen_br) { @@ -310,43 +308,43 @@ if(yych <= 'z') goto yy25; } yy4: -#line 234 - { passthru(STD_ARGS); goto state_plain; } +#line 232 + { PASSTHRU(); goto state_plain; } yy5: yych = *++YYCURSOR; yy6: -#line 225 +#line 223 { mctx.fg_code = mctx.bg_code = -1; goto state_color_fg; } yy7: yych = *++YYCURSOR; yy8: -#line 226 - { add_entity(STD_ARGS, "<"); goto state_plain; } +#line 224 + { ADD_CONST("<"); goto state_plain; } yy9: yych = *++YYCURSOR; yy10: -#line 227 - { add_entity(STD_ARGS, ">"); goto state_plain; } +#line 225 + { ADD_CONST(">"); goto state_plain; } yy11: yych = *++YYCURSOR; yy12: -#line 228 - { add_entity(STD_ARGS, "&"); goto state_plain; } +#line 226 + { ADD_CONST("&"); goto state_plain; } yy13: yych = *++YYCURSOR; yy14: -#line 229 - { add_entity(STD_ARGS, """); goto state_plain; } +#line 227 + { ADD_CONST("""); goto state_plain; } yy15: yych = *++YYCURSOR; yy16: -#line 230 - { if (gen_br) smart_str_appendl_ex(result, "<br>", 4, 1); goto state_plain; } +#line 228 + { if (gen_br) ADD_CONST("<br>"); goto state_plain; } yy17: yych = *++YYCURSOR; yy18: -#line 231 +#line 229 { handle_bold(STD_ARGS, 0); goto state_plain; } yy19: yych = *++YYCURSOR; yy20: -#line 232 +#line 230 { handle_underline(STD_ARGS, 0); goto state_plain; } yy21: yych = *++YYCURSOR; yy22: -#line 233 +#line 231 { handle_italic(STD_ARGS, 0); goto state_plain; } yy23: yych = *++YYCURSOR; goto yy4; @@ -361,10 +359,10 @@ if(yych != '/') goto yy2; yy28: yych = *++YYCURSOR; yy29: -#line 224 - { if (auto_links) { handle_scheme(STD_ARGS); goto state_url; } else { passthru(STD_ARGS); goto state_plain; } } +#line 222 + { if (auto_links) { handle_scheme(STD_ARGS); goto state_url; } else { +PASSTHRU(); goto state_plain; } } } -#line 235 +#line 233 state_url: @@ -430,19 +428,19 @@ yy32: yych = *++YYCURSOR; goto yy37; yy33: -#line 240 +#line 238 { handle_url(STD_ARGS); goto state_plain; } yy34: yych = *++YYCURSOR; yy35: -#line 241 - { passthru(STD_ARGS); goto state_plain; } +#line 239 + { PASSTHRU(); goto state_plain; } yy36: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy37: if(yybm[0+yych] & 128) goto yy36; goto yy33; } -#line 242 +#line 240 @@ -462,16 +460,16 @@ if(yych <= '/') goto yy41; if(yych <= '9') goto yy44; yy41: -#line 248 +#line 246 { handle_color_digit(STD_ARGS, 0); goto state_color_comma; } yy42: yych = *++YYCURSOR; yy43: -#line 249 - { finish_color_stuff(STD_ARGS); passthru(STD_ARGS); goto state_plain; } +#line 247 + { finish_color_stuff(STD_ARGS); PASSTHRU(); goto state_plain; } yy44: yych = *++YYCURSOR; goto yy41; } -#line 250 +#line 248 @@ -488,14 +486,14 @@ if(yych != ',') goto yy49; yy47: yych = *++YYCURSOR; yy48: -#line 256 +#line 254 { goto state_color_bg; } yy49: yych = *++YYCURSOR; yy50: -#line 257 +#line 255 { YYCURSOR--; commit_color_stuff(STD_ARGS); goto state_plain; } } -#line 258 +#line 256 @@ -515,16 +513,16 @@ if(yych <= '/') goto yy54; if(yych <= '9') goto yy57; yy54: -#line 264 +#line 262 { handle_color_digit(STD_ARGS, 1); commit_color_stuff(STD_ARGS); goto state_plain; } yy55: yych = *++YYCURSOR; yy56: -#line 265 +#line 263 { commit_color_stuff(STD_ARGS); goto state_plain; } yy57: yych = *++YYCURSOR; goto yy54; } -#line 266 +#line 264 stop: Index: php4/ext/ircg/ircg_scanner.re diff -u php4/ext/ircg/ircg_scanner.re:1.19 php4/ext/ircg/ircg_scanner.re:1.20 --- php4/ext/ircg/ircg_scanner.re:1.19 Sun Dec 1 01:30:01 2002 +++ php4/ext/ircg/ircg_scanner.re Mon Dec 9 10:28:23 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ircg_scanner.re,v 1.19 2002/12/01 06:30:01 sas Exp $ */ +/* $Id: ircg_scanner.re,v 1.20 2002/12/09 15:28:23 sas Exp $ */ #include "php_ircg_alloc.h" @@ -89,10 +89,9 @@ #define STD_PARA ircg_msg_scanner *ctx, const char *start, const char *YYCURSOR #define STD_ARGS ctx, start, YYCURSOR -static inline void passthru(STD_PARA) -{ - smart_str_appendl_ex(ctx->result, start, YYCURSOR - start, 1); -} +#define PASSTHRU() do { + \ + smart_str_appendl_ex(result, start, YYCURSOR - start, 1); \ +} while (0) static inline void handle_scheme(STD_PARA) { @@ -197,10 +196,9 @@ } } -static void add_entity(STD_PARA, const char *entity) -{ - smart_str_appends_ex(ctx->result, entity, 1); -} +#define ADD_CONST(entity) do { + \ + smart_str_appends_ex(result, entity, 1); + \ +} while (0) void ircg_mirc_color(const char *msg, smart_str *result, size_t msg_len, int auto_links, int gen_br) { @@ -221,24 +219,24 @@ if (xp >= end) goto stop; start = YYCURSOR; /*!re2c - scheme "://" { if (auto_links) { handle_scheme(STD_ARGS); goto state_url; } else { passthru(STD_ARGS); goto state_plain; } } + scheme "://" { if (auto_links) { handle_scheme(STD_ARGS); goto state_url; } +else { PASSTHRU(); goto state_plain; } } coloresc { mctx.fg_code = mctx.bg_code = -1; goto state_color_fg; } - "<" { add_entity(STD_ARGS, "<"); goto state_plain; } - ">" { add_entity(STD_ARGS, ">"); goto state_plain; } - "&" { add_entity(STD_ARGS, "&"); goto state_plain; } - winquotes { add_entity(STD_ARGS, """); goto state_plain; } - ircnl { if (gen_br) smart_str_appendl_ex(result, "<br>", 4, 1); goto state_plain; } + "<" { ADD_CONST("<"); goto state_plain; } + ">" { ADD_CONST(">"); goto state_plain; } + "&" { ADD_CONST("&"); goto state_plain; } + winquotes { ADD_CONST("""); goto state_plain; } + ircnl { if (gen_br) ADD_CONST("<br>"); goto state_plain; } bold { handle_bold(STD_ARGS, 0); goto state_plain; } underline { handle_underline(STD_ARGS, 0); goto state_plain; } italic { handle_italic(STD_ARGS, 0); goto state_plain; } - anynoneof { passthru(STD_ARGS); goto state_plain; } + anynoneof { PASSTHRU(); goto state_plain; } */ state_url: start = YYCURSOR; /*!re2c [-a-zA-Z0-9~_?=.@&+/#:;!*'()%,$]+ { handle_url(STD_ARGS); goto state_plain; } - any { passthru(STD_ARGS); goto state_plain; } + any { PASSTHRU(); goto state_plain; } */ @@ -246,7 +244,7 @@ start = YYCURSOR; /*!re2c digit digit? { handle_color_digit(STD_ARGS, 0); goto state_color_comma; } - any { finish_color_stuff(STD_ARGS); passthru(STD_ARGS); goto state_plain; } + any { finish_color_stuff(STD_ARGS); +PASSTHRU(); goto state_plain; } */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php