Skip to content

Commit b877d6d

Browse files
committed
Avoid unnecessary float conversion
1 parent 3297ec8 commit b877d6d

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

lib/sass/value/color/space/lab.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def convert(dest, lightness, a, b, alpha, # rubocop:disable Naming/MethodParamet
6363
private
6464

6565
def _convert_f_to_x_or_z(component)
66-
cubed = (component**3) + 0.0
66+
cubed = component**3
6767
cubed > Utils::LAB_EPSILON ? cubed : ((116 * component) - 16) / Utils::LAB_KAPPA
6868
end
6969
end

lib/sass/value/color/space/oklab.rb

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,15 @@ def convert(dest, lightness, a, b, alpha, # rubocop:disable Naming/MethodParamet
3737

3838
LMS.convert(
3939
dest,
40-
((
41-
(Conversions::OKLAB_TO_LMS[0] * lightness) +
42-
(Conversions::OKLAB_TO_LMS[1] * a) +
43-
(Conversions::OKLAB_TO_LMS[2] * b)
44-
)**3) + 0.0,
45-
((
46-
(Conversions::OKLAB_TO_LMS[3] * lightness) +
47-
(Conversions::OKLAB_TO_LMS[4] * a) +
48-
(Conversions::OKLAB_TO_LMS[5] * b)
49-
)**3) + 0.0,
50-
((
51-
(Conversions::OKLAB_TO_LMS[6] * lightness) +
52-
(Conversions::OKLAB_TO_LMS[7] * a) +
53-
(Conversions::OKLAB_TO_LMS[8] * b)
54-
)**3) + 0.0,
40+
((Conversions::OKLAB_TO_LMS[0] * lightness) +
41+
(Conversions::OKLAB_TO_LMS[1] * a) +
42+
(Conversions::OKLAB_TO_LMS[2] * b))**3,
43+
((Conversions::OKLAB_TO_LMS[3] * lightness) +
44+
(Conversions::OKLAB_TO_LMS[4] * a) +
45+
(Conversions::OKLAB_TO_LMS[5] * b))**3,
46+
((Conversions::OKLAB_TO_LMS[6] * lightness) +
47+
(Conversions::OKLAB_TO_LMS[7] * a) +
48+
(Conversions::OKLAB_TO_LMS[8] * b))**3,
5549
alpha,
5650
missing_lightness:,
5751
missing_chroma:,

0 commit comments

Comments
 (0)