From 68982e6e5b98406673d3da2d3cc7764c4e737ef0 Mon Sep 17 00:00:00 2001 From: Dennis Schridde Date: Mon, 1 Oct 2012 22:58:25 +0200 Subject: [PATCH] Simplify register_lsyncd(), too --- lsyncd.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lsyncd.c b/lsyncd.c index c0deb5a..b2c9d47 100644 --- a/lsyncd.c +++ b/lsyncd.c @@ -1373,26 +1373,24 @@ register_lsyncd(lua_State *L) // creates the metatable for jiffies userdata luaL_newmetatable(L, "Lsyncd.jiffies"); - lua_pushstring(L, "__add"); + int mt = lua_gettop(L); + lua_pushcfunction(L, l_jiffies_add); - lua_settable(L, -3); + lua_setfield(L, mt, "__add"); - lua_pushstring(L, "__sub"); lua_pushcfunction(L, l_jiffies_sub); - lua_settable(L, -3); + lua_setfield(L, mt, "__sub"); - lua_pushstring(L, "__lt"); lua_pushcfunction(L, l_jiffies_lt); - lua_settable(L, -3); + lua_setfield(L, mt, "__lt"); - lua_pushstring(L, "__le"); lua_pushcfunction(L, l_jiffies_le); - lua_settable(L, -3); + lua_setfield(L, mt, "__le"); - lua_pushstring(L, "__eq"); lua_pushcfunction(L, l_jiffies_eq); - lua_settable(L, -3); - lua_pop(L, 1); + lua_setfield(L, mt, "__eq"); + + lua_pop(L, 1); // pop(mt) #ifdef LSYNCD_WITH_INOTIFY lua_getglobal(L, "lsyncd");