genius r639 - in trunk: . src
- From: jirka svn gnome org
- To: svn-commits-list gnome org
- Subject: genius r639 - in trunk: . src
- Date: Sat, 12 Jan 2008 21:04:19 +0000 (GMT)
Author: jirka
Date: Sat Jan 12 21:04:19 2008
New Revision: 639
URL: http://svn.gnome.org/viewvc/genius?rev=639&view=rev
Log:
Sat Jan 12 15:03:19 2008 Jiri (George) Lebl <jirka 5z com>
* src/eval.c: make internal function calling a bit faster. Can be
noticeable (tested 10% on fast operations)
* src/funclib.c: fix memory leak
Modified:
trunk/ChangeLog
trunk/src/eval.c
trunk/src/funclib.c
Modified: trunk/src/eval.c
==============================================================================
--- trunk/src/eval.c (original)
+++ trunk/src/eval.c Sat Jan 12 21:04:19 2008
@@ -169,8 +169,8 @@
}
#else /* MEM_DEBUG_FRIENDLY */
#define GE_BLIND_POP_STACK(thectx) { \
- if GE_LIKELY ((thectx)->topstack != (gpointer *)(thectx)->stack || \
- ge_remove_stack_array(thectx)) { \
+ if G_LIKELY ((thectx)->topstack != (gpointer *)(thectx)->stack || \
+ ge_remove_stack_array(thectx)) { \
(thectx)->topstack -= 2; \
} \
}
@@ -4509,8 +4509,6 @@
if (f == NULL)
goto funccall_done_ok;
- g_assert(f);
-
if G_UNLIKELY ((f->vararg && f->nargs > n->op.nargs) ||
(! f->vararg && f->nargs != n->op.nargs - 1)) {
if ( ! f->vararg)
@@ -4523,8 +4521,13 @@
"(should be greater than %d)"),
f->id != NULL ? f->id->token : "anonymous",
f->nargs-2);
- } else if(f->type == GEL_USER_FUNC ||
- f->type == GEL_VARIABLE_FUNC) {
+ goto funccall_done_ok;
+ }
+
+ switch (f->type) {
+ case GEL_USER_FUNC:
+ case GEL_VARIABLE_FUNC:
+ {
GSList *li;
GelETree *ali;
GelToken *last_arg = NULL;
@@ -4635,7 +4638,9 @@
/*exit without popping the stack as we don't want to do that*/
return TRUE;
- } else if(f->type == GEL_BUILTIN_FUNC) {
+ }
+ case GEL_BUILTIN_FUNC:
+ {
gboolean exception = FALSE;
GelETree *ret;
mpw_ptr old_modulo;
@@ -4649,11 +4654,7 @@
GelETree **r;
GelETree *li;
int i;
-#ifdef MEM_DEBUG_FRIENDLY
- r = g_new0 (GelETree *, n->op.nargs);
-#else
- r = g_new (GelETree *, n->op.nargs);
-#endif
+ r = g_alloca (sizeof (GelETree *) * n->op.nargs);
for(i=0,li=n->op.args->any.next;li;i++,li=li->any.next)
r[i] = li;
r[i] = NULL;
@@ -4667,10 +4668,6 @@
*/
ret = (*f->data.func)(ctx,r,&exception);
-#ifdef MEM_DEBUG_FRIENDLY
- memset (r, 0xaa, sizeof(GelETree *) * n->op.nargs);
-#endif
- g_free (r);
} else {
ret = (*f->data.func)(ctx,NULL,&exception);
}
@@ -4692,7 +4689,10 @@
mod_node (ret, ctx->modulo);
replacenode (n, ret);
}
- } else if(f->type == GEL_REFERENCE_FUNC) {
+ break;
+ }
+ case GEL_REFERENCE_FUNC:
+ {
GelETree *id;
if G_UNLIKELY (f->nargs > 0) {
gel_errorout (_("Reference function with arguments encountered!"));
@@ -4715,8 +4715,11 @@
n->op.args = id;
n->op.nargs = 1;
- } else {
+ break;
+ }
+ default:
gel_errorout (_("Unevaluatable function type encountered!"));
+ break;
}
funccall_done_ok:
iter_pop_stack(ctx);
Modified: trunk/src/funclib.c
==============================================================================
--- trunk/src/funclib.c (original)
+++ trunk/src/funclib.c Sat Jan 12 21:04:19 2008
@@ -2923,8 +2923,10 @@
}
}
- if (nml <= 0)
+ if (nml <= 0) {
+ g_free (index);
return gel_makenum_null ();
+ }
nm = gel_matrix_new ();
gel_matrix_set_size (nm, nml, 1, FALSE /* padding */);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]