the docs were wrong

This commit is contained in:
2026-04-30 00:01:32 +03:00
parent 871a7d4e17
commit 5a488bfc60
2 changed files with 3 additions and 3 deletions

View File

@@ -2424,7 +2424,7 @@ int nn_countValueCost(nn_Computer *computer, size_t values) {
switch(val.type) { switch(val.type) {
case NN_VAL_NULL: case NN_VAL_NULL:
case NN_VAL_BOOL: case NN_VAL_BOOL:
total += 4; total += 1;
continue; continue;
case NN_VAL_NUM: case NN_VAL_NUM:
total += 8; total += 8;

View File

@@ -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 // computes the cost of the top [values] values using the same algorithm as
// the modem. // the modem.
// It will return -1 if the values are invalid. // 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: // and is as follows:
// - Every value adds a 2 byte overhead // - 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. // many bytes as they contain, except empty strings count as 1 byte.
int nn_countValueCost(nn_Computer *computer, size_t values); int nn_countValueCost(nn_Computer *computer, size_t values);