You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I realize the code is a simple #string + 2, though the initial TYPE_OVERHEAD variable made it seem like every type only has 1 byte of overhead. Also much like with remote functions, the number of size bytes changes when the value reaches 0x80 (128 characters) because it uses a Variable Length Quantity (VLQ) encoding scheme
The text was updated successfully, but these errors were encountered:
SolarScuffle-Bot
changed the title
Strings Have A 2 Byte Type Overhead
Strings Have A 2 (Or More) Byte Type Overhead
Jul 19, 2023
If I'm understanding correctly, the#String + 2 should instead be #String + math.ceil(#String / 128) (type overhead being added afterwards; I'll update GetDataByteSize to append the type overhead also) - would this be the intended behavior? I'll take a further look tomorrow.
The above calculation wouldn't work when #string == 0, as the output would be 0; which I assume isn't the correct behavior. I've implemented the following function:
localfunctionGetVLQSize(InitialSize: number, Length: number)
returnmath.max(math.ceil(math.log(Length+InitialSize, 128)), InitialSize)
end
https://data-oriented-house.github.io/Squash/docs/binary#strings
I realize the code is a simple
#string + 2
, though the initialTYPE_OVERHEAD
variable made it seem like every type only has 1 byte of overhead. Also much like with remote functions, the number of size bytes changes when the value reaches 0x80 (128 characters) because it uses a Variable Length Quantity (VLQ) encoding schemeThe text was updated successfully, but these errors were encountered: