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

Implement CSS3 Calc #7185

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Get rid of some cloning

  • Loading branch information
dzbarsky committed Sep 2, 2015
commit f3f236db5f335555dfc33eab7785effb41f14966
@@ -507,9 +507,8 @@ pub mod specified {
}

fn simplify_sum_to_number(node: &CalcSumNode) -> Option<CSSFloat> {
let node = node.clone();
let mut sum = 0.;
for product in node.products {
for product in &node.products {
match Calc::simplify_product_to_number(product) {
Some(number) => sum += number,
_ => return None
@@ -518,10 +517,10 @@ pub mod specified {
Some(sum)
}

fn simplify_product_to_number(node: CalcProductNode) -> Option<CSSFloat> {
fn simplify_product_to_number(node: &CalcProductNode) -> Option<CSSFloat> {
let mut product = 1.;
for value in node.values {
match Calc::simplify_value_to_number(&value) {
for value in &node.values {
match Calc::simplify_value_to_number(value) {
Some(number) => product *= number,
_ => return None
}
@@ -531,8 +530,7 @@ pub mod specified {

fn simplify_products_in_sum(node: &CalcSumNode) -> Result<SimplifiedValueNode, ()> {
let mut simplified = Vec::new();
let node = node.clone();
for product in node.products {
for product in &node.products {
match try!(Calc::simplify_product(product)) {
SimplifiedValueNode::Sum(box sum) => simplified.push_all(&sum.values),
val => simplified.push(val),
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.