summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--llex.c5
-rw-r--r--ltable.h6
2 files changed, 9 insertions, 2 deletions
diff --git a/llex.c b/llex.c
index 1a32e348..b1a714fa 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 2.63 2013/03/16 21:10:18 roberto Exp $ 2** $Id: llex.c,v 2.63.1.1 2013/04/12 18:48:47 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -133,6 +133,9 @@ TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
133 setbvalue(o, 1); /* t[string] = true */ 133 setbvalue(o, 1); /* t[string] = true */
134 luaC_checkGC(L); 134 luaC_checkGC(L);
135 } 135 }
136 else { /* string already present */
137 ts = rawtsvalue(keyfromval(o)); /* re-use value previously stored */
138 }
136 L->top--; /* remove string from stack */ 139 L->top--; /* remove string from stack */
137 return ts; 140 return ts;
138} 141}
diff --git a/ltable.h b/ltable.h
index 2f6f5c2d..b28b6e62 100644
--- a/ltable.h
+++ b/ltable.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.h,v 2.16 2011/08/17 20:26:47 roberto Exp $ 2** $Id: ltable.h,v 2.16.1.1 2013/04/12 18:48:47 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -17,6 +17,10 @@
17 17
18#define invalidateTMcache(t) ((t)->flags = 0) 18#define invalidateTMcache(t) ((t)->flags = 0)
19 19
20/* returns the key, given the value of a table entry */
21#define keyfromval(v) \
22 (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val))))
23
20 24
21LUAI_FUNC const TValue *luaH_getint (Table *t, int key); 25LUAI_FUNC const TValue *luaH_getint (Table *t, int key);
22LUAI_FUNC void luaH_setint (lua_State *L, Table *t, int key, TValue *value); 26LUAI_FUNC void luaH_setint (lua_State *L, Table *t, int key, TValue *value);