diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2016-01-05 14:07:21 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2016-01-05 14:07:21 -0200 |
commit | 1a44e822009752513ce895b9eabc51a4ee4a195a (patch) | |
tree | dc8c1dc1ca01601335e447d3d627b4354247a31d /lapi.c | |
parent | a272fa66f0c149689e2a2c896434967b7248a0eb (diff) | |
download | lua-1a44e822009752513ce895b9eabc51a4ee4a195a.tar.gz lua-1a44e822009752513ce895b9eabc51a4ee4a195a.tar.bz2 lua-1a44e822009752513ce895b9eabc51a4ee4a195a.zip |
'luaV_fastget' only treats the real fast case (table with a non-nil
value at given key, so that it does not need to check metamethods)
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.256 2015/10/06 16:10:22 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.257 2015/11/02 18:48:07 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -585,16 +585,16 @@ LUA_API int lua_pushthread (lua_State *L) { | |||
585 | 585 | ||
586 | 586 | ||
587 | static int auxgetstr (lua_State *L, const TValue *t, const char *k) { | 587 | static int auxgetstr (lua_State *L, const TValue *t, const char *k) { |
588 | const TValue *aux; | 588 | const TValue *slot; |
589 | TString *str = luaS_new(L, k); | 589 | TString *str = luaS_new(L, k); |
590 | if (luaV_fastget(L, t, str, aux, luaH_getstr)) { | 590 | if (luaV_fastget(L, t, str, slot, luaH_getstr)) { |
591 | setobj2s(L, L->top, aux); | 591 | setobj2s(L, L->top, slot); |
592 | api_incr_top(L); | 592 | api_incr_top(L); |
593 | } | 593 | } |
594 | else { | 594 | else { |
595 | setsvalue2s(L, L->top, str); | 595 | setsvalue2s(L, L->top, str); |
596 | api_incr_top(L); | 596 | api_incr_top(L); |
597 | luaV_finishget(L, t, L->top - 1, L->top - 1, aux); | 597 | luaV_finishget(L, t, L->top - 1, L->top - 1, slot); |
598 | } | 598 | } |
599 | lua_unlock(L); | 599 | lua_unlock(L); |
600 | return ttnov(L->top - 1); | 600 | return ttnov(L->top - 1); |
@@ -626,17 +626,17 @@ LUA_API int lua_getfield (lua_State *L, int idx, const char *k) { | |||
626 | 626 | ||
627 | LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) { | 627 | LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) { |
628 | StkId t; | 628 | StkId t; |
629 | const TValue *aux; | 629 | const TValue *slot; |
630 | lua_lock(L); | 630 | lua_lock(L); |
631 | t = index2addr(L, idx); | 631 | t = index2addr(L, idx); |
632 | if (luaV_fastget(L, t, n, aux, luaH_getint)) { | 632 | if (luaV_fastget(L, t, n, slot, luaH_getint)) { |
633 | setobj2s(L, L->top, aux); | 633 | setobj2s(L, L->top, slot); |
634 | api_incr_top(L); | 634 | api_incr_top(L); |
635 | } | 635 | } |
636 | else { | 636 | else { |
637 | setivalue(L->top, n); | 637 | setivalue(L->top, n); |
638 | api_incr_top(L); | 638 | api_incr_top(L); |
639 | luaV_finishget(L, t, L->top - 1, L->top - 1, aux); | 639 | luaV_finishget(L, t, L->top - 1, L->top - 1, slot); |
640 | } | 640 | } |
641 | lua_unlock(L); | 641 | lua_unlock(L); |
642 | return ttnov(L->top - 1); | 642 | return ttnov(L->top - 1); |
@@ -740,15 +740,15 @@ LUA_API int lua_getuservalue (lua_State *L, int idx) { | |||
740 | ** t[k] = value at the top of the stack (where 'k' is a string) | 740 | ** t[k] = value at the top of the stack (where 'k' is a string) |
741 | */ | 741 | */ |
742 | static void auxsetstr (lua_State *L, const TValue *t, const char *k) { | 742 | static void auxsetstr (lua_State *L, const TValue *t, const char *k) { |
743 | const TValue *aux; | 743 | const TValue *slot; |
744 | TString *str = luaS_new(L, k); | 744 | TString *str = luaS_new(L, k); |
745 | api_checknelems(L, 1); | 745 | api_checknelems(L, 1); |
746 | if (luaV_fastset(L, t, str, aux, luaH_getstr, L->top - 1)) | 746 | if (luaV_fastset(L, t, str, slot, luaH_getstr, L->top - 1)) |
747 | L->top--; /* pop value */ | 747 | L->top--; /* pop value */ |
748 | else { | 748 | else { |
749 | setsvalue2s(L, L->top, str); /* push 'str' (to make it a TValue) */ | 749 | setsvalue2s(L, L->top, str); /* push 'str' (to make it a TValue) */ |
750 | api_incr_top(L); | 750 | api_incr_top(L); |
751 | luaV_finishset(L, t, L->top - 1, L->top - 2, aux); | 751 | luaV_finishset(L, t, L->top - 1, L->top - 2, slot); |
752 | L->top -= 2; /* pop value and key */ | 752 | L->top -= 2; /* pop value and key */ |
753 | } | 753 | } |
754 | lua_unlock(L); /* lock done by caller */ | 754 | lua_unlock(L); /* lock done by caller */ |
@@ -781,16 +781,16 @@ LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { | |||
781 | 781 | ||
782 | LUA_API void lua_seti (lua_State *L, int idx, lua_Integer n) { | 782 | LUA_API void lua_seti (lua_State *L, int idx, lua_Integer n) { |
783 | StkId t; | 783 | StkId t; |
784 | const TValue *aux; | 784 | const TValue *slot; |
785 | lua_lock(L); | 785 | lua_lock(L); |
786 | api_checknelems(L, 1); | 786 | api_checknelems(L, 1); |
787 | t = index2addr(L, idx); | 787 | t = index2addr(L, idx); |
788 | if (luaV_fastset(L, t, n, aux, luaH_getint, L->top - 1)) | 788 | if (luaV_fastset(L, t, n, slot, luaH_getint, L->top - 1)) |
789 | L->top--; /* pop value */ | 789 | L->top--; /* pop value */ |
790 | else { | 790 | else { |
791 | setivalue(L->top, n); | 791 | setivalue(L->top, n); |
792 | api_incr_top(L); | 792 | api_incr_top(L); |
793 | luaV_finishset(L, t, L->top - 1, L->top - 2, aux); | 793 | luaV_finishset(L, t, L->top - 1, L->top - 2, slot); |
794 | L->top -= 2; /* pop value and key */ | 794 | L->top -= 2; /* pop value and key */ |
795 | } | 795 | } |
796 | lua_unlock(L); | 796 | lua_unlock(L); |