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

optimization: mode to check the tail of a chunk to see if it's worth attempting to read an object #4

Open
tychoish opened this issue Mar 4, 2024 · 0 comments

Comments

@tychoish
Copy link

tychoish commented Mar 4, 2024

Just to capture a thought, (and sorry for all of my noise), If we know (or can be told) that the stream is going to be a bounded object type (e.g. strings, arrays, objects) we can inspect the end of every chunk and avoid attempting to parse a chunk if we know that the end of the chunk doesn't contain whitespace or another terminator. (e.g. if the first character of the chunk is [ and the last is " then we should wait for more input rather than attempting to parse the data and learn that it's incomplete.

Whitespace at the beginning can be ignored/dropped, but whitespace at the end is ambiguous, any place where there's a match is potentially a false-positive, but we could greatly reduce the number of times we need to call the deserializer, which would improve overall performance.

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