Use Span.CopyTo(Span) in BigInteger's add and subtract (#83951), fixes #83457
* Use Span.CopyTo(Span) in BigInteger's add and subtract
In BigIntegerCalculator methods Add and Subtract, if sizes of arguments
differ, after processing the part of size of the right (small) argument,
there was loop of add/sub carry value. When the carry value once become
zero, in fact the rest of the larger argument can be copied to the result.
With this commit the second loop is interrupted when carry become zero
and applies fast Span.CopyTo(Span) to the rest part.
This optimization applied only when size of the greatest argument is more
or equal to const CopyToThreshold introduced in this commit. This const
is 8 now.
See #83457 for details.
Co-authored-by: NAdam Sitnik <adam.sitnik@gmail.com>
Showing
想要评论请 注册 或 登录