[genius] Tue Dec 18 20:49:50 2012 Jiri (George) Lebl <jirka 5z com>



commit 1703693faa6a11397feb4326482da05e313256d8
Author: Jiri (George) Lebl <jirka 5z com>
Date:   Tue Dec 18 20:50:10 2012 -0600

    Tue Dec 18 20:49:50 2012  Jiri (George) Lebl <jirka 5z com>
    
    	* src/mpwrap.c, src/calc.c: make a minor optimization, and remove an
    	  unsafe unnecessary one

 ChangeLog    |    5 +++++
 src/calc.c   |    5 -----
 src/mpwrap.c |   21 ++++++++++++---------
 3 files changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8378a3c..ea8c255 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Dec 18 20:49:50 2012  Jiri (George) Lebl <jirka 5z com>
+
+	* src/mpwrap.c, src/calc.c: make a minor optimization, and remove an
+	  unsafe unnecessary one
+
 Mon Dec 17 15:15:44 2012  Jiri (George) Lebl <jirka 5z com>
 
 	* src/graphing.c: bit of post release cleanup
diff --git a/src/calc.c b/src/calc.c
index 24f127b..9b97d9a 100644
--- a/src/calc.c
+++ b/src/calc.c
@@ -163,7 +163,6 @@ get_category (const char *category, gboolean insert)
  * not really needed to be done fast, but during startup it is done many times
  */
 static GelHelp *get_help_cache = NULL;
-static const char *get_help_func_cache = NULL;
 
 GelHelp *
 gel_get_help (const char *func, gboolean insert)
@@ -171,9 +170,6 @@ gel_get_help (const char *func, gboolean insert)
 	GelHelp *help;
 
 	if (get_help_cache != NULL &&
-	    /* just checking pointers is not safe, but it is fast,
-	     * if pointers are same it is likely the string will be the same */
-	    get_help_func_cache == func &&
 	    strcmp (get_help_cache->func, func) == 0)
 		return get_help_cache;
 
@@ -189,7 +185,6 @@ gel_get_help (const char *func, gboolean insert)
 	}
 
 	if (help != NULL) {
-		get_help_func_cache = func;
 		get_help_cache = help;
 	}
 
diff --git a/src/mpwrap.c b/src/mpwrap.c
index 8e234e4..58a091a 100644
--- a/src/mpwrap.c
+++ b/src/mpwrap.c
@@ -3256,15 +3256,18 @@ mpw_clear(mpw_ptr op)
 
 /*make them the same type without loosing information*/
 void
-mpw_make_same_type(mpw_ptr op1,mpw_ptr op2)
-{
-	MAKE_COPY(op1->r);
-	MAKE_COPY(op2->r);
-	mpwl_make_same_type(op1->r,op2->r);
-	if (MPW_IS_COMPLEX (op1) || MPW_IS_COMPLEX (op2)) {
-		MAKE_COPY(op1->i);
-		MAKE_COPY(op2->i);
-		mpwl_make_same_type(op1->i,op2->i);
+mpw_make_same_type (mpw_ptr op1, mpw_ptr op2)
+{
+	if (op1->r->type != op2->r->type) {
+		MAKE_COPY (op1->r);
+		MAKE_COPY (op2->r);
+		mpwl_make_same_type (op1->r, op2->r);
+	}
+	if ((MPW_IS_COMPLEX (op1) || MPW_IS_COMPLEX (op2)) &&
+	    (op1->i->type != op2->i->type)) {
+		MAKE_COPY (op1->i);
+		MAKE_COPY (op2->i);
+		mpwl_make_same_type (op1->i, op2->i);
 	}
 }
 



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