From 532f47444bbd8e92a5c30611dbba4fdde610a293 Mon Sep 17 00:00:00 2001 From: snail Date: Mon, 11 Jan 2016 15:06:51 +0800 Subject: [PATCH] reduce needless 'add_string' call Short strings in lua proto are reused most of the time. The string in SSM may be added by one service and used by other service, there is no need to call `add_string`,which will call 'new_string' first. --- 3rd/lua/lstring.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/3rd/lua/lstring.c b/3rd/lua/lstring.c index 79a232df..71443a91 100644 --- a/3rd/lua/lstring.c +++ b/3rd/lua/lstring.c @@ -419,8 +419,11 @@ luaS_clonestring(lua_State *L, TString *ts) { result = query_ptr(ts); if (result) return result; - // ts is not in SSM, so recalc hash, and add it to SSM h = luaS_hash(str, l, 0); + result = query_string(h, str, l); + if (result) + return result; + // ts is not in SSM, so recalc hash, and add it to SSM return add_string(h, str, l); }