Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
remove branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Feb 5, 2022
1 parent 270f495 commit 010b714
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
18 changes: 2 additions & 16 deletions src/io/json/write/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn utf8_serializer<'a, O: Offset>(
array.iter(),
|x, buf| {
if let Some(x) = x {
utf8_serialize(x, buf)
serde_json::to_writer(buf, x).unwrap();
} else {
buf.extend_from_slice(b"null")
}
Expand Down Expand Up @@ -136,20 +136,6 @@ fn list_serializer<'a, O: Offset>(
))
}

#[inline]
fn utf8_serialize(value: &str, buf: &mut Vec<u8>) {
if value.as_bytes().is_ascii() && !value.contains('"') {
buf.reserve(value.len() + 2);
buf.push(b'"');
buf.extend_from_slice(value.as_bytes());
buf.push(b'"');
} else {
// it may contain reserved keywords: perform roundtrip for
// todo: avoid this roundtrip over serde_json
serde_json::to_writer(buf, value).unwrap();
}
}

fn new_serializer<'a>(
array: &'a dyn Array,
) -> Box<dyn StreamingIterator<Item = [u8]> + 'a + Send + Sync> {
Expand Down Expand Up @@ -188,7 +174,7 @@ fn serialize_item<F: JsonFormat>(
buffer.push(b',');
}
first_item = false;
utf8_serialize(key, buffer);
serde_json::to_writer(&mut *buffer, key).unwrap();
buffer.push(b':');
buffer.extend(*value);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/it/io/json/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ fn write_escaped_utf8() -> Result<()> {

assert_eq!(
String::from_utf8(buf).unwrap().as_bytes(),
b"{\"c1\":\"a\na\"}\n{\"c1\":null}\n"
b"{\"c1\":\"a\\na\"}\n{\"c1\":null}\n"
);
Ok(())
}
Expand Down

0 comments on commit 010b714

Please sign in to comment.