From 07dbb6538ca55e69a33ada6761e749f4ee06affe Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Fri, 22 Aug 2025 21:15:31 +0200 Subject: json: Improved parsing performance --- src/json.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/json.c') diff --git a/src/json.c b/src/json.c index 6f00da8..af93d06 100644 --- a/src/json.c +++ b/src/json.c @@ -38,7 +38,7 @@ JSON JSON_array(Vec items) { return json; } -JSON JSON_string(Str value) { +JSON JSON_string(StrView value) { JSON json = {0}; json.type = JSON_STRING; json.as.string = value; @@ -72,7 +72,7 @@ i32 JSON_fprint(FILE *w, JSON json) { switch (json.type) { case JSON_STRING: fprintf(w, "\""); - Str_fprint(w, json.as.string); + StrView_fprint(w, json.as.string); return fprintf(w, "\""); case JSON_INTEGER: return fprintf(w, "%d", json.as.integer); @@ -182,8 +182,8 @@ parse_result parse_string(Arena *a, byte *src, uptr start_pos) { result.pos++; } assert(src[result.pos] == '"'); - result.value = JSON_string( - Str_copy(a, &src[start_pos + 1], result.pos - start_pos - 1)); + result.value = + JSON_string(Str_view(&src[start_pos + 1], result.pos - start_pos - 1)); result.pos++; return result; -- cgit v1.3