Style and micro-optimizations in JSON parsing.
@@ -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;
@@ -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;
