From 8220eaab9bade122a8430b3bbf97ed620c05bcd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 1 Jun 2016 14:12:20 +0200 Subject: [PATCH] stylo: Remove unneeded null-check, and isolate unsafe code Gecko's allocs are infallible by default. --- ports/geckolib/properties.mako.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/ports/geckolib/properties.mako.rs b/ports/geckolib/properties.mako.rs index 1a7fdb67c16..4e0d8f3879b 100644 --- a/ports/geckolib/properties.mako.rs +++ b/ports/geckolib/properties.mako.rs @@ -778,11 +778,7 @@ fn static_assert() { stop_count as u32) }; - if gecko_gradient.is_null() { - warn!("stylo: Couldn't allocate gradient"); - return; - } - + // TODO: figure out what gecko does in the `corner` case. if let AngleOrCorner::Angle(angle) = gradient.angle_or_corner { unsafe { (*gecko_gradient).mAngle.set(angle); @@ -808,12 +804,13 @@ fn static_assert() { CSSColor::RGBA(ref rgba) => convert_rgba_to_nscolor(rgba), }; - unsafe { - let mut stop = &mut (*gecko_gradient).mStops[index as u32]; - stop.mColor = color; - stop.mIsInterpolationHint = false; - stop.mLocation.copy_from(&coord); - } + let mut stop = unsafe { + &mut (*gecko_gradient).mStops[index as u32] + }; + + stop.mColor = color; + stop.mIsInterpolationHint = false; + stop.mLocation.copy_from(&coord); } unsafe {