-
Notifications
You must be signed in to change notification settings - Fork 25
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
Update ToWkt::write_wkt
to not buffer string
#126
Conversation
geo_types
writer integration to avoid intermediate representationToWkt::write_wkt
to not buffer string
I updated the PR description. This is actually considerably faster than collecting a string and then writing that to the output buffer. |
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.
I'd say I'm content with keeping the direct APIs as using std::fmt::Write
because we know we're writing UTF8 content. Otherwise you'd have to write to a Vec<u8>
and then parse that back to a String
(or maybe trust ourselves and use from_utf8_unchecked
?)
src/to_wkt/mod.rs
Outdated
// Sadly, this will lose the content of the error when mapping to std::fmt::Error | ||
self.0.write(s.as_bytes()).map_err(|_| std::fmt::Error)?; |
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.
This loss of error content is unfortunate but I'm not sure of a good way around this.
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.
See #129
Retain io::error details
CHANGES.md
if knowledge of this change could be valuable to users.This avoids buffering when writing WKT to
std::io::Write
. It's considerably faster: