diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-17 10:09:12 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-17 10:09:12 -0300 |
| commit | 4fb8e93c36f3a38bd5041650361d820898122532 (patch) | |
| tree | 36b6351cb796491e57632fac2e049245340535b0 | |
| parent | 7f774319504c0c56ee7efd3337a5c5a4074526c2 (diff) | |
| download | lua-4fb8e93c36f3a38bd5041650361d820898122532.tar.gz lua-4fb8e93c36f3a38bd5041650361d820898122532.tar.bz2 lua-4fb8e93c36f3a38bd5041650361d820898122532.zip | |
small optimization for i..''
| -rw-r--r-- | lvm.c | 12 |
1 files changed, 4 insertions, 8 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 1.94 2000/03/10 14:38:10 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.95 2000/03/10 18:37:44 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -258,18 +258,14 @@ int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r, StkId top) | |||
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | 260 | ||
| 261 | #define setbool(o,cond) if (cond) { \ | ||
| 262 | ttype(o) = TAG_NUMBER; nvalue(o) = 1.0; } \ | ||
| 263 | else ttype(o) = TAG_NIL | ||
| 264 | |||
| 265 | |||
| 266 | static void strconc (lua_State *L, int total, StkId top) { | 261 | static void strconc (lua_State *L, int total, StkId top) { |
| 267 | do { | 262 | do { |
| 268 | int n = 2; /* number of elements handled in this pass (at least 2) */ | 263 | int n = 2; /* number of elements handled in this pass (at least 2) */ |
| 269 | if (tostring(L, top-2) || tostring(L, top-1)) | 264 | if (tostring(L, top-2) || tostring(L, top-1)) |
| 270 | call_binTM(L, top, IM_CONCAT, "unexpected type for concatenation"); | 265 | call_binTM(L, top, IM_CONCAT, "unexpected type for concatenation"); |
| 271 | else { /* at least two string values; get as many as possible */ | 266 | else if (tsvalue(top-1)->u.s.len > 0) { /* if len=0, do nothing */ |
| 272 | long tl = tsvalue(top-2)->u.s.len + tsvalue(top-1)->u.s.len; | 267 | /* at least two string values; get as many as possible */ |
| 268 | long tl = tsvalue(top-1)->u.s.len + tsvalue(top-2)->u.s.len; | ||
| 273 | char *buffer; | 269 | char *buffer; |
| 274 | int i; | 270 | int i; |
| 275 | while (n < total && !tostring(L, top-n-1)) { /* collect total length */ | 271 | while (n < total && !tostring(L, top-n-1)) { /* collect total length */ |
