plot unref improvement and removed debug messages - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
diff options
context:
space:
mode:
authorfrancesco-ST <francesco.abbate@st.com>2010年07月08日 13:54:59 +0200
committerfrancesco-ST <francesco.abbate@st.com>2010年07月08日 13:54:59 +0200
commitd4ba2e23123520fa9ee32e690465c55291175863 (patch)
tree029734db039044b4eb9c9f8cbfe5917f4b1f5b3d
parent6089a3871d1cf7b4e3148210356043c145568004 (diff)
downloadgsl-shell-d4ba2e23123520fa9ee32e690465c55291175863.tar.gz
plot unref improvement and removed debug messages
Diffstat
-rw-r--r--agg-plot/lua-draw.cpp 1
-rw-r--r--agg-plot/lua-plot.cpp 1
-rw-r--r--agg-plot/xwin-show.cpp 1
-rw-r--r--gsl-shell.c 43
-rw-r--r--lua-utils.c 3
5 files changed, 27 insertions, 22 deletions
diff --git a/agg-plot/lua-draw.cpp b/agg-plot/lua-draw.cpp
index 4c6ae9d3..d812d7ea 100644
--- a/agg-plot/lua-draw.cpp
+++ b/agg-plot/lua-draw.cpp
@@ -116,7 +116,6 @@ agg_path_free (lua_State *L)
{
typedef my::path path_type;
path_type *path = check_agg_path (L, 1);
- printf("freeing PATH %p\n", (void *) path);
path->~path_type();
return 0;
}
diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp
index ea3b1944..f0993db9 100644
--- a/agg-plot/lua-plot.cpp
+++ b/agg-plot/lua-plot.cpp
@@ -167,7 +167,6 @@ int
agg_plot_free (lua_State *L)
{
agg_plot *p = agg_plot::arg_check(L, 1);
- printf("freeing plot\n");
p->~agg_plot();
return 0;
}
diff --git a/agg-plot/xwin-show.cpp b/agg-plot/xwin-show.cpp
index 05692340..25cd6bee 100644
--- a/agg-plot/xwin-show.cpp
+++ b/agg-plot/xwin-show.cpp
@@ -91,7 +91,6 @@ xwin_thread_function (void *_plot)
AGG_UNLOCK();
GSL_SHELL_LOCK();
- printf("unref plot\n");
gsl_shell_unref_plot (p->id);
GSL_SHELL_UNLOCK();
}
diff --git a/gsl-shell.c b/gsl-shell.c
index efbaa18b..a4647d19 100644
--- a/gsl-shell.c
+++ b/gsl-shell.c
@@ -70,6 +70,10 @@ struct window_unref_cell {
struct window_unref_cell *next;
};
+#define UNREF_FIXED_SIZE 8
+static int unref_fixed_list[UNREF_FIXED_SIZE];
+static size_t unref_fixed_count = 0;
+
static struct window_unref_cell *window_unref_list = NULL;
static lua_State *globalL = NULL;
@@ -329,6 +333,8 @@ static void dotty (lua_State *L) {
{
struct window_unref_cell *wu;
int status = loadline(L);
+ size_t j;
+
if (status == -1)
break;
if (status == 0)
@@ -346,6 +352,12 @@ static void dotty (lua_State *L) {
}
}
GSL_SHELL_LOCK();
+
+ for (j = 0; j < unref_fixed_count; j++)
+ mlua_window_unref (L, unref_fixed_list[j]);
+
+ unref_fixed_count = 0;
+
for (wu = window_unref_list; wu != NULL; /* */)
{
struct window_unref_cell *nxt = wu->next;
@@ -354,22 +366,9 @@ static void dotty (lua_State *L) {
wu = nxt;
}
window_unref_list = NULL;
+
GSL_SHELL_UNLOCK();
}
-#if 0
- while ((status = loadline(L)) != -1) {
- if (status == 0) status = docall(L, 0, 0);
- report(L, status);
- if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */
- lua_getglobal(L, "print");
- lua_insert(L, 1);
- if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0)
- l_message(progname, lua_pushfstring(L,
- "error calling " LUA_QL("print") " (%s)",
- lua_tostring(L, -1)));
- }
- }
-#endif
lua_settop(L, 0); /* clear stack */
fputs("\n", stdout);
fflush(stdout);
@@ -551,10 +550,18 @@ int main (int argc, char **argv) {
void
gsl_shell_unref_plot (int id)
{
- struct window_unref_cell *cell = malloc(sizeof(struct window_unref_cell));
+ if (unref_fixed_count < UNREF_FIXED_SIZE)
+ {
+ unref_fixed_list[unref_fixed_count] = id;
+ unref_fixed_count ++;
+ }
+ else
+ {
+ struct window_unref_cell *cell = malloc(sizeof(struct window_unref_cell));
- cell->id = id;
- cell->next = window_unref_list;
+ cell->id = id;
+ cell->next = window_unref_list;
- window_unref_list = cell;
+ window_unref_list = cell;
+ }
}
diff --git a/lua-utils.c b/lua-utils.c
index e385339d..01565177 100644
--- a/lua-utils.c
+++ b/lua-utils.c
@@ -218,15 +218,16 @@ mlua_fenv_addref (lua_State *L, int refindex)
lua_pop (L, 1);
}
+#if 0
void
mlua_set_fenv_ref (lua_State *L, int refindex)
{
- int n;
lua_newtable (L);
lua_pushvalue (L, refindex);
lua_rawseti (L, -2, 1);
lua_setfenv (L, -2);
}
+#endif
void
prepare_window_ref_table (lua_State *L)
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月24日 22:54:54 +0000

AltStyle によって変換されたページ (->オリジナル) /