diff options
author | Valentin Bartenev <vbart@nginx.com> | 2019-04-24 20:31:00 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2019-04-24 20:31:00 +0300 |
commit | 30768b7b3c944425f4176fdf05946a684ba5a7ea (patch) | |
tree | 4c5c8606fb587b6d357fe00526745673332b684b | |
parent | 1467d34d733fcbecb7cbc7289c3415cb14bf6603 (diff) | |
download | unit-30768b7b3c944425f4176fdf05946a684ba5a7ea.tar.gz unit-30768b7b3c944425f4176fdf05946a684ba5a7ea.tar.bz2 |
Refactored nxt_conf_op_compile().
Now index is always initialized for create operations.
The changes in nxt_conf_op_compile() simplify adding upcoming support of
operations with arrays.
No functional changes.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_conf.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/nxt_conf.c b/src/nxt_conf.c index 08b0a029..5ec86cd4 100644 --- a/src/nxt_conf.c +++ b/src/nxt_conf.c @@ -741,6 +741,7 @@ nxt_conf_op_compile(nxt_mp_t *mp, nxt_conf_op_t **ops, nxt_conf_value_t *root, { nxt_str_t token; nxt_conf_op_t *op, **parent; + nxt_conf_value_t *node; nxt_conf_path_parse_t parse; nxt_conf_object_member_t *member; @@ -761,22 +762,23 @@ nxt_conf_op_compile(nxt_mp_t *mp, nxt_conf_op_t **ops, nxt_conf_value_t *root, nxt_conf_path_next_token(&parse, &token); - root = nxt_conf_get_object_member(root, &token, &op->index); + node = nxt_conf_get_object_member(root, &token, &op->index); if (parse.last) { break; } - if (root == NULL) { + if (node == NULL) { return NXT_DECLINED; } op->action = NXT_CONF_OP_PASS; + root = node; } if (value == NULL) { - if (root == NULL) { + if (node == NULL) { return NXT_DECLINED; } @@ -785,7 +787,7 @@ nxt_conf_op_compile(nxt_mp_t *mp, nxt_conf_op_t **ops, nxt_conf_value_t *root, return NXT_OK; } - if (root == NULL) { + if (node == NULL) { member = nxt_mp_zget(mp, sizeof(nxt_conf_object_member_t)); if (nxt_slow_path(member == NULL)) { @@ -796,6 +798,7 @@ nxt_conf_op_compile(nxt_mp_t *mp, nxt_conf_op_t **ops, nxt_conf_value_t *root, member->value = *value; + op->index = root->u.object->count; op->action = NXT_CONF_OP_CREATE; op->ctx = member; @@ -938,9 +941,7 @@ nxt_conf_copy_object(nxt_mp_t *mp, nxt_conf_op_t *op, nxt_conf_value_t *dst, do { if (pass_op == NULL) { - index = (op == NULL || op->action == NXT_CONF_OP_CREATE) - ? src->u.object->count - : op->index; + index = (op == NULL) ? src->u.object->count : op->index; } while (s != index) { |