Skip to content

divide function is causing huge compile times #144

@cameron-yee

Description

@cameron-yee

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions