The getGcd function defined at src/utils.ts is dealing with BigInts, so I think it might be a good idea to use Stein's algorithm only if both ints are too large. I'm aware the function is already optimized enough, and adding more code would make minification harder, but this could increase performance.
I already have a hybrid implementation here, but it's too complicated because it also uses Lehmer's algo, which I think is overkill for both libraries, so it shouldn't be included. As some source comments point out, computing the GCD of 2 Mersennes can be done calculating the bitlength, which we can get "for free" if we use an iterative isMersenne helper function, instead of the short expression approach my library uses.
If this is approved, I'll make a pull request with the changes. I'll start writing a small draft to post it here
The
getGcdfunction defined at src/utils.ts is dealing withBigInts, so I think it might be a good idea to use Stein's algorithm only if both ints are too large. I'm aware the function is already optimized enough, and adding more code would make minification harder, but this could increase performance.I already have a hybrid implementation here, but it's too complicated because it also uses Lehmer's algo, which I think is overkill for both libraries, so it shouldn't be included. As some source comments point out, computing the GCD of 2 Mersennes can be done calculating the bitlength, which we can get "for free" if we use an iterative
isMersennehelper function, instead of the short expression approach my library uses.If this is approved, I'll make a pull request with the changes. I'll start writing a small draft to post it here