mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-23 16:40:35 +00:00
Use the slice::windows() iterator instead of zipping twice for Element::link_many() and unlink_many()
Has the same effect but is easier to read and more efficient.
This commit is contained in:
parent
5a6313c682
commit
5af54b8d94
1 changed files with 8 additions and 5 deletions
|
@ -47,12 +47,12 @@ use gobject_ffi;
|
||||||
impl Element {
|
impl Element {
|
||||||
pub fn link_many<E: IsA<Element>>(elements: &[&E]) -> Result<(), glib::BoolError> {
|
pub fn link_many<E: IsA<Element>>(elements: &[&E]) -> Result<(), glib::BoolError> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
for (e1, e2) in elements.iter().zip(elements.iter().skip(1)) {
|
for e in elements.windows(2) {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib_result_from_gboolean!(
|
glib_result_from_gboolean!(
|
||||||
ffi::gst_element_link(
|
ffi::gst_element_link(
|
||||||
e1.as_ref().to_glib_none().0,
|
e[0].as_ref().to_glib_none().0,
|
||||||
e2.as_ref().to_glib_none().0,
|
e[1].as_ref().to_glib_none().0,
|
||||||
),
|
),
|
||||||
"Failed to link elements"
|
"Failed to link elements"
|
||||||
)?;
|
)?;
|
||||||
|
@ -64,9 +64,12 @@ impl Element {
|
||||||
|
|
||||||
pub fn unlink_many<E: IsA<Element>>(elements: &[&E]) {
|
pub fn unlink_many<E: IsA<Element>>(elements: &[&E]) {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
for (e1, e2) in elements.iter().zip(elements.iter().skip(1)) {
|
for e in elements.windows(2) {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_element_unlink(e1.as_ref().to_glib_none().0, e2.as_ref().to_glib_none().0);
|
ffi::gst_element_unlink(
|
||||||
|
e[0].as_ref().to_glib_none().0,
|
||||||
|
e[1].as_ref().to_glib_none().0,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue