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

Make most operator traits take their input by value and change TransferFn to TransferFn<T> #246

Merged
merged 9 commits into from
Jul 18, 2021

Conversation

Ogeon
Copy link
Owner

@Ogeon Ogeon commented Jul 18, 2021

This makes all of the traits have the same convention, modeled after the core::ops traits, and leaves any cloning to the caller. I considered adding an Outputtype too, but that can go into a separate pass.

Breaking Change

Almost every trait that takes parameters have changed here, so that may be breaking for non-Copy types. The clamp_self method is also gone.

@github-actions
Copy link

Benchmark for 0d7a57a

Click to view benchmark
Test PR Benchmark Master Benchmark %
Cie family/lab to lch 3.5±0.03µs 3.6±0.14µs -2.78%
Cie family/lab to xyz 964.2±15.61ns 974.1±7.31ns -1.02%
Cie family/lch to lab 2.5±0.03µs 2.6±0.08µs -3.85%
Cie family/linsrgb to xyz 3.9±0.06µs 3.9±0.05µs 0.00%
Cie family/xyz to lab 10.7±0.23µs 11.2±0.94µs -4.46%
Cie family/xyz to yxy 750.3±22.61ns 735.2±7.73ns +2.05%
Cie family/yxy to xyz 622.6±10.83ns 680.8±8.03ns -8.55%
Matrix functions/matrix_inverse 13.4±0.21ns 13.0±0.24ns +3.08%
Matrix functions/multiply_3x3 11.0±0.21ns 11.4±0.15ns -3.51%
Matrix functions/multiply_rgb_to_xyz 4.8±0.07ns 4.8±0.07ns 0.00%
Matrix functions/multiply_xyz 4.9±0.07ns 5.0±0.20ns -2.00%
Matrix functions/multiply_xyz_to_rgb 4.8±0.07ns 4.8±0.09ns 0.00%
Matrix functions/rgb_to_xyz_matrix 25.4±0.35ns 25.6±0.25ns -0.78%
Rgb family/hsl to hsv 689.3±11.26ns 790.6±10.95ns -12.81%
Rgb family/hsl to linear hsl 9.8±0.15µs 9.6±0.14µs +2.08%
Rgb family/hsl to rgb 2.5±0.05µs 2.5±0.03µs 0.00%
Rgb family/hsv to hsl 1135.3±16.47ns 1148.2±16.81ns -1.12%
Rgb family/hsv to hwb 281.2±9.33ns 268.4±7.73ns +4.77%
Rgb family/hsv to linear hsv 9.1±0.13µs 9.1±0.12µs 0.00%
Rgb family/hsv to rgb 2.5±0.03µs 2.5±0.05µs 0.00%
Rgb family/hwb to hsv 569.8±8.28ns 561.7±7.81ns +1.44%
Rgb family/hwb to linear hwb 10.9±0.16µs 11.0±0.48µs -0.91%
Rgb family/linear hsl to hsl 10.3±0.14µs 10.2±0.18µs +0.98%
Rgb family/linear hsv to hsv 9.6±0.21µs 9.8±0.10µs -2.04%
Rgb family/linear hwb to hwb 11.9±0.13µs 12.2±0.38µs -2.46%
Rgb family/linsrgb to rgb 4.7±0.08µs 4.7±0.06µs 0.00%
Rgb family/linsrgb_f32 to rgb_u8 6.4±0.08µs 6.4±0.10µs 0.00%
Rgb family/rgb to hsl 880.7±14.32ns 881.3±14.46ns -0.07%
Rgb family/rgb to hsv 679.3±6.31ns 675.4±10.20ns +0.58%
Rgb family/rgb to linsrgb 5.1±0.05µs 5.1±0.08µs 0.00%
Rgb family/rgb_u8 to linsrgb_f32 5.4±0.09µs 5.4±0.10µs 0.00%
Rgb family/xyz to linsrgb 9.0±0.07µs 8.4±0.08µs +7.14%

@Ogeon
Copy link
Owner Author

Ogeon commented Jul 18, 2021

I'm going to go through the traits again and do some more focused improvements. These were just some fixes and low hanging fruit they had in common.

bors r+

@bors
Copy link
Contributor

bors bot commented Jul 18, 2021

Build succeeded:

@bors bors bot merged commit 7f712ed into master Jul 18, 2021
@bors bors bot deleted the trait_conventions branch July 18, 2021 14:54
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.

1 participant