aboutsummaryrefslogtreecommitdiffstats
path: root/serve/message-json.c
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-18 18:52:48 +0100
committereunhhu <[email protected]>2026-10-18 18:52:48 +0100
commite8b3499289022c8729900a58ed218d961a85fec8 (patch)
treefef2531be1dfc5a1568c3e2545430a8d5718d26f /serve/message-json.c
parent531200a6c24842784fad68102878c3ab77391b13 (diff)
downloadpure-e8b3499289022c8729900a58ed218d961a85fec8.tar.gz
pure-e8b3499289022c8729900a58ed218d961a85fec8.zip
Module format and executor: 027's 4b-1, a record field holding bytes (type 5): held as a text is but for UTF-8, its default a constant; a function's bytes in a signature this type too (PURE_SIGNATURE_BYTES gone); no list keyed by bytes; replaced, a text field becomes a bytes field keeping its value (pure_cell_as, kinds_carry); images' headers take its kind; the JSON edge reads it from a string; pure-run shows it as hex; an append asks a record's fields held as bytes from a mask the load makes (record_held) instead of each field's type twice, so b32 runs fewer instructions than b30 (BFS without batches -1.05%, join -0.25%, BFS with batches -0.36%, the rest within 0.04%; the bank's queries s30 against s32 -0.01% to +0.30%); unit test bytes_fields (bytes not UTF-8, a text field replaced by a bytes field, three refused); server_trees with a bytes field; 008 and 027
Diffstat (limited to 'serve/message-json.c')
-rw-r--r--serve/message-json.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/serve/message-json.c b/serve/message-json.c
index f0f965c..ea3b18c 100644
--- a/serve/message-json.c
+++ b/serve/message-json.c
@@ -341,7 +341,7 @@ static const char *items_of(PureJsonMessage *b, unsigned char *json, size_t size
if (given[k]) return "json_field";
given[k] = true;
uint8_t type = m->record_field_type[record->first + k];
- bool text = type == PURE_RECORD_TEXT, truth;
+ bool text = pure_record_bytes(type), truth; /* a string: a text's, or bytes' (as its UTF-8) */
if (type == PURE_RECORD_LIST) {
size_t from = b->rows_size;
const char *why = items_of(b, json, size, at, (uint32_t)m->record_field_default[record->first + k].i64,
@@ -366,7 +366,7 @@ static const char *items_of(PureJsonMessage *b, unsigned char *json, size_t size
unsigned char *value = json + *at + 1;
if (!memchr(value, '\\', end - 1)) written = end - 1;
else if (!json_unescape(value, end - 1, value, &written)) return "json";
- if (!pure_utf8_valid((PureSpan){value, written})) return "json";
+ if (type == PURE_RECORD_TEXT && !pure_utf8_valid((PureSpan){value, written})) return "json";
texts[k] = (PureSpan){value, written};
*at = pure_json_space(json, *at + 1 + end, size);
continue;
@@ -386,10 +386,10 @@ static const char *items_of(PureJsonMessage *b, unsigned char *json, size_t size
for (unsigned k = 0; k < record->count; ++k) {
uint32_t at_field = record->first + k;
uint8_t type = m->record_field_type[at_field];
- if (type == PURE_RECORD_TEXT || type == PURE_RECORD_LIST) {
+ if (pure_record_bytes(type) || type == PURE_RECORD_LIST) {
PureSpan text = {0};
size_t length = type == PURE_RECORD_LIST ? (given[k] ? lists[k][1] : 0) : 0;
- if (type == PURE_RECORD_TEXT) {
+ if (type != PURE_RECORD_LIST) {
uint32_t constant = (uint32_t)m->record_field_default[at_field].num;
text = given[k] ? texts[k]
: (PureSpan){m->constant_data + m->constant_offset[constant], m->constant_length[constant]};