From 672fe2dfd7d751a864983a78786176060564e6b1 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Fri, 14 Feb 2020 22:17:50 +0300 Subject: [PATCH] Parse KML without converting to UTF-8 and back to bytes --- src/location.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/location.rs b/src/location.rs index 3c6876f44..6bde075c4 100644 --- a/src/location.rs +++ b/src/location.rs @@ -64,11 +64,10 @@ impl Kml { Default::default() } - pub fn parse(context: &Context, content: &[u8]) -> Result { - ensure!(content.len() <= 1024 * 1024, "kml-file is too large"); + pub fn parse(context: &Context, to_parse: &[u8]) -> Result { + ensure!(to_parse.len() <= 1024 * 1024, "kml-file is too large"); - let to_parse = String::from_utf8_lossy(content); - let mut reader = quick_xml::Reader::from_str(&to_parse); + let mut reader = quick_xml::Reader::from_reader(to_parse); reader.trim_text(true); let mut kml = Kml::new();