foundation / motion-ui

💎 The powerful Sass library for creating CSS transitions and animations
https://zurb.com/playground/motion-ui
MIT License
1.15k stars 175 forks source link

divide function is causing huge compile times #144

Open cameron-yee opened 1 year ago

cameron-yee commented 1 year ago

Description

The divide function in src/util/_unit.scss is causing our SCSS compile times to take about 20 minutes. The divide function takes a long time to run when large numbers are passed in to the $dividend parameter. This doesn't seem to be an issue with the built-in divide function from Sass.

Commit: bde57ece5f18e050ef0fdb51e90b5f97d9fead0a

How to Reproduce

We're calling the strip-unit function with strip-unit(999999999). This calls: divide(999999999, 1).

The nested @while loop on lines 28-31 in the divide function runs 999999999 times which takes a really long time.

The @while loop starts with these values:

$remainder: 999999999; $divisor: 1;

   @while ($remainder >= $divisor) {
      $remainder: $remainder - $divisor;
      $quotient: $quotient + 1;
    }

Reverting to v2.0.3 fixes this issue.

Motion-UI Version 2.0.4