Skip to content

Commit 94d26e7

Browse files
committed
glib: avoid copying in GStr::to_glib_none
1 parent b284f29 commit 94d26e7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

glib/src/gstring.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,11 @@ impl crate::value::ToValueOptional for GStr {
316316

317317
#[doc(hidden)]
318318
impl<'a> ToGlibPtr<'a, *const c_char> for GStr {
319-
type Storage = GString;
319+
type Storage = &'a Self;
320320

321321
#[inline]
322322
fn to_glib_none(&'a self) -> Stash<'a, *const c_char, Self> {
323-
let tmp = self.to_owned();
324-
Stash(self.as_ptr(), tmp)
323+
Stash(self.as_ptr() as *const _, self)
325324
}
326325

327326
#[inline]
@@ -332,12 +331,11 @@ impl<'a> ToGlibPtr<'a, *const c_char> for GStr {
332331

333332
#[doc(hidden)]
334333
impl<'a> ToGlibPtr<'a, *mut c_char> for GStr {
335-
type Storage = GString;
334+
type Storage = &'a Self;
336335

337336
#[inline]
338337
fn to_glib_none(&'a self) -> Stash<'a, *mut c_char, Self> {
339-
let tmp = self.to_owned();
340-
Stash(tmp.as_ptr() as *mut c_char, tmp)
338+
Stash(self.as_ptr() as *mut _, self)
341339
}
342340

343341
#[inline]

0 commit comments

Comments
 (0)