From 4f99b27c3486801d1a986440e3527d3126523839 Mon Sep 17 00:00:00 2001 From: Thierry Fournier Date: Mon, 22 Feb 2016 08:40:02 +0100 Subject: [PATCH] CLEANUP: lua: Remove two same functions The function hlua_array_add_fcn() is exactly the same than the function hlua_class_function(), so this patch removes the first one. --- src/hlua_fcn.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c index f9e13918a..ac8f03316 100644 --- a/src/hlua_fcn.c +++ b/src/hlua_fcn.c @@ -161,14 +161,6 @@ static int hlua_asctime_date(lua_State *L) return hlua_parse_date(L, parse_asctime_date); } -static void hlua_array_add_fcn(lua_State *L, const char *name, - int (*function)(lua_State *L)) -{ - lua_pushstring(L, name); - lua_pushcclosure(L, function, 0); - lua_rawset(L, -3); -} - static struct hlua_concat *hlua_check_concat(lua_State *L, int ud) { return (struct hlua_concat *)(hlua_checkudata(L, ud, class_concat_ref)); @@ -291,11 +283,12 @@ int hlua_fcn_reg_core_fcn(lua_State *L) if (!hlua_concat_init(L)) return 0; - hlua_array_add_fcn(L, "now", hlua_now); - hlua_array_add_fcn(L, "http_date", hlua_http_date); - hlua_array_add_fcn(L, "imf_date", hlua_imf_date); - hlua_array_add_fcn(L, "rfc850_date", hlua_rfc850_date); - hlua_array_add_fcn(L, "asctime_date", hlua_asctime_date); - hlua_array_add_fcn(L, "concat", hlua_concat_new); + hlua_class_function(L, "now", hlua_now); + hlua_class_function(L, "http_date", hlua_http_date); + hlua_class_function(L, "imf_date", hlua_imf_date); + hlua_class_function(L, "rfc850_date", hlua_rfc850_date); + hlua_class_function(L, "asctime_date", hlua_asctime_date); + hlua_class_function(L, "concat", hlua_concat_new); + return 5; }