From 23e248260ea913227a8d224f64cd9ff592ac8b6b Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Thu, 1 Mar 2018 16:34:12 -0500 Subject: Inline some simple BigInt sign handling functions --- src/lib/math/bigint/bigint.cpp | 29 ----------------------------- src/lib/math/bigint/bigint.h | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/src/lib/math/bigint/bigint.cpp b/src/lib/math/bigint/bigint.cpp index ec0df8f2d..c21ce89fc 100644 --- a/src/lib/math/bigint/bigint.cpp +++ b/src/lib/math/bigint/bigint.cpp @@ -213,35 +213,6 @@ size_t BigInt::encoded_size(Base base) const throw Invalid_Argument("Unknown base for BigInt encoding"); } -/* -* Set the sign -*/ -void BigInt::set_sign(Sign s) - { - if(is_zero()) - m_signedness = Positive; - else - m_signedness = s; - } - -/* -* Reverse the value of the sign flag -*/ -void BigInt::flip_sign() - { - set_sign(reverse_sign()); - } - -/* -* Return the opposite value of the current sign -*/ -BigInt::Sign BigInt::reverse_sign() const - { - if(sign() == Positive) - return Negative; - return Positive; - } - /* * Return the negation of this number */ diff --git a/src/lib/math/bigint/bigint.h b/src/lib/math/bigint/bigint.h index 6e2f8dbde..5092187d9 100644 --- a/src/lib/math/bigint/bigint.h +++ b/src/lib/math/bigint/bigint.h @@ -409,18 +409,32 @@ class BOTAN_PUBLIC_API(2,0) BigInt final /** * @result the opposite sign of the represented integer value */ - Sign reverse_sign() const; + Sign reverse_sign() const + { + if(sign() == Positive) + return Negative; + return Positive; + } /** * Flip the sign of this BigInt */ - void flip_sign(); + void flip_sign() + { + set_sign(reverse_sign()); + } /** * Set sign of the integer * @param sign new Sign to set */ - void set_sign(Sign sign); + void set_sign(Sign sign) + { + if(is_zero()) + m_signedness = Positive; + else + m_signedness = sign; + } /** * @result absolute (positive) value of this -- cgit v1.2.3