lua-users home
lua-l archive

Re: [ANN] Lua 5.2.0 (work1) now available

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Jan 11, 2010 at 05:36:48PM -0500, Tom N Harris wrote:
> Or just: if (t1[1]==t2[1] && t1[2]==t2[2])
> Slightly slower, but who cares? It's an error message.
true true.
Yet there is no reason to have to different copies of
the string "userdata" in luaT_typenames.
luaT_typenames[LUA_TLIGHTUSERDATA] and luaT_typenames[LUA_TUSERDATA]
should just be the same pointer to allow fast and safe
pointer comparision (and save 9 bytes ;).
$ diff -u ltm.c.orig ltm.c
--- ltm.c.orig 2007年12月27日 14:02:25.000000000 +0100
+++ ltm.c 2010年01月12日 12:25:54.000000000 +0100
@@ -19,10 +19,10 @@
 #include "ltm.h"
 
 
-
+static const char userdata[] = "userdata";
 const char *const luaT_typenames[] = {
- "nil", "boolean", "userdata", "number",
- "string", "table", "function", "userdata", "thread",
+ "nil", "boolean", userdata, "number",
+ "string", "table", "function", userdata, "thread",
 "proto", "upval"
 };
 
best

AltStyle によって変換されたページ (->オリジナル) /