table field names for dedicated opcodes can be restricted to

small strings for slightly faster access
This commit is contained in:
Roberto Ierusalimschy 2017-05-18 16:44:19 -03:00
parent 92b3deaffa
commit de74289049
2 changed files with 8 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lcode.c,v 2.117 2017/04/26 17:46:52 roberto Exp roberto $ ** $Id: lcode.c,v 2.118 2017/04/28 20:57:45 roberto Exp roberto $
** Code generator for Lua ** Code generator for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -978,11 +978,11 @@ static void codenot (FuncState *fs, expdesc *e) {
/* /*
** Check whether expression 'e' is a literal string ** Check whether expression 'e' is a small literal string
*/ */
static int isKstr (FuncState *fs, expdesc *e) { static int isKstr (FuncState *fs, expdesc *e) {
return (e->k == VK && !hasjumps(e) && e->u.info <= MAXARG_C && return (e->k == VK && !hasjumps(e) && e->u.info <= MAXARG_C &&
ttisstring(&fs->f->k[e->u.info])); ttisshrstring(&fs->f->k[e->u.info]));
} }

10
lvm.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lvm.c,v 2.282 2017/05/13 13:54:47 roberto Exp roberto $ ** $Id: lvm.c,v 2.283 2017/05/18 19:34:39 roberto Exp roberto $
** Lua virtual machine ** Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -865,7 +865,7 @@ void luaV_execute (lua_State *L) {
TValue *upval = cl->upvals[GETARG_B(i)]->v; TValue *upval = cl->upvals[GETARG_B(i)]->v;
TValue *rc = KC(i); TValue *rc = KC(i);
TString *key = tsvalue(rc); /* key must be a string */ TString *key = tsvalue(rc); /* key must be a string */
if (luaV_fastget(L, upval, key, slot, luaH_getstr)) { if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
setobj2s(L, ra, slot); setobj2s(L, ra, slot);
} }
else Protect(luaV_finishget(L, upval, rc, ra, slot)); else Protect(luaV_finishget(L, upval, rc, ra, slot));
@ -904,7 +904,7 @@ void luaV_execute (lua_State *L) {
StkId rb = RB(i); StkId rb = RB(i);
TValue *rc = KC(i); TValue *rc = KC(i);
TString *key = tsvalue(rc); /* key must be a string */ TString *key = tsvalue(rc); /* key must be a string */
if (luaV_fastget(L, rb, key, slot, luaH_getstr)) { if (luaV_fastget(L, rb, key, slot, luaH_getshortstr)) {
setobj2s(L, ra, slot); setobj2s(L, ra, slot);
} }
else Protect(luaV_finishget(L, rb, rc, ra, slot)); else Protect(luaV_finishget(L, rb, rc, ra, slot));
@ -916,7 +916,7 @@ void luaV_execute (lua_State *L) {
TValue *rb = KB(i); TValue *rb = KB(i);
TValue *rc = RKC(i); TValue *rc = RKC(i);
TString *key = tsvalue(rb); /* key must be a string */ TString *key = tsvalue(rb); /* key must be a string */
if (luaV_fastget(L, upval, key, slot, luaH_getstr)) if (luaV_fastget(L, upval, key, slot, luaH_getshortstr))
luaV_finishfastset(L, upval, slot, rc); luaV_finishfastset(L, upval, slot, rc);
else else
Protect(luaV_finishset(L, upval, rb, rc, slot)); Protect(luaV_finishset(L, upval, rb, rc, slot));
@ -953,7 +953,7 @@ void luaV_execute (lua_State *L) {
TValue *rb = KB(i); TValue *rb = KB(i);
TValue *rc = RKC(i); TValue *rc = RKC(i);
TString *key = tsvalue(rb); /* key must be a string */ TString *key = tsvalue(rb); /* key must be a string */
if (luaV_fastget(L, ra, key, slot, luaH_getstr)) if (luaV_fastget(L, ra, key, slot, luaH_getshortstr))
luaV_finishfastset(L, ra, slot, rc); luaV_finishfastset(L, ra, slot, rc);
else else
Protect(luaV_finishset(L, ra, rb, rc, slot)); Protect(luaV_finishset(L, ra, rb, rc, slot));