Recursive function my_gcd with too many nesting
-
Hello,
We encountered a case in which one image could not be cropped : having a blank pop-up. For only one image, that seems quite normal.Developper mode :
There was a JS error saying that t.cropData was null.
The Ajax call to cpt_cropdata was bugging.
After long debug of the code in the function called by that ajax call, I could find out that the my_gcd function, which is recursive, was bugging when reaching its 87th nesting.
The dimensions of the image are 1056 * 263I looked after code for calculating a GCD, and found another function with
return ($a % $b) ? self::my_gcd($b,$a % $b) : $b;
instead of
return ( $a % $b )? self::my_gcd($b, abs($a – $b)) : $b;
and that seems to more efficient = less nesting of recursive.I’m note quite sure it is a better solution for all cases, but I don’t have any more problem with that image, and I tested it on other ones with no problems either.
What do you think about that ?
Have a good day
Sylvie
- The topic ‘Recursive function my_gcd with too many nesting’ is closed to new replies.