diff options
author | Mark Kriegsman <kriegsman@tr.org> | 2015-07-02 04:54:30 +0300 |
---|---|---|
committer | Mark Kriegsman <kriegsman@tr.org> | 2015-07-02 04:54:30 +0300 |
commit | cf39c27391d5b44ae94be6a4d1de5b98cfd9f07e (patch) | |
tree | 261be80cd2f6362984b063753254886220f73037 /hsv2rgb.cpp | |
parent | 7a86bc473b84d9a6d1007e597f5a4da854f0000d (diff) |
Minor hsv2rgb speedup on ARM.
Diffstat (limited to 'hsv2rgb.cpp')
-rw-r--r-- | hsv2rgb.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/hsv2rgb.cpp b/hsv2rgb.cpp index f16472fc..25ec8ea9 100644 --- a/hsv2rgb.cpp +++ b/hsv2rgb.cpp @@ -305,11 +305,19 @@ void hsv2rgb_rainbow( const CHSV& hsv, CRGB& rgb) // offset8 = offset * 8 uint8_t offset8 = offset; { +#if defined(__AVR__) + // Left to its own devices, gcc turns "x <<= 3" into a loop + // It's much faster and smaller to just do three single-bit shifts + // So this business is to force that. offset8 <<= 1; asm volatile(""); offset8 <<= 1; asm volatile(""); offset8 <<= 1; +#else + // On ARM and other non-AVR platforms, we just shift 3. + offset8 <<= 3; +#endif } uint8_t third = scale8( offset8, (256 / 3)); |