[SR-Dev] git:master: core expr: optimize $v==""

Andrei Pelinescu-Onciul andrei at iptel.org
Fri Apr 24 21:52:44 CEST 2009


Module: sip-router
Branch: master
Commit: fe8ef674f5c5bdc72ecb1616537750d9a791854f
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=fe8ef674f5c5bdc72ecb1616537750d9a791854f

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Fri Apr 24 15:35:17 2009 +0200

core expr: optimize $v==""

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

---

 rvalue.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/rvalue.c b/rvalue.c
index 74e8df5..2179844 100644
--- 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;
 		}




More information about the sr-dev mailing list