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

Further optimize number printing #71

Merged
merged 1 commit into from
May 1, 2020
Merged

Further optimize number printing #71

merged 1 commit into from
May 1, 2020

Conversation

connorskees
Copy link
Contributor

This builds on #67. It's a pretty minor change but removing the allocation to add to the last char is exciting. It also changes how the negative sign is emitted such that -0.0000000000000000001 is not printed as -0.

Performance gains are small but noticeable. For a 10,000 line file that looks like

a {
  color: 0.45684318453159234;
  color: 0.32462456760120406;
  color: 0.8137736535327419;
  color: 0.7358225117215007;
  color: 0.17214528398099915;
  color: 0.49902566583569585;
  color: 0.338644100262644;
  color: 0.20366595024608847;
  color: 0.9913235248842889;
  color: 0.4504985674365235;
  color: 0.4019760103825616;
  color: 0.050337450640631;
  color: 0.5651205053784689;
  color: 0.3858205416141207;
  color: 0.09217890891037928;
...

I was able to see a consistent speedup of about 20-40ms. The speedup increases as --precision does.

Copy link
Owner

@kaj kaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me. Not including the "." in the dec String gives a nice cleanup of the macthing.

@kaj kaj merged commit b6cb073 into kaj:master May 1, 2020
kaj added a commit that referenced this pull request Oct 3, 2020
Progress: 2234 of 5510 tests passed in dart-sass compatiblilty mode.

* PR #76 and #78: Target dart-sass rather than libsass compatibilty.
  This sets the target when testing and changes some different
  behaviour, including how strings are parsed and handled.
* PR #75 from @divergentdave: Parse and add `Value` variants for
  BigInt numbers
* PR #77: Support `rgba(r g b / a)` and `hsla(h s l / a)` functions,
  i.e. the `channels` parameter with div-separated alpha channel.
* Fix `@import` indention.
* Improve function default argument parsing and dont panic in
  `parse_value_data`.
* Handle dictionary-ellipsis style call-by-varargs for functions.
* PR #73 from @divergentdave: Remove three unwraps from escaped_char
* PR #71 from @connorskees: Further optimize number printing
* Update travis url in README.
* PR #70 from @svenstaro: Mention grass rather than sassers, as
  sassers appears to be dead while grass is in rather active
  development.
* Add a CHANGELOG.md
* Update spec to 2020-09-17.
* Update num-rational to 0.3.0.

Tested with rustc 1.46.0 (04488afe3 2020-08-24),
1.44.1 (c7087fe00 2020-06-17), 1.42.0 (b8cedc004 2020-03-09),
1.40.0 (73528e339 2019-12-16), 1.38.0 (625451e37 2019-09-23),
1.47.0-beta.7 (e28d2bd09 2020-10-01), and
1.48.0-nightly (8876ffc92 2020-10-02)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants