diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-10-19 17:53:20 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-10-19 17:53:20 +0100 |
commit | e891c9546aa997ef84a8bf5513c745eb9d34c8e0 (patch) | |
tree | f159d59ce639fe7780a4e833d907a4e96a4b6c31 | |
parent | 05457bf4200250d8262bd1de87b0a33545cf70a4 (diff) | |
download | rspamd-e891c9546aa997ef84a8bf5513c745eb9d34c8e0.tar.gz rspamd-e891c9546aa997ef84a8bf5513c745eb9d34c8e0.zip |
[Minor] Lua_cdb: Avoid extra copy on lookup
-rw-r--r-- | src/lua/lua_cdb.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/src/lua/lua_cdb.c b/src/lua/lua_cdb.c index 91f770cb3..37f35d985 100644 --- a/src/lua/lua_cdb.c +++ b/src/lua/lua_cdb.c @@ -149,9 +149,6 @@ lua_cdb_lookup (lua_State *L) struct cdb *cdb = lua_check_cdb (L, 1); gsize klen; const gchar *what = luaL_checklstring(L, 2, &klen); - gchar *value; - gsize vlen; - gint64 vpos; if (!cdb || what == NULL) { return lua_error (L); @@ -159,12 +156,7 @@ lua_cdb_lookup (lua_State *L) if (cdb_find (cdb, what, klen) > 0) { /* Extract and push value to lua as string */ - vpos = cdb_datapos (cdb); - vlen = cdb_datalen (cdb); - value = g_malloc (vlen); - cdb_read (cdb, value, vlen, vpos); - lua_pushlstring (L, value, vlen); - g_free (value); + lua_pushlstring (L, cdb_getdata (cdb), cdb_datalen (cdb)); } else { lua_pushnil (L); |