-
Notifications
You must be signed in to change notification settings - Fork 23
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
Pretty Encoding #32
base: master
Are you sure you want to change the base?
Pretty Encoding #32
Conversation
Any encoders with the same indent share a cache. Only one assignment is made on depth change. `space` is equivalent to the third argument of [javascript's JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
You are using _ENV... is your changes breaks the Lua 5.1 compat ? |
Hah right, forgot to write the compat. I'll get on that |
Can't you just use a local table items instead of separated variables in _ENV ? for sample local config
...
-builder[i] = start_array
+builder[i] = config.start_array
...
- if type(space) ~= "string" or space == "" then _ENV = basic else
+ if type(space) ~= "string" or space == "" then config = basic else and just avoid to use _ENV and ugly compat ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: rename tmp
to arraylen
?
Turns out using the environment has zero performance benefit in any version of lua, so it just serves to make the code less readable
This brings the interface more in line with the rest of the library
|
This doesn't really do anything for consumers, however it is valuable for ensuring variables are made local
The string escape pattern is used in |
Related to #11
This is my shot at an efficient pretty encoding facility. I'm happy to implement any changes that could improve performance.
cache
argument, avoiding recreation of indent strings. This will consume memory (that will be released with the encoder), however the footprint is minimalspace
is equivalent to the third argument of javascript's JSON.stringify