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

Early out in load_buffer for empty inputs to avoid allocations #664

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

zeux
Copy link
Owner

@zeux zeux commented Feb 19, 2025

Previously, calling xml_document::load_string on an empty buffer resulted in a single byte allocation for the buffer copy; this allocation was redundant as no data was parsed, so we now add the same early-out that already exists in xml_parser::parse to load_buffer_impl.

This should almost never matter but might help applications that for some strange reason frequently parse empty documents without a higher level size check on the app side.

Previously, calling xml_document::load_string on an empty buffer
resulted in a single byte allocation for the buffer copy; this
allocation was redundant as no data was parsed, so we now add the same
early-out that already exists in xml_parser::parse to load_buffer_impl.
@zeux zeux merged commit 066b658 into master Feb 19, 2025
24 checks passed
@zeux zeux deleted the emptybuf branch February 19, 2025 17:33
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

Successfully merging this pull request may close these issues.

1 participant