Skip to content

Commit 5bf6d2a

Browse files
committed
pango: use the new List api to simplify reorder_items
Once gir will know about glib::List, we will be able to autogenerate this.
1 parent 3a7bf73 commit 5bf6d2a

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

pango/src/functions.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

3-
use std::ptr;
4-
53
use glib::translate::*;
64

75
#[cfg(any(feature = "v1_44", feature = "dox"))]
86
use crate::ShapeFlags;
97
use crate::{Analysis, GlyphString, Item};
108

119
#[doc(alias = "pango_reorder_items")]
12-
pub fn reorder_items(logical_items: &[&Item]) -> Vec<Item> {
10+
pub fn reorder_items(logical_items: &glib::List<Item>) -> glib::List<Item> {
1311
unsafe {
14-
let stash_vec: Vec<_> = logical_items
15-
.iter()
16-
.rev()
17-
.map(|v| v.to_glib_none())
18-
.collect();
19-
let mut list: *mut glib::ffi::GList = ptr::null_mut();
20-
for stash in &stash_vec {
21-
list = glib::ffi::g_list_prepend(list, Ptr::to(stash.0));
22-
}
23-
24-
FromGlibPtrContainer::from_glib_full(ffi::pango_reorder_items(list))
12+
FromGlibPtrContainer::from_glib_full(ffi::pango_reorder_items(
13+
logical_items.as_ptr() as *mut _
14+
))
2515
}
2616
}
2717

0 commit comments

Comments
 (0)