[genius] Thu Mar 22 11:25:49 2012 Jiri (George) Lebl <jirka 5z com>



commit 09a6a77ad0e4d739cc81f4b3f5bf4c8a6eb3be95
Author: Jiri (George) Lebl <jirka 5z com>
Date:   Thu Mar 22 11:27:08 2012 -0500

    Thu Mar 22 11:25:49 2012  Jiri (George) Lebl <jirka 5z com>
    
    	* src/funclib.c: remove some redundant code, load the exp for
    	  matrices lazily

 ChangeLog     |    5 +++++
 src/funclib.c |   30 ++++++++++++++++++------------
 2 files changed, 23 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 644ce41..4f846b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Mar 22 11:25:49 2012  Jiri (George) Lebl <jirka 5z com>
+
+	* src/funclib.c: remove some redundant code, load the exp for
+	  matrices lazily
+
 Wed Mar 21 15:39:04 2012  Jiri (George) Lebl <jirka 5z com>
 
 	* src/*.[ch]: mark a bunch of functions as pure.  Probably doesn't
diff --git a/src/funclib.c b/src/funclib.c
index 2d0c18d..0f19714 100644
--- a/src/funclib.c
+++ b/src/funclib.c
@@ -40,7 +40,7 @@
 
 #include "binreloc.h"
 
-static GelEFunc *_internal_ln_function = NULL;
+/* FIXME:static GelEFunc *_internal_ln_function = NULL; */
 static GelEFunc *_internal_exp_function = NULL;
 
 static GelEFunc *conj_function = NULL;
@@ -1989,6 +1989,19 @@ exp_op(GelCtx *ctx, GelETree * * a, gboolean *exception)
 				      "exp");
 			return NULL;
 		}
+		if G_UNLIKELY (_internal_exp_function == NULL) {
+			_internal_exp_function = d_makeufunc(d_intern("<internal>exp"),
+							     gel_parseexp
+							     ("s = float(x^0); "
+							      "fact = 1; "
+							      "for i = 1 to 100 do "
+							      "(fact = fact * x / i; "
+							      "s = s + fact) ; s",
+							      NULL, FALSE, FALSE,
+							      NULL, NULL),
+							     g_slist_append(NULL,d_intern("x")),1,
+							     NULL);
+		}
 		return gel_funccall(ctx,_internal_exp_function,a,1);
 	}
 
@@ -6633,6 +6646,9 @@ gel_funclib_addall(void)
 	f->no_mod_all_args = 1;
 
 	/*temporary until well done internal functions are done*/
+	/* Search also for _internal_exp_function above, it's done on
+	 * demand */
+#if 0
 	_internal_ln_function = d_makeufunc(d_intern("<internal>ln"),
 					    /*FIXME:this is not the correct 
 					      function*/
@@ -6641,17 +6657,7 @@ gel_funclib_addall(void)
 							 NULL, NULL),
 					    g_slist_append(NULL,d_intern("x")),1,
 					    NULL);
-	_internal_exp_function = d_makeufunc(d_intern("<internal>exp"),
-					     gel_parseexp
-					     ("s = float(x^0); "
-					      "fact = 1; "
-					      "for i = 1 to 100 do "
-					      "(fact = fact * x / i; "
-					      "s = s + fact) ; s",
-					      NULL, FALSE, FALSE,
-					      NULL, NULL),
-					     g_slist_append(NULL,d_intern("x")),1,
-					     NULL);
+#endif
 
 	gel_add_symbolic_functions ();
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]