diff options
| Commit | 0abd62e8c8a8648366ef12d024b821c6f55f2719 (patch) | |
|---|---|---|
| Author | 2025-07-23 15:01:09 +0300 | |
| Committer | 2025-07-23 15:01:09 +0300 | |
| Files | d1cb9fc85e0c34eaf98122820afbb796d5e1e789 /src | |
| screen-generator-nemetschek-main.tar screen-generator-nemetschek-main.tar.gz screen-generator-nemetschek-main.zip | ||
| Parent | de14e63ab5a26f26e08a9ae33f456465d466776f (diff) | |
Euclidean is faster
1 files changed, 3 insertions, 3 deletions
| -rw-r--r-- | src/LEDVideoWall.cpp | 6 |
diff --git a/src/LEDVideoWall.cpp b/src/LEDVideoWall.cpp index 5fb69ac..abdbcf0 100644 --- a/src/LEDVideoWall.cpp +++ b/src/LEDVideoWall.cpp @@ -18,9 +18,9 @@ LEDVideoWall* LEDVideoWall::Freeform(mm panel_width, mm panel_height, mm wall_ma // GCD is available in stl from C++17 onwards, but I'm still reimplementing it unsigned int gcd(unsigned int a, unsigned int b) { - if (a == b) return a; - if (a < b) return gcd(b, a); - return gcd(a - b, b); + // Eucledian algorithm https://en.wikipedia.org/wiki/Greatest_common_divisor#Euclidean_algorithm + if (b == 0) return a; + return gcd(b, a % b); } LEDVideoWall* LEDVideoWall::Aspect(mm panel_width, mm panel_height, unsigned int aspect_width, unsigned int aspect_height) { |