Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kriegsman <kriegsman@tr.org>2014-11-06 16:55:38 +0300
committerMark Kriegsman <kriegsman@tr.org>2014-11-06 16:55:38 +0300
commit0889b8058830fa82a7deb36a5f0f58f756468695 (patch)
tree1dad4ef7a41eaffc79c1be99d53a4df2638f84b0 /noise.cpp
parent38e08de1dc039f2bd402787113672e7b537619c0 (diff)
Slight speedup and code size reduction by changing 16-bit-shift+AND to 8-bit shift (ASL) with no AND needed afterwards. The compiler should have done this itself but didn't; film at 0x0B.
Diffstat (limited to 'noise.cpp')
-rw-r--r--noise.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/noise.cpp b/noise.cpp
index a54e9ce4..59205b3d 100644
--- a/noise.cpp
+++ b/noise.cpp
@@ -342,9 +342,9 @@ int8_t inoise8_raw(uint16_t x, uint16_t y, uint16_t z)
uint8_t w = z;
// Get a signed version of the above for the grad function
- int8_t xx = (x>>1) & 0x7F;
- int8_t yy = (y>>1) & 0x7F;
- int8_t zz = (z>>1) & 0x7F;
+ int8_t xx = ((uint8_t)(x)>>1) & 0x7F;
+ int8_t yy = ((uint8_t)(y)>>1) & 0x7F;
+ int8_t zz = ((uint8_t)(z)>>1) & 0x7F;
uint8_t N = 0x80;
// u = FADE(u); v = FADE(v); w = FADE(w);
@@ -386,8 +386,8 @@ int8_t inoise8_raw(uint16_t x, uint16_t y)
uint8_t v = y;
// Get a signed version of the above for the grad function
- int8_t xx = (x>>1) & 0x7F;
- int8_t yy = (y>>1) & 0x7F;
+ int8_t xx = ((uint8_t)(x)>>1) & 0x7F;
+ int8_t yy = ((uint8_t)(y)>>1) & 0x7F;
uint8_t N = 0x80;
// u = FADE(u); v = FADE(v); w = FADE(w);
@@ -421,7 +421,7 @@ int8_t inoise8_raw(uint16_t x)
uint8_t u = x;
// Get a signed version of the above for the grad function
- int8_t xx = (x>>1) & 0x7F;
+ int8_t xx = ((uint8_t)(x)>>1) & 0x7F;
uint8_t N = 0x80;
u = scale8(u,u);