removed field 'n' from 'CallInfo' (not being used right now)

This commit is contained in:
Roberto Ierusalimschy 2015-11-13 10:16:51 -02:00
parent 04587b6256
commit 89e3a84344
2 changed files with 12 additions and 16 deletions

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lstate.c,v 2.131 2015/10/20 13:11:05 roberto Exp roberto $ ** $Id: lstate.c,v 2.132 2015/11/02 16:01:41 roberto Exp roberto $
** Global State ** Global State
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -111,7 +111,7 @@ CallInfo *luaE_extendCI (lua_State *L) {
L->ci->next = ci; L->ci->next = ci;
ci->previous = L->ci; ci->previous = L->ci;
ci->next = NULL; ci->next = NULL;
ci->n = ++L->nci; L->nci++;
return ci; return ci;
} }
@ -126,8 +126,8 @@ void luaE_freeCI (lua_State *L) {
while ((ci = next) != NULL) { while ((ci = next) != NULL) {
next = ci->next; next = ci->next;
luaM_free(L, ci); luaM_free(L, ci);
L->nci--;
} }
L->nci = L->ci->n;
} }
@ -136,17 +136,15 @@ void luaE_freeCI (lua_State *L) {
*/ */
void luaE_shrinkCI (lua_State *L) { void luaE_shrinkCI (lua_State *L) {
CallInfo *ci = L->ci; CallInfo *ci = L->ci;
CallInfo *next; CallInfo *next2; /* next's next */
int n = (L->nci - ci->n + 1)/2; /* number of entries to be preserved */ /* while there are two nexts */
for (; n > 0; n--) while (ci->next != NULL && (next2 = ci->next->next) != NULL) {
ci = ci->next; /* skip items to be preserved */ luaM_free(L, ci->next); /* free next */
lua_assert(n == 0); L->nci--;
while ((next = ci->next) != NULL) { /* remove all other items */ ci->next = next2; /* remove 'next' from the list */
ci->next = next->next; next2->previous = ci;
luaM_free(L, next); /* remove item */ ci = next2; /* keep next's next */
n++; /* count number of removed items */
} }
L->nci -= n;
} }
@ -161,7 +159,6 @@ static void stack_init (lua_State *L1, lua_State *L) {
L1->stack_last = L1->stack + L1->stacksize - EXTRA_STACK; L1->stack_last = L1->stack + L1->stacksize - EXTRA_STACK;
/* initialize first ci */ /* initialize first ci */
ci = &L1->base_ci; ci = &L1->base_ci;
ci->n = 0;
ci->next = ci->previous = NULL; ci->next = ci->previous = NULL;
ci->callstatus = 0; ci->callstatus = 0;
ci->func = L1->top; ci->func = L1->top;

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lstate.h,v 2.126 2015/11/02 11:43:17 roberto Exp roberto $ ** $Id: lstate.h,v 2.127 2015/11/02 16:01:41 roberto Exp roberto $
** Global State ** Global State
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -78,7 +78,6 @@ typedef struct CallInfo {
} c; } c;
} u; } u;
ptrdiff_t extra; ptrdiff_t extra;
unsigned short n; /* ordinal number in call list */
short nresults; /* expected number of results from this function */ short nresults; /* expected number of results from this function */
lu_byte callstatus; lu_byte callstatus;
} CallInfo; } CallInfo;