summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2024-01-31 14:08:57 +0800
committerZhidao HONG <z.hong@f5.com>2024-02-20 06:09:23 +0800
commit62894ae77b806e84e7e2c16950850f62825869c2 (patch)
tree4108e557be8f5d359d6d04c0048c15b32a092ccc /src
parent30b410e49098c5016b9295263a15c479aec77e86 (diff)
downloadunit-62894ae77b806e84e7e2c16950850f62825869c2.tar.gz
unit-62894ae77b806e84e7e2c16950850f62825869c2.tar.bz2
Var: Refactored nxt_var_ref_get()
Diffstat (limited to 'src')
-rw-r--r--src/nxt_var.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/nxt_var.c b/src/nxt_var.c
index 729de788..e45c4f14 100644
--- a/src/nxt_var.c
+++ b/src/nxt_var.c
@@ -132,18 +132,13 @@ nxt_var_ref_get(nxt_tstr_state_t *state, nxt_str_t *name)
ref->index = state->var_refs->nelts - 1;
- ref->name = nxt_str_dup(state->pool, NULL, name);
- if (nxt_slow_path(ref->name == NULL)) {
- return NULL;
- }
-
decl = nxt_var_hash_find(name);
if (decl != NULL) {
ref->handler = decl->handler;
ref->cacheable = decl->cacheable;
- return ref;
+ goto done;
}
ret = nxt_http_unknown_var_ref(state, ref, name);
@@ -151,6 +146,13 @@ nxt_var_ref_get(nxt_tstr_state_t *state, nxt_str_t *name)
return NULL;
}
+done:
+
+ ref->name = nxt_str_dup(state->pool, NULL, name);
+ if (nxt_slow_path(ref->name == NULL)) {
+ return NULL;
+ }
+
return ref;
}