Skip to content

Commit

Permalink
remove unnecessary heap allocation (#30272)
Browse files Browse the repository at this point in the history
  • Loading branch information
thechampagne committed Sep 1, 2023
1 parent e6558e3 commit 6eb3e16
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ports/libsimpleservo/capi/src/prefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl LocalCPrefValue {
match v {
PrefValue::Float(v) => LocalCPrefValue::Float(*v),
PrefValue::Int(v) => LocalCPrefValue::Int(*v),
PrefValue::Str(v) => LocalCPrefValue::Str(CString::new(v.clone()).unwrap()),
PrefValue::Str(v) => LocalCPrefValue::Str(CString::new(v.as_bytes()).unwrap()),
PrefValue::Bool(v) => LocalCPrefValue::Bool(*v),
PrefValue::Missing => LocalCPrefValue::Missing,
}
Expand Down Expand Up @@ -203,7 +203,7 @@ pub extern "C" fn get_prefs() -> CPrefList {
.into_iter()
.map(|(key, (value, is_default))| {
let l = Box::new(LocalCPref {
key: CString::new(key.clone()).unwrap(),
key: CString::new(key.as_bytes()).unwrap(),
value: LocalCPrefValue::new(&value),
is_default: is_default,
});
Expand Down

0 comments on commit 6eb3e16

Please sign in to comment.