styled-components / polished

A lightweight toolset for writing styles in JavaScript ✨
https://polished.js.org/
MIT License
7.6k stars 209 forks source link

[Performance] Improve tint and shade performance #626

Open thadeucity opened 1 year ago

thadeucity commented 1 year ago

Improve the performance of the tint and shade functions.

It is a tiny performance improvement and lib size reduction, but it does not degrade in any shape or form the quality of the code, so I believe it is a welcome change.

The improvement is achieved by exiting the parseToRgb function in the first IF that checks for HEX Colors, this way not testing or matching the default color unnecessarily.

codecov[bot] commented 1 year ago

Codecov Report

Merging #626 (8b70bb2) into main (275e646) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #626   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           89        89           
  Lines          860       860           
  Branches       323       323           
=========================================
  Hits           860       860           
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/color/shade.js 100.00% <100.00%> (ø)
src/color/tint.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.