Replace assert! in animation code with debug_assert! draft
authorXidorn Quan <me@upsuper.org>
Fri, 03 Mar 2017 18:24:05 +1100
changeset 493803 b78daeae90627fe81e38b47954ecae48b597c87a
parent 493802 9a81b2a8e8d1a9d1da61ba2ad7739e9f4ef4521f
child 493804 e593b4bad6985612a64e11a75ffdd9fd41e35f63
child 494020 8a6c0ffbe4daa67ebbd7e40000678ff317a75ec1
push id47845
push userxquan@mozilla.com
push dateMon, 06 Mar 2017 02:53:49 +0000
milestone54.0a1
Replace assert! in animation code with debug_assert! MozReview-Commit-ID: ExoTs6xgk56
servo/components/style/properties/gecko.mako.rs
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -1319,17 +1319,17 @@ fn static_assert() {
     pub fn animation_${ident}_count(&self) -> usize {
         self.gecko.mAnimation${gecko_ffi_name}Count as usize
     }
 </%def>
 
 <%def name="impl_animation_time_value(ident, gecko_ffi_name)">
     #[allow(non_snake_case)]
     pub fn set_animation_${ident}(&mut self, v: longhands::animation_${ident}::computed_value::T) {
-        assert!(v.0.len() > 0);
+        debug_assert!(!v.0.is_empty());
         unsafe { self.gecko.mAnimations.ensure_len(v.0.len()) };
 
         self.gecko.mAnimation${gecko_ffi_name}Count = v.0.len() as u32;
         for (servo, gecko) in v.0.into_iter().zip(self.gecko.mAnimations.iter_mut()) {
             gecko.m${gecko_ffi_name} = servo.seconds() * 1000.;
         }
     }
     #[allow(non_snake_case)]
@@ -1343,17 +1343,17 @@ fn static_assert() {
 </%def>
 
 <%def name="impl_animation_keyword(ident, gecko_ffi_name, keyword, cast_type='u8')">
     #[allow(non_snake_case)]
     pub fn set_animation_${ident}(&mut self, v: longhands::animation_${ident}::computed_value::T) {
         use properties::longhands::animation_${ident}::single_value::computed_value::T as Keyword;
         use gecko_bindings::structs;
 
-        assert!(v.0.len() > 0);
+        debug_assert!(!v.0.is_empty());
         unsafe { self.gecko.mAnimations.ensure_len(v.0.len()) };
 
         self.gecko.mAnimation${gecko_ffi_name}Count = v.0.len() as u32;
 
         for (servo, gecko) in v.0.into_iter().zip(self.gecko.mAnimations.iter_mut()) {
             let result = match servo {
                 % for value in keyword.gecko_values():
                     Keyword::${to_rust_ident(value)} =>
@@ -1768,17 +1768,17 @@ fn static_assert() {
                              data.longhands_by_name["animation-fill-mode"].keyword)}
     ${impl_animation_keyword('play_state', 'PlayState',
                              data.longhands_by_name["animation-play-state"].keyword)}
 
     pub fn set_animation_iteration_count(&mut self, v: longhands::animation_iteration_count::computed_value::T) {
         use std::f32;
         use properties::longhands::animation_iteration_count::single_value::SpecifiedValue as AnimationIterationCount;
 
-        assert!(v.0.len() > 0);
+        debug_assert!(!v.0.is_empty());
         unsafe { self.gecko.mAnimations.ensure_len(v.0.len()) };
 
         self.gecko.mAnimationIterationCountCount = v.0.len() as u32;
         for (servo, gecko) in v.0.into_iter().zip(self.gecko.mAnimations.iter_mut()) {
             match servo {
                 AnimationIterationCount::Number(n) => gecko.mIterationCount = n,
                 AnimationIterationCount::Infinite => gecko.mIterationCount = f32::INFINITY,
             }
@@ -1794,17 +1794,17 @@ fn static_assert() {
         } else {
             AnimationIterationCount::Number(self.gecko.mAnimations[index].mIterationCount)
         }
     }
     ${impl_animation_count('iteration_count', 'IterationCount')}
     ${impl_copy_animation_value('iteration_count', 'IterationCount')}
 
     pub fn set_animation_timing_function(&mut self, v: longhands::animation_timing_function::computed_value::T) {
-        assert!(v.0.len() > 0);
+        debug_assert!(!v.0.is_empty());
         unsafe { self.gecko.mAnimations.ensure_len(v.0.len()) };
 
         self.gecko.mAnimationTimingFunctionCount = v.0.len() as u32;
         for (servo, gecko) in v.0.into_iter().zip(self.gecko.mAnimations.iter_mut()) {
             gecko.mTimingFunction = servo.into();
         }
     }
     ${impl_animation_count('timing_function', 'TimingFunction')}