cvs: php4 /ext/standard url_scanner_ex.c url_scanner_ex.h url_scanner_ex.re

From: Date: Wed, 20 Sep 2000 08:13:46 +0000
Subject: cvs: php4 /ext/standard url_scanner_ex.c url_scanner_ex.h url_scanner_ex.re
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-1813@lists.php.net to get a copy of this message
sas Wed Sep 20 01:13:46 2000 EDT Modified files: /php4/ext/standard url_scanner_ex.re url_scanner_ex.h url_scanner_ex.c Log: Remove this pseudo optimization from the previous rewrite. Since we leave/enter the loop more often, the cost of maintaining c_arg/c_val is higher than simply copying the tag/arg string once. Index: php4/ext/standard/url_scanner_ex.re diff -u php4/ext/standard/url_scanner_ex.re:1.10 php4/ext/standard/url_scanner_ex.re:1.11 --- php4/ext/standard/url_scanner_ex.re:1.10 Wed Sep 20 01:06:01 2000 +++ php4/ext/standard/url_scanner_ex.re Wed Sep 20 01:13:45 2000 @@ -225,7 +225,7 @@ #define HANDLE_TAG() {\ int ok = 0; \ int i; \ - smart_str_setl(&ctx->tag, start, YYCURSOR - start); \ + smart_str_copyl(&ctx->tag, start, YYCURSOR - start); \ for (i = 0; check_tag_arg[i].tag; i++) { \ if (ctx->tag.len == check_tag_arg[i].taglen \ && strncasecmp(ctx->tag.c, check_tag_arg[i].tag, ctx->tag.len) == 0) { \ @@ -237,30 +237,13 @@ } #define HANDLE_ARG() {\ - smart_str_setl(&ctx->arg, start, YYCURSOR - start); \ + smart_str_copyl(&ctx->arg, start, YYCURSOR - start); \ } #define HANDLE_VAL(quotes) {\ smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); \ tag_arg(ctx PLS_CC); \ } -/* - * Since arg/tag are read-only during the mainloop, we do not need - * to copy them. We need those variables across multiple calls - * to url_adapt() though, but they point to a private buffer. So we - * copy them before leaving the mainloop() and restore them at - * the beginning. - */ - -#define MOVE_TO_CTX(X) \ - if (ctx->X.c) \ - smart_str_copyl(&ctx->c_##X, ctx->X.c, ctx->X.len); \ - else \ - smart_str_free(&ctx->c_##X) - -#define FETCH_FROM_CTX(X) \ - smart_str_setl(&ctx->X, ctx->c_##X.c, ctx->c_##X.len) - static inline void mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size_t newlen) { char *end, *q; @@ -269,9 +252,6 @@ int rest; PLS_FETCH(); - FETCH_FROM_CTX(arg); - FETCH_FROM_CTX(tag); - smart_str_appendl(&ctx->buf, newdata, newlen); YYCURSOR = ctx->buf.c; @@ -340,9 +320,6 @@ printf("stopped in state %d at pos %d (%d:%c)\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR); #endif - MOVE_TO_CTX(tag); - MOVE_TO_CTX(arg); - rest = YYLIMIT - start; memmove(ctx->buf.c, start, rest); @@ -395,8 +372,8 @@ smart_str_free(&ctx->result); smart_str_free(&ctx->buf); - smart_str_free(&ctx->c_tag); - smart_str_free(&ctx->c_arg); + smart_str_free(&ctx->tag); + smart_str_free(&ctx->arg); return SUCCESS; } Index: php4/ext/standard/url_scanner_ex.h diff -u php4/ext/standard/url_scanner_ex.h:1.5 php4/ext/standard/url_scanner_ex.h:1.6 --- php4/ext/standard/url_scanner_ex.h:1.5 Wed Sep 20 01:06:01 2000 +++ php4/ext/standard/url_scanner_ex.h Wed Sep 20 01:13:45 2000 @@ -38,10 +38,6 @@ smart_str val; /* read only */ smart_str buf; - /* Dito, but they are used only for preserving data across calls */ - smart_str c_tag; - smart_str c_arg; - /* The result buffer */ smart_str result; Index: php4/ext/standard/url_scanner_ex.c diff -u php4/ext/standard/url_scanner_ex.c:1.10 php4/ext/standard/url_scanner_ex.c:1.11 --- php4/ext/standard/url_scanner_ex.c:1.10 Wed Sep 20 01:06:01 2000 +++ php4/ext/standard/url_scanner_ex.c Wed Sep 20 01:13:45 2000 @@ -1,4 +1,4 @@ -/* Generated by re2c 0.5 on Wed Sep 20 10:04:05 2000 */ +/* Generated by re2c 0.5 on Wed Sep 20 10:08:57 2000 */ #line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re" /* +----------------------------------------------------------------------+ @@ -227,7 +227,7 @@ #define HANDLE_TAG() {\ int ok = 0; \ int i; \ - smart_str_setl(&ctx->tag, start, YYCURSOR - start); \ + smart_str_copyl(&ctx->tag, start, YYCURSOR - start); \ for (i = 0; check_tag_arg[i].tag; i++) { \ if (ctx->tag.len == check_tag_arg[i].taglen \ && strncasecmp(ctx->tag.c, check_tag_arg[i].tag, ctx->tag.len) == 0) { \ @@ -239,30 +239,13 @@ } #define HANDLE_ARG() {\ - smart_str_setl(&ctx->arg, start, YYCURSOR - start); \ + smart_str_copyl(&ctx->arg, start, YYCURSOR - start); \ } #define HANDLE_VAL(quotes) {\ smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); \ tag_arg(ctx PLS_CC); \ } -/* - * Since arg/tag are read-only during the mainloop, we do not need - * to copy them. We need those variables across multiple calls - * to url_adapt() though, but they point to a private buffer. So we - * copy them before leaving the mainloop() and restore them at - * the beginning. - */ - -#define MOVE_TO_CTX(X) \ - if (ctx->X.c) \ - smart_str_copyl(&ctx->c_##X, ctx->X.c, ctx->X.len); \ - else \ - smart_str_free(&ctx->c_##X) - -#define FETCH_FROM_CTX(X) \ - smart_str_setl(&ctx->X, ctx->c_##X.c, ctx->c_##X.len) - static inline void mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size_t newlen) { char *end, *q; @@ -271,15 +254,12 @@ int rest; PLS_FETCH(); - FETCH_FROM_CTX(arg); - FETCH_FROM_CTX(tag); - smart_str_appendl(&ctx->buf, newdata, newlen); YYCURSOR = ctx->buf.c; YYLIMIT = ctx->buf.c + ctx->buf.len; -#line 283 +#line 263 while(1) { @@ -301,14 +281,14 @@ if(yych != '<') goto yy4; yy2: yych = *++YYCURSOR; yy3: -#line 294 +#line 274 { PASSTHRU(); STATE = STATE_TAG; continue; } yy4: yych = *++YYCURSOR; yy5: -#line 295 +#line 275 { PASSTHRU(); continue; } } -#line 296 +#line 276 break; @@ -362,11 +342,11 @@ yy8: yych = *++YYCURSOR; goto yy13; yy9: -#line 301 +#line 281 { HANDLE_TAG() /* Sets STATE */; PASSTHRU(); continue; } yy10: yych = *++YYCURSOR; yy11: -#line 302 +#line 282 { PASSTHRU(); continue; } yy12: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -374,7 +354,7 @@ yy13: if(yybm[0+yych] & 128) goto yy12; goto yy9; } -#line 303 +#line 283 break; @@ -408,22 +388,22 @@ } yy16: yych = *++YYCURSOR; yy17: -#line 308 +#line 288 { PASSTHRU(); HANDLE_FORM(); STATE = STATE_PLAIN; continue; } yy18: yych = *++YYCURSOR; yy19: -#line 309 +#line 289 { PASSTHRU(); continue; } yy20: yych = *++YYCURSOR; yy21: -#line 310 +#line 290 { YYCURSOR--; STATE = STATE_ARG; continue; } yy22: yych = *++YYCURSOR; yy23: -#line 311 +#line 291 { PASSTHRU(); continue; } } -#line 312 +#line 292 break; @@ -477,11 +457,11 @@ yy26: yych = *++YYCURSOR; goto yy31; yy27: -#line 317 +#line 297 { PASSTHRU(); HANDLE_ARG(); STATE = STATE_BEFORE_VAL; continue; } yy28: yych = *++YYCURSOR; yy29: -#line 318 +#line 298 { PASSTHRU(); STATE = STATE_NEXT_ARG; continue; } yy30: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -489,7 +469,7 @@ yy31: if(yybm[0+yych] & 128) goto yy30; goto yy27; } -#line 319 +#line 299 case STATE_BEFORE_VAL: @@ -543,12 +523,12 @@ if(yych == ' ') goto yy41; if(yych == '=') goto yy39; yy35: -#line 324 +#line 304 { YYCURSOR--; STATE = STATE_NEXT_ARG; continue; } yy36: yych = *++YYCURSOR; goto yy40; yy37: -#line 323 +#line 303 { PASSTHRU(); STATE = STATE_VAL; continue; } yy38: yych = *++YYCURSOR; goto yy35; @@ -567,7 +547,7 @@ case 0: goto yy35; } } -#line 325 +#line 305 break; @@ -630,12 +610,12 @@ yych = *(YYMARKER = ++YYCURSOR); if(yych != '>') goto yy54; yy47: -#line 332 +#line 312 { PASSTHRU(); STATE = STATE_NEXT_ARG; continue; } yy48: yych = *++YYCURSOR; goto yy52; yy49: -#line 331 +#line 311 { HANDLE_VAL(0); STATE = STATE_NEXT_ARG; continue; } yy50: yych = *++YYCURSOR; goto yy47; @@ -655,10 +635,10 @@ } yy56: yych = *++YYCURSOR; yy57: -#line 330 +#line 310 { HANDLE_VAL(1); STATE = STATE_NEXT_ARG; continue; } } -#line 333 +#line 313 break; } @@ -669,9 +649,6 @@ printf("stopped in state %d at pos %d (%d:%c)\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR); #endif - MOVE_TO_CTX(tag); - MOVE_TO_CTX(arg); - rest = YYLIMIT - start; memmove(ctx->buf.c, start, rest); @@ -724,8 +701,8 @@ smart_str_free(&ctx->result); smart_str_free(&ctx->buf); - smart_str_free(&ctx->c_tag); - smart_str_free(&ctx->c_arg); + smart_str_free(&ctx->tag); + smart_str_free(&ctx->arg); return SUCCESS; }

« previous php.cvs (#1813) next »