Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change calculation method for arrays #8

Closed
Pyseph opened this issue Jul 19, 2023 · 0 comments
Closed

Change calculation method for arrays #8

Pyseph opened this issue Jul 19, 2023 · 0 comments

Comments

@Pyseph
Copy link
Owner

Pyseph commented Jul 19, 2023

Currently, if a table is determined to be a continuous array with no holes between its elements, only its values are calculated into account for. Otherwise, it will count the table as a dictionary - this is not the true behavior, as remotes have undocumented behavior when it comes to arrays with holes. Internally, it seems to rely on HttpService:JSONEncode & HttpService:JSONDecode's behavior with arrays, iterating through the array until a gap is met.
As such, to check if a given table is an array, you could do the following:

local IsArray = t[1] ~= nil

If IsArray == true, the dictionary elements would be discarded in favor of the array components only; mixed tables not being supported.

Additionally, the length byte of the table is encoded as a variable and not a constant. It uses the VLQ format, which means the byte size changes at the rate of math.ceil(num_elements(t) / 128), due to the VLQ format using base-128.

@Pyseph Pyseph closed this as completed in 83eba7a Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant