aboutsummaryrefslogtreecommitdiff
path: root/src/str.c
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 /src/str.c
parent911f1fe752173fdfee3f135acd2509c908c7fce2 (diff)
json: Improved parsing performance
Diffstat (limited to 'src/str.c')
-rw-r--r--src/str.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/str.c b/src/str.c
index eccacd8..2899ca9 100644
--- a/src/str.c
+++ b/src/str.c
@@ -30,3 +30,14 @@ Str Str_copy(Arena *a, byte *data, size len) {
i32 Str_fprint(FILE *w, Str s) {
return fprintf(w, "%.*s", (i32)s.len, s.data);
}
+
+StrView Str_view(byte *data, size len) {
+ StrView str = {0};
+ str.len = len;
+ str.data = data;
+ return str;
+}
+
+i32 StrView_fprint(FILE *w, StrView s) {
+ return fprintf(w, "%.*s", (i32)s.len, s.data);
+}