foundation / foundation/motion-ui

divide function is causing huge compile times

Open
#144 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
SCSS
Stars
1.2k
Forks
169
PR merge metrics
No merged PRs in 30d

Description

**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](https://github.com/foundation/motion-ui/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;`

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

Reverting to `v2.0.3` fixes this issue.

**Motion-UI Version**
2.0.4

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.