the docs were wrong
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user