diff lwlib/lw_expr.h @ 337:3b5a45c6ab92

Speed improvement to lw_expr Instead of using a singly linked list and doing the slow append algorithm when adding an operand to an expression (scan from the start to find the end), now maintain a tail pointer. Also maintain a previous pointer in each entry. Benchmarking suggests this yields a rougly 30% improvement in runtime. Also refactor some of the code in lw_expr.c to make it somewhat clearer to understand. For some values of clearer and understand.
author William Astle <lost@l-w.ca>
date Sat, 02 Aug 2014 10:08:01 -0600
parents 1f1a28b797e1
children 6138e304ab9a
line wrap: on
line diff
--- a/lwlib/lw_expr.h	Thu Jul 31 17:20:11 2014 -0600
+++ b/lwlib/lw_expr.h	Sat Aug 02 10:08:01 2014 -0600
@@ -58,6 +58,7 @@
 {
 	lw_expr_t p;
 	struct lw_expr_opers *next;
+	struct lw_expr_opers *prev;
 };
 
 struct lw_expr_priv
@@ -66,6 +67,7 @@
 	int value;							// integer value
 	void *value2;						// misc pointer value
 	struct lw_expr_opers *operands;		// ptr to list of operands (for operators)
+	struct lw_expr_opers *operand_tail;	// ptr to last operand
 };
 
 typedef lw_expr_t lw_expr_fn_t(int t, void *ptr, void *priv);