core expr: optimize $v==""
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 24 Apr 2009 13:35:17 +0000 (15:35 +0200)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 24 Apr 2009 19:51:46 +0000 (21:51 +0200)
- optimize $v="" to strempty($v) (slightly faster)

rvalue.c

index 74e8df5..2179844 100644 (file)
--- a/rvalue.c
+++ b/rvalue.c
@@ -2479,6 +2479,18 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
                                        ret=1;
                                }
                                break;
+                       case RVE_EQ_OP:
+                               if (rv->v.s.len==0){
+                                       /* $v == "" -> strempty($v) 
+                                          "" == $v -> strempty ($v) */
+                                       rve_destroy(ct_rve);
+                                       /* replace current expr. with strempty(rve) */
+                                       rve->op=RVE_STREMPTY_OP;
+                                       rve->left.rve=v_rve;
+                                       rve->right.rve=0;
+                                       ret=1;
+                               }
+                               break;
                        default:
                                break;
                }