Avoid unnecessary allocations.
This commit is contained in:
@@ -156,11 +156,13 @@ pub fn format_map_as_json(map: &Map) -> String {
|
||||
let mut result = String::from('{');
|
||||
|
||||
for (key, value) in map {
|
||||
use std::fmt::Write;
|
||||
|
||||
if result.len() > 1 {
|
||||
result.push(',');
|
||||
}
|
||||
|
||||
result.push_str(&format!("{:?}", key));
|
||||
write!(result, "{:?}", key).unwrap();
|
||||
result.push(':');
|
||||
|
||||
if let Some(val) = value.read_lock::<Map>() {
|
||||
@@ -171,7 +173,7 @@ pub fn format_map_as_json(map: &Map) -> String {
|
||||
if value.is::<()>() {
|
||||
result.push_str("null");
|
||||
} else {
|
||||
result.push_str(&format!("{:?}", value));
|
||||
write!(result, "{:?}", value).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user