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

Why not take Strings as input? #3

Open
thejh opened this issue Oct 5, 2011 · 0 comments
Open

Why not take Strings as input? #3

thejh opened this issue Oct 5, 2011 · 0 comments

Comments

@thejh
Copy link

thejh commented Oct 5, 2011

Hello,
I saw that @dominictarr wrote about this being much slower than v8s JSON.parse(), put I thought that some improvements would maybe be possible. Some thoughts:
Why don't you take strings as input? I think that this should give you a huge speed improvement because you don't have to call multiple methods per character, but can instead skip over strings until you hit a backslash or quote and then do str.slice(). See this pull request for isaacs sax xml parser which got a 169% speed increase just by adding some fast string-skipping code: isaacs/sax-js#25

If you want to continue accepting buffers, you could just inspect the last six bytes in order to determine where the last complete character ends - a character starts with 0 or 11, so seek back (max 6 bytes) until you hit such a character, then check whether it's a complete character by inspecting the first byte of the character.

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