Browse code

core expr: optimize $v==""

- optimize $v="" to strempty($v) (slightly faster)

Andrei Pelinescu-Onciul authored on 24/04/2009 13:35:17
Showing 1 changed files
... ...
@@ -2479,6 +2479,18 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
2479 2479
 					ret=1;
2480 2480
 				}
2481 2481
 				break;
2482
+			case RVE_EQ_OP:
2483
+				if (rv->v.s.len==0){
2484
+					/* $v == "" -> strempty($v) 
2485
+					   "" == $v -> strempty ($v) */
2486
+					rve_destroy(ct_rve);
2487
+					/* replace current expr. with strempty(rve) */
2488
+					rve->op=RVE_STREMPTY_OP;
2489
+					rve->left.rve=v_rve;
2490
+					rve->right.rve=0;
2491
+					ret=1;
2492
+				}
2493
+				break;
2482 2494
 			default:
2483 2495
 				break;
2484 2496
 		}