Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the size of AnimationValue code #18414

Merged
merged 3 commits into from Oct 3, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Remove 10k from AnimationValue::animate.

  • Loading branch information
jdm committed Oct 3, 2017
commit 799014755ed338753644dea6cd8e3187d603706e
@@ -524,40 +524,45 @@ impl AnimationValue {
}
}

fn animate_discrete<T: Clone>(this: &T, other: &T, procedure: Procedure) -> Result<T, ()> {
if let Procedure::Interpolate { progress } = procedure {
Ok(if progress < 0.5 { this.clone() } else { other.clone() })
} else {
Err(())
}
}

impl Animate for AnimationValue {
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
match (self, other) {
let value = match (self, other) {
% for prop in data.longhands:
% if prop.animatable:
% if prop.animation_value_type != "discrete":
(
&AnimationValue::${prop.camel_case}(ref this),
&AnimationValue::${prop.camel_case}(ref other),
) => {
Ok(AnimationValue::${prop.camel_case}(
AnimationValue::${prop.camel_case}(
this.animate(other, procedure)?,
))
)
},
% else:
(
&AnimationValue::${prop.camel_case}(ref this),
&AnimationValue::${prop.camel_case}(ref other),
) => {
if let Procedure::Interpolate { progress } = procedure {
Ok(AnimationValue::${prop.camel_case}(
if progress < 0.5 { this.clone() } else { other.clone() },
))
} else {
Err(())
}
AnimationValue::${prop.camel_case}(
animate_discrete(this, other, procedure)?
)
},
% endif
% endif
% endfor
_ => {
panic!("Unexpected AnimationValue::animate call, got: {:?}, {:?}", self, other);
}
}
};
Ok(value)
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.