mirror of
https://github.com/lua/lua
synced 2024-11-21 20:31:22 +03:00
Details
- Better comments about short strings in opcodes. - luaH_newkey made static.
This commit is contained in:
parent
6443185167
commit
934e77a286
7
lcode.c
7
lcode.c
@ -1215,7 +1215,7 @@ static void codenot (FuncState *fs, expdesc *e) {
|
||||
|
||||
|
||||
/*
|
||||
** Check whether expression 'e' is a small literal string
|
||||
** Check whether expression 'e' is a short literal string
|
||||
*/
|
||||
static int isKstr (FuncState *fs, expdesc *e) {
|
||||
return (e->k == VK && !hasjumps(e) && e->u.info <= MAXARG_B &&
|
||||
@ -1283,15 +1283,16 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
|
||||
if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */
|
||||
luaK_exp2anyreg(fs, t); /* put it in a register */
|
||||
if (t->k == VUPVAL) {
|
||||
lua_assert(isKstr(fs, k));
|
||||
t->u.ind.t = t->u.info; /* upvalue index */
|
||||
t->u.ind.idx = k->u.info; /* literal string */
|
||||
t->u.ind.idx = k->u.info; /* literal short string */
|
||||
t->k = VINDEXUP;
|
||||
}
|
||||
else {
|
||||
/* register index of the table */
|
||||
t->u.ind.t = (t->k == VLOCAL) ? t->u.var.ridx: t->u.info;
|
||||
if (isKstr(fs, k)) {
|
||||
t->u.ind.idx = k->u.info; /* literal string */
|
||||
t->u.ind.idx = k->u.info; /* literal short string */
|
||||
t->k = VINDEXSTR;
|
||||
}
|
||||
else if (isCint(k)) {
|
||||
|
@ -210,15 +210,15 @@ OP_LOADNIL,/* A B R[A], R[A+1], ..., R[A+B] := nil */
|
||||
OP_GETUPVAL,/* A B R[A] := UpValue[B] */
|
||||
OP_SETUPVAL,/* A B UpValue[B] := R[A] */
|
||||
|
||||
OP_GETTABUP,/* A B C R[A] := UpValue[B][K[C]:string] */
|
||||
OP_GETTABUP,/* A B C R[A] := UpValue[B][K[C]:shortstring] */
|
||||
OP_GETTABLE,/* A B C R[A] := R[B][R[C]] */
|
||||
OP_GETI,/* A B C R[A] := R[B][C] */
|
||||
OP_GETFIELD,/* A B C R[A] := R[B][K[C]:string] */
|
||||
OP_GETFIELD,/* A B C R[A] := R[B][K[C]:shortstring] */
|
||||
|
||||
OP_SETTABUP,/* A B C UpValue[A][K[B]:string] := RK(C) */
|
||||
OP_SETTABUP,/* A B C UpValue[A][K[B]:shortstring] := RK(C) */
|
||||
OP_SETTABLE,/* A B C R[A][R[B]] := RK(C) */
|
||||
OP_SETI,/* A B C R[A][B] := RK(C) */
|
||||
OP_SETFIELD,/* A B C R[A][K[B]:string] := RK(C) */
|
||||
OP_SETFIELD,/* A B C R[A][K[B]:shortstring] := RK(C) */
|
||||
|
||||
OP_NEWTABLE,/* A B C k R[A] := {} */
|
||||
|
||||
|
3
ltable.c
3
ltable.c
@ -662,7 +662,8 @@ static Node *getfreepos (Table *t) {
|
||||
** put new key in its main position; otherwise (colliding node is in its main
|
||||
** position), new key goes to an empty position.
|
||||
*/
|
||||
void luaH_newkey (lua_State *L, Table *t, const TValue *key, TValue *value) {
|
||||
static void luaH_newkey (lua_State *L, Table *t, const TValue *key,
|
||||
TValue *value) {
|
||||
Node *mp;
|
||||
TValue aux;
|
||||
if (l_unlikely(ttisnil(key)))
|
||||
|
2
ltable.h
2
ltable.h
@ -41,8 +41,6 @@ LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key,
|
||||
LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key);
|
||||
LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
|
||||
LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
|
||||
LUAI_FUNC void luaH_newkey (lua_State *L, Table *t, const TValue *key,
|
||||
TValue *value);
|
||||
LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key,
|
||||
TValue *value);
|
||||
LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key,
|
||||
|
8
lvm.c
8
lvm.c
@ -1253,7 +1253,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
||||
const TValue *slot;
|
||||
TValue *upval = cl->upvals[GETARG_B(i)]->v.p;
|
||||
TValue *rc = KC(i);
|
||||
TString *key = tsvalue(rc); /* key must be a string */
|
||||
TString *key = tsvalue(rc); /* key must be a short string */
|
||||
if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
|
||||
setobj2s(L, ra, slot);
|
||||
}
|
||||
@ -1296,7 +1296,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
||||
const TValue *slot;
|
||||
TValue *rb = vRB(i);
|
||||
TValue *rc = KC(i);
|
||||
TString *key = tsvalue(rc); /* key must be a string */
|
||||
TString *key = tsvalue(rc); /* key must be a short string */
|
||||
if (luaV_fastget(L, rb, key, slot, luaH_getshortstr)) {
|
||||
setobj2s(L, ra, slot);
|
||||
}
|
||||
@ -1309,7 +1309,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
||||
TValue *upval = cl->upvals[GETARG_A(i)]->v.p;
|
||||
TValue *rb = KB(i);
|
||||
TValue *rc = RKC(i);
|
||||
TString *key = tsvalue(rb); /* key must be a string */
|
||||
TString *key = tsvalue(rb); /* key must be a short string */
|
||||
if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
|
||||
luaV_finishfastset(L, upval, slot, rc);
|
||||
}
|
||||
@ -1352,7 +1352,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
||||
const TValue *slot;
|
||||
TValue *rb = KB(i);
|
||||
TValue *rc = RKC(i);
|
||||
TString *key = tsvalue(rb); /* key must be a string */
|
||||
TString *key = tsvalue(rb); /* key must be a short string */
|
||||
if (luaV_fastget(L, s2v(ra), key, slot, luaH_getshortstr)) {
|
||||
luaV_finishfastset(L, s2v(ra), slot, rc);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user