diff options
author | Valentin Bartenev <vbart@nginx.com> | 2017-04-10 23:04:34 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2017-04-10 23:04:34 +0300 |
commit | b01865c0233154a06b2e68c42d9eec7cb3a3c35f (patch) | |
tree | c011de2f810fbcf8715d2899d42f2c7f37cab53e /src/nxt_conf_json.c | |
parent | 3d9be969e7a7c181570aa69b9b1cb5f122904404 (diff) | |
download | unit-b01865c0233154a06b2e68c42d9eec7cb3a3c35f.tar.gz unit-b01865c0233154a06b2e68c42d9eec7cb3a3c35f.tar.bz2 |
Style and micro-optimizations in JSON parsing.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_conf_json.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/nxt_conf_json.c b/src/nxt_conf_json.c index 5f181611..01eab55a 100644 --- a/src/nxt_conf_json.c +++ b/src/nxt_conf_json.c @@ -279,11 +279,13 @@ nxt_conf_json_parse_object(u_char *pos, u_char *end, nxt_lvlhsh_t *object; nxt_conf_json_obj_member_t *member; - object = nxt_mem_zalloc(pool, sizeof(nxt_lvlhsh_t)); + object = nxt_mem_alloc(pool, sizeof(nxt_lvlhsh_t)); if (nxt_slow_path(object == NULL)) { return NULL; } + nxt_lvlhsh_init(object); + value->type = NXT_CONF_JSON_OBJECT; value->u.object = object; @@ -365,7 +367,7 @@ static u_char * nxt_conf_json_parse_array(u_char *pos, u_char *end, nxt_conf_json_value_t *value, nxt_mem_pool_t *pool) { - nxt_array_t *array; + nxt_array_t *array; array = nxt_array_create(pool, 8, sizeof(nxt_conf_json_value_t)); if (nxt_slow_path(array == NULL)) { @@ -471,11 +473,11 @@ nxt_conf_json_parse_string(u_char *pos, u_char *end, case '"': case '\\': case '/': - case 'b': - case 'f': case 'n': case 'r': case 't': + case 'b': + case 'f': surplus++; state = sw_usual; continue; @@ -558,14 +560,6 @@ nxt_conf_json_parse_string(u_char *pos, u_char *end, *s++ = ch; continue; - case 'b': - *s++ = '\b'; - continue; - - case 'f': - *s++ = '\f'; - continue; - case 'n': *s++ = '\n'; continue; @@ -577,6 +571,14 @@ nxt_conf_json_parse_string(u_char *pos, u_char *end, case 't': *s++ = '\t'; continue; + + case 'b': + *s++ = '\b'; + continue; + + case 'f': + *s++ = '\f'; + continue; } utf = 0; |