diff options
author | Jack Lloyd <[email protected]> | 2017-09-20 02:38:02 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-09-20 02:38:02 -0400 |
commit | d3b0cb47b7ea04fea0327a9fbdfd2224620836b2 (patch) | |
tree | f61cf718c520ce3dcc69f71c1e12c3cc05d0cbdc /src/lib | |
parent | b480445b757fa28087b71b050571d71aca624659 (diff) |
Use dword for bigint_divop if available
Results in FPE being about 5x faster
See #494
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/math/mp/mp_core.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/math/mp/mp_core.cpp b/src/lib/math/mp/mp_core.cpp index ff4efd945..40e45bc12 100644 --- a/src/lib/math/mp/mp_core.cpp +++ b/src/lib/math/mp/mp_core.cpp @@ -406,6 +406,10 @@ word bigint_divop(word n1, word n0, word d) if(d == 0) throw Invalid_Argument("bigint_divop divide by zero"); +#if defined(BOTAN_HAS_MP_DWORD) + return ((static_cast<dword>(n1) << MP_WORD_BITS) | n0) / d; +#else + word high = n1 % d, quotient = 0; for(size_t i = 0; i != MP_WORD_BITS; ++i) @@ -424,6 +428,7 @@ word bigint_divop(word n1, word n0, word d) } return quotient; +#endif } /* |