From 5a488bfc60e4002c09f5a86f6dcb2a8344a963d0 Mon Sep 17 00:00:00 2001 From: ionut Date: Thu, 30 Apr 2026 00:01:32 +0300 Subject: [PATCH] the docs were wrong --- src/neonucleus.c | 2 +- src/neonucleus.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/neonucleus.c b/src/neonucleus.c index fe01773..227278c 100644 --- a/src/neonucleus.c +++ b/src/neonucleus.c @@ -2424,7 +2424,7 @@ int nn_countValueCost(nn_Computer *computer, size_t values) { switch(val.type) { case NN_VAL_NULL: case NN_VAL_BOOL: - total += 4; + total += 1; continue; case NN_VAL_NUM: total += 8; diff --git a/src/neonucleus.h b/src/neonucleus.h index ddefdde..1139383 100644 --- a/src/neonucleus.h +++ b/src/neonucleus.h @@ -908,10 +908,10 @@ nn_Exit nn_dumptable(nn_Computer *computer, size_t idx, size_t *len); // computes the cost of the top [values] values using the same algorithm as // the modem. // It will return -1 if the values are invalid. -// The algorithm is as mentioned in https://ocdoc.cil.li/component:modem +// The algorithm is as mentioned in https://ocdoc.cil.li/component:modem, with 1 small change to match OC's code. // and is as follows: // - Every value adds a 2 byte overhead -// - Numbers add another 8 bytes, true/false/null another 4 bytes, strings as +// - Numbers add another 8 bytes, true/false/null another 1 byte, strings as // many bytes as they contain, except empty strings count as 1 byte. int nn_countValueCost(nn_Computer *computer, size_t values);