diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-08-16 14:34:28 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-08-16 14:34:28 -0300 |
| commit | a3e1c40d6d6fb81db9d8b58aee69466f715aab5c (patch) | |
| tree | ea11a028d8d92772ad97879c7bc5bbe50318bbea /lobject.c | |
| parent | c1a2a646c81000b03a243cbdeba9c4bd6dd7b474 (diff) | |
| download | lua-a3e1c40d6d6fb81db9d8b58aee69466f715aab5c.tar.gz lua-a3e1c40d6d6fb81db9d8b58aee69466f715aab5c.tar.bz2 lua-a3e1c40d6d6fb81db9d8b58aee69466f715aab5c.zip | |
remove of unecessary luaD_checkstack. (In some cases, C should
ensure stack space; in others, Lua can use the extra slots for
temporary values.)
Diffstat (limited to 'lobject.c')
| -rw-r--r-- | lobject.c | 16 |
1 files changed, 7 insertions, 9 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.c,v 2.54 2011/11/30 12:44:26 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.55 2011/11/30 19:30:16 roberto Exp roberto $ |
| 3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -171,8 +171,7 @@ int luaO_str2d (const char *s, size_t len, lua_Number *result) { | |||
| 171 | 171 | ||
| 172 | 172 | ||
| 173 | static void pushstr (lua_State *L, const char *str, size_t l) { | 173 | static void pushstr (lua_State *L, const char *str, size_t l) { |
| 174 | setsvalue2s(L, L->top, luaS_newlstr(L, str, l)); | 174 | setsvalue2s(L, L->top++, luaS_newlstr(L, str, l)); |
| 175 | incr_top(L); | ||
| 176 | } | 175 | } |
| 177 | 176 | ||
| 178 | 177 | ||
| @@ -182,8 +181,8 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { | |||
| 182 | for (;;) { | 181 | for (;;) { |
| 183 | const char *e = strchr(fmt, '%'); | 182 | const char *e = strchr(fmt, '%'); |
| 184 | if (e == NULL) break; | 183 | if (e == NULL) break; |
| 185 | setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); | 184 | luaD_checkstack(L, 2); /* fmt + item */ |
| 186 | incr_top(L); | 185 | pushstr(L, fmt, e - fmt); |
| 187 | switch (*(e+1)) { | 186 | switch (*(e+1)) { |
| 188 | case 's': { | 187 | case 's': { |
| 189 | const char *s = va_arg(argp, char *); | 188 | const char *s = va_arg(argp, char *); |
| @@ -198,13 +197,11 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { | |||
| 198 | break; | 197 | break; |
| 199 | } | 198 | } |
| 200 | case 'd': { | 199 | case 'd': { |
| 201 | setnvalue(L->top, cast_num(va_arg(argp, int))); | 200 | setnvalue(L->top++, cast_num(va_arg(argp, int))); |
| 202 | incr_top(L); | ||
| 203 | break; | 201 | break; |
| 204 | } | 202 | } |
| 205 | case 'f': { | 203 | case 'f': { |
| 206 | setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); | 204 | setnvalue(L->top++, cast_num(va_arg(argp, l_uacNumber))); |
| 207 | incr_top(L); | ||
| 208 | break; | 205 | break; |
| 209 | } | 206 | } |
| 210 | case 'p': { | 207 | case 'p': { |
| @@ -226,6 +223,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { | |||
| 226 | n += 2; | 223 | n += 2; |
| 227 | fmt = e+2; | 224 | fmt = e+2; |
| 228 | } | 225 | } |
| 226 | luaD_checkstack(L, 1); | ||
| 229 | pushstr(L, fmt, strlen(fmt)); | 227 | pushstr(L, fmt, strlen(fmt)); |
| 230 | if (n > 0) luaV_concat(L, n + 1); | 228 | if (n > 0) luaV_concat(L, n + 1); |
| 231 | return svalue(L->top - 1); | 229 | return svalue(L->top - 1); |
