OPTION: map/hlua: make core.set_map() lookup more efficient
0844bed7d3
("MEDIUM: map/acl: Improve pat_ref_set() efficiency (for
"set-map", "add-acl" action perfs)") improved lookup efficiency for
set-map http action, but the core.set_map() lua method which is built
on the same construct was overlooked. Let's also benefit from this optim
as it easily applies.
This commit is contained in:
parent
311dc748b0
commit
2ce0db4e4b
|
@ -2279,6 +2279,7 @@ static int hlua_set_map(lua_State *L)
|
||||||
const char *key;
|
const char *key;
|
||||||
const char *value;
|
const char *value;
|
||||||
struct pat_ref *ref;
|
struct pat_ref *ref;
|
||||||
|
struct pat_ref_elt *elt;
|
||||||
|
|
||||||
MAY_LJMP(check_args(L, 3, "set_map"));
|
MAY_LJMP(check_args(L, 3, "set_map"));
|
||||||
|
|
||||||
|
@ -2291,8 +2292,9 @@ static int hlua_set_map(lua_State *L)
|
||||||
WILL_LJMP(luaL_error(L, "'set_map': unknown map file '%s'", name));
|
WILL_LJMP(luaL_error(L, "'set_map': unknown map file '%s'", name));
|
||||||
|
|
||||||
HA_RWLOCK_WRLOCK(PATREF_LOCK, &ref->lock);
|
HA_RWLOCK_WRLOCK(PATREF_LOCK, &ref->lock);
|
||||||
if (pat_ref_find_elt(ref, key) != NULL)
|
elt = pat_ref_find_elt(ref, key);
|
||||||
pat_ref_set(ref, key, value, NULL, NULL);
|
if (elt)
|
||||||
|
pat_ref_set(ref, key, value, NULL, elt);
|
||||||
else
|
else
|
||||||
pat_ref_add(ref, key, value, NULL);
|
pat_ref_add(ref, key, value, NULL);
|
||||||
HA_RWLOCK_WRUNLOCK(PATREF_LOCK, &ref->lock);
|
HA_RWLOCK_WRUNLOCK(PATREF_LOCK, &ref->lock);
|
||||||
|
|
Loading…
Reference in New Issue