Skip to content

Commit f57a3bb

Browse files
committed
Perf(value): use to_owned instead of to_string
This change improves `ValueRef::to_owned()` method performance by approximately 10-20%. Also after this commit it's cheaper to decode directly into `ValueRef` with further converting to owned value rather than decoding directly into `Value`.
1 parent 7162a07 commit f57a3bb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rmp/src/value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'a> ValueRef<'a> {
9898
&ValueRef::Boolean(val) => Value::Boolean(val),
9999
&ValueRef::Integer(val) => Value::Integer(val),
100100
&ValueRef::Float(val) => Value::Float(val),
101-
&ValueRef::String(val) => Value::String(val.to_string()),
101+
&ValueRef::String(val) => Value::String(val.to_owned()),
102102
&ValueRef::Binary(val) => Value::Binary(val.to_vec()),
103103
&ValueRef::Array(ref val) => {
104104
Value::Array(val.iter().map(|v| v.to_owned()).collect())

0 commit comments

Comments
 (0)