aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-08-22 21:15:31 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-08-27 11:43:09 +0200
commit07dbb6538ca55e69a33ada6761e749f4ee06affe (patch)
treebe8eaf0a1b3a20aba89a85fe6b614227655e6a39 /include
parent911f1fe752173fdfee3f135acd2509c908c7fce2 (diff)
json: Improved parsing performance
Diffstat (limited to 'include')
-rw-r--r--include/json.h2
-rw-r--r--include/str.h7
2 files changed, 8 insertions, 1 deletions
diff --git a/include/json.h b/include/json.h
index 749a3e0..9bd668e 100644
--- a/include/json.h
+++ b/include/json.h
@@ -24,7 +24,7 @@ typedef struct {
i32 integer;
f32 floating;
Vec array; // Vec<JSON>
- Str string;
+ StrView string;
JSONObject object;
} as;
} JSON;
diff --git a/include/str.h b/include/str.h
index 300d5ea..3ccd072 100644
--- a/include/str.h
+++ b/include/str.h
@@ -12,7 +12,14 @@ typedef struct {
byte *data;
size len;
} Str;
+typedef struct {
+ byte *data;
+ size len;
+} StrView;
i32 Str_equals(Str a, Str b);
u64 Str_hash64(Str s);
Str Str_copy(Arena *a, byte *data, size len);
i32 Str_fprint(FILE *w, Str s);
+
+StrView Str_view(byte *data, size len);
+i32 StrView_fprint(FILE *w, StrView s);