summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-11-20 14:11:34 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-11-20 14:11:47 +0000
commitb19f007bd2449f635780078e61a174f19838b32d (patch)
treeedf3df691de99fcc97b09a7a7ceed881c7a7dc4f
parent69c5f3045a7a25ef62f65b47a79c60e3de77fee0 (diff)
downloadlibguestfs-b19f007bd2449f635780078e61a174f19838b32d.tar.gz
libguestfs-b19f007bd2449f635780078e61a174f19838b32d.tar.xz
libguestfs-b19f007bd2449f635780078e61a174f19838b32d.zip
lua: Use lua_rawgeti to read elements from lists of strings.
This is faster, but more importantly it avoids the strange error 'lua: attempt to index a string value' which appears with (some) single element lists.
-rw-r--r--generator/lua.ml3
1 files changed, 1 insertions, 2 deletions
diff --git a/generator/lua.ml b/generator/lua.ml
index 7e5779f6..67f18243 100644
--- a/generator/lua.ml
+++ b/generator/lua.ml
@@ -600,8 +600,7 @@ get_string_list (lua_State *L, int index)
}
for (i = 0; i < len; ++i) {
- lua_pushinteger (L, i+1 /* because of base 1 arrays */);
- lua_gettable (L, index);
+ lua_rawgeti (L, index, i+1 /* because of base 1 arrays */);
strs[i] = (char *) luaL_checkstring (L, -1);
lua_pop (L, 1);
}