Skip to content

Commit

Permalink
Janitor: Fix clippy::blocks_in_if_conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
hunger authored and ogoffart committed Aug 5, 2021
1 parent 9c12421 commit ff76aa8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 26 deletions.
8 changes: 5 additions & 3 deletions sixtyfps_compiler/passes/visible.rs
Expand Up @@ -24,9 +24,11 @@ pub fn handle_visible(component: &Rc<Component>, type_register: &TypeRegister) {
component,
&(),
&mut |elem: &ElementRc, _| {
if elem.borrow().native_class().map_or(false, |n| {
Rc::ptr_eq(&n, &native_clip) && elem.borrow().id.ends_with("_visibility")
}) {
let is_lowered_from_visible_property =
elem.borrow().native_class().map_or(false, |n| {
Rc::ptr_eq(&n, &native_clip) && elem.borrow().id.ends_with("_visibility")
});
if is_lowered_from_visible_property {
// This is the element we just created. Skip it.
return;
}
Expand Down
6 changes: 3 additions & 3 deletions sixtyfps_runtime/corelib/flickable.rs
Expand Up @@ -75,13 +75,13 @@ impl FlickableData {
}
}
MouseEvent::MouseMoved { pos } => {
if inner.capture_events
let do_intercept = inner.capture_events
|| inner.pressed_time.map_or(false, |pressed_time| {
crate::animations::current_tick() - pressed_time < DURATION_THRESHOLD
&& (pos - inner.pressed_pos).square_length()
> DISTANCE_THRESHOLD * DISTANCE_THRESHOLD
})
{
});
if do_intercept {
InputEventFilterResult::Intercept
} else if inner.pressed_time.is_some() {
InputEventFilterResult::ForwardAndInterceptGrab
Expand Down
28 changes: 14 additions & 14 deletions sixtyfps_runtime/corelib/model.rs
Expand Up @@ -538,7 +538,8 @@ impl<C: RepeatedComponent + 'static> Repeater<C> {
let listview_geometry_tracker =
unsafe { self.map_unchecked(|s| &s.listview_geometry_tracker) };
let init = &init;
if listview_geometry_tracker

let geometry_changed = listview_geometry_tracker
.evaluate_if_dirty(|| {
let listview_height = listview_height.get();
// Compute the element height
Expand Down Expand Up @@ -603,19 +604,18 @@ impl<C: RepeatedComponent + 'static> Repeater<C> {
break;
}
})
.is_none()
{
if self.inner.borrow().borrow().is_dirty.as_ref().get() {
let count = self
.inner
.borrow()
.borrow()
.components
.len()
.min(row_count.saturating_sub(self.inner.borrow().borrow().offset));
self.ensure_updated_impl(init, &model, count);
self.compute_layout_listview(viewport_width, listview_width);
}
.is_none();

if geometry_changed && self.inner.borrow().borrow().is_dirty.as_ref().get() {
let count = self
.inner
.borrow()
.borrow()
.components
.len()
.min(row_count.saturating_sub(self.inner.borrow().borrow().offset));
self.ensure_updated_impl(init, &model, count);
self.compute_layout_listview(viewport_width, listview_width);
}
}

Expand Down
17 changes: 11 additions & 6 deletions sixtyfps_runtime/corelib/properties.rs
Expand Up @@ -405,12 +405,14 @@ impl PropertyHandle {

/// Implementation of Self::set_binding.
fn set_binding_impl(&self, binding: *mut BindingHolder) {
if self.access(|b| {
let previous_binding_intercepted = self.access(|b| {
b.map_or(false, |b| unsafe {
// Safety: b is a BindingHolder<T>
(b.vtable.intercept_set_binding)(&*b as *const BindingHolder, binding)
})
}) {
});

if previous_binding_intercepted {
return;
}

Expand Down Expand Up @@ -608,21 +610,24 @@ impl<T: Clone> Property<T> {
where
T: PartialEq,
{
if !self.handle.access(|b| {
let previous_binding_intercepted = self.handle.access(|b| {
b.map_or(false, |b| unsafe {
// Safety: b is a BindingHolder<T>
(b.vtable.intercept_set)(&*b as *const BindingHolder, &t as *const T as *const ())
})
}) {
});
if !previous_binding_intercepted {
self.handle.remove_binding();
}

// Safety: PropertyHandle::access ensure that the value is locked
if self.handle.access(|_| unsafe {
let has_value_changed = self.handle.access(|_| unsafe {
*self.value.get() != t && {
*self.value.get() = t;
true
}
}) {
});
if has_value_changed {
self.handle.mark_dirty();
}
}
Expand Down

0 comments on commit ff76aa8

Please sign in to comment.