Skip to content

Commit 2ce0db4

Browse files
committed
OPTION: map/hlua: make core.set_map() lookup more efficient
0844bed ("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.
1 parent 311dc74 commit 2ce0db4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/hlua.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,6 +2279,7 @@ static int hlua_set_map(lua_State *L)
22792279
const char *key;
22802280
const char *value;
22812281
struct pat_ref *ref;
2282+
struct pat_ref_elt *elt;
22822283

22832284
MAY_LJMP(check_args(L, 3, "set_map"));
22842285

@@ -2291,8 +2292,9 @@ static int hlua_set_map(lua_State *L)
22912292
WILL_LJMP(luaL_error(L, "'set_map': unknown map file '%s'", name));
22922293

22932294
HA_RWLOCK_WRLOCK(PATREF_LOCK, &ref->lock);
2294-
if (pat_ref_find_elt(ref, key) != NULL)
2295-
pat_ref_set(ref, key, value, NULL, NULL);
2295+
elt = pat_ref_find_elt(ref, key);
2296+
if (elt)
2297+
pat_ref_set(ref, key, value, NULL, elt);
22962298
else
22972299
pat_ref_add(ref, key, value, NULL);
22982300
HA_RWLOCK_WRUNLOCK(PATREF_LOCK, &ref->lock);

0 commit comments

Comments
 (0)