]> granicus.if.org Git - php/commitdiff
Remove this pseudo optimization from the previous rewrite.
authorSascha Schumann <sas@php.net>
Wed, 20 Sep 2000 08:13:45 +0000 (08:13 +0000)
committerSascha Schumann <sas@php.net>
Wed, 20 Sep 2000 08:13:45 +0000 (08:13 +0000)
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.

ext/standard/url_scanner_ex.c
ext/standard/url_scanner_ex.h
ext/standard/url_scanner_ex.re

index cd44d0fa3fb9f7bae9c2ee5a899d91e176fe9da0..02a0cc473f75bf2e466e7cedce77248421917140 100644 (file)
@@ -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 @@ enum {
 #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 @@ enum {
 }
 
 #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 @@ static inline void mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size
        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 @@ yy0:
        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 @@ yy6:
 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 @@ yy12:       ++YYCURSOR;
 yy13:  if(yybm[0+yych] & 128)  goto yy12;
        goto yy9;
 }
-#line 303
+#line 283
 
                        break;
                        
@@ -408,22 +388,22 @@ yy14:
        }
 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 @@ yy24:
 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 @@ yy30:       ++YYCURSOR;
 yy31:  if(yybm[0+yych] & 128)  goto yy30;
        goto yy27;
 }
-#line 319
+#line 299
 
 
                case STATE_BEFORE_VAL:
@@ -543,12 +523,12 @@ yy34:     yyaccept = 0;
        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 @@ yy43:       YYCURSOR = YYMARKER;
        case 0: goto yy35;
        }
 }
-#line 325
+#line 305
 
                        break;
 
@@ -630,12 +610,12 @@ yy46:     yyaccept = 0;
        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 @@ yy55:     YYCURSOR = YYMARKER;
        }
 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 @@ stop:
        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 @@ PHP_RSHUTDOWN_FUNCTION(url_scanner)
 
        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 0199b2bd6d30122295323cf3a8483b47907b2f05..89923265380fe42f496f9871b2d22dbd3532b3cd 100644 (file)
@@ -38,10 +38,6 @@ typedef struct {
        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 e01a491938c57e2f55cbb2990ee301e1576896c8..6e22dd476225d408a61a0637ed2691fbc842ce7c 100644 (file)
@@ -225,7 +225,7 @@ enum {
 #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 @@ enum {
 }
 
 #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 @@ static inline void mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size
        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 @@ stop:
        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 @@ PHP_RSHUTDOWN_FUNCTION(url_scanner)
 
        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;
 }