Closed KommuSoft closed 3 years ago
This is mainly for performance purposes. Right now it can take up to 241 guards, and each guard requires three boolean checks.
In the new approach after 25 guards (75 boolean checks), we work with a helper function that will for each color map it to a [0..5]
range, and then we perform calculations to obtain the number. This helper function performs three guards (each with one boolean check) and some arithmetic, but the number of checks thus drops, worst case from 723 boolean checks to 84 checks, which is likely more efficient.
I've added a testcase to check the equivalence with the "old" implementation. This had:
vty > Test case check rgbColorToColor240 optimization is correct: Pass
Thanks for the details and for the test!
Can you provide a bit more information about this change? Such as: