From 89e454a65b1893aa112dea237f662f08c165fa9e Mon Sep 17 00:00:00 2001 From: fwcd Date: Wed, 10 Apr 2019 00:12:58 +0200 Subject: [PATCH] Pass numbers in the remaining arithmetic functions by const reference --- src/CalcManager/Ratpack/basex.cpp | 12 ++++++------ src/CalcManager/Ratpack/logic.cpp | 6 +++--- src/CalcManager/Ratpack/support.cpp | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/CalcManager/Ratpack/basex.cpp b/src/CalcManager/Ratpack/basex.cpp index 25c98a81..787a6831 100644 --- a/src/CalcManager/Ratpack/basex.cpp +++ b/src/CalcManager/Ratpack/basex.cpp @@ -19,7 +19,7 @@ using namespace std; -void _mulnumx( NUMBER *pa, NUMBER b ); +void _mulnumx( NUMBER *pa, const NUMBER &b ); //---------------------------------------------------------------------------- // @@ -78,13 +78,13 @@ void __inline mulnumx( NUMBER *pa, const NUMBER &b ) // //---------------------------------------------------------------------------- -void _mulnumx( NUMBER *pa, NUMBER b ) +void _mulnumx( NUMBER *pa, const NUMBER &b ) { NUMBER c; // c will contain the result. NUMBER a; // a is the dereferenced number pointer from *pa vector::iterator ptra; // ptra is an iterator pointing to the mantissa of a. - vector::iterator ptrb; // ptrb is an iterator pointing to the mantissa of b. + vector::const_iterator ptrb; // ptrb is an iterator pointing to the mantissa of b. vector::iterator ptrc; // ptrc is an iterator pointing to the mantissa of c. vector::iterator ptrcoffset; // ptrcoffset, is the anchor location of the next // single digit multiply partial result. @@ -201,7 +201,7 @@ void numpowi32x( _Inout_ NUMBER *proot, _In_ int32_t power ) } -void _divnumx( NUMBER *pa, NUMBER b, int32_t precision); +void _divnumx( NUMBER *pa, const NUMBER &b, int32_t precision); //---------------------------------------------------------------------------- // @@ -218,7 +218,7 @@ void _divnumx( NUMBER *pa, NUMBER b, int32_t precision); // //---------------------------------------------------------------------------- -void __inline divnumx( NUMBER *pa, NUMBER b, int32_t precision) +void __inline divnumx( NUMBER *pa, const NUMBER &b, int32_t precision) { if ( b.cdigit > 1 || b.mant[0] != 1 || b.exp != 0 ) @@ -257,7 +257,7 @@ void __inline divnumx( NUMBER *pa, NUMBER b, int32_t precision) // //---------------------------------------------------------------------------- -void _divnumx( NUMBER *pa, NUMBER b, int32_t precision) +void _divnumx( NUMBER *pa, const NUMBER &b, int32_t precision) { NUMBER a; // a is the dereferenced number pointer from *pa diff --git a/src/CalcManager/Ratpack/logic.cpp b/src/CalcManager/Ratpack/logic.cpp index f396ef8b..c841a11e 100644 --- a/src/CalcManager/Ratpack/logic.cpp +++ b/src/CalcManager/Ratpack/logic.cpp @@ -65,7 +65,7 @@ void rshrat( PRAT *pa, PRAT b, uint32_t radix, int32_t precision) } void boolrat( PRAT *pa, PRAT b, int func, uint32_t radix, int32_t precision); -void boolnum( NUMBER *pa, NUMBER b, int func ); +void boolnum( NUMBER *pa, const NUMBER &b, int func ); enum { @@ -130,13 +130,13 @@ void boolrat( PRAT *pa, PRAT b, int func, uint32_t radix, int32_t precision) // //--------------------------------------------------------------------------- -void boolnum( NUMBER *pa, NUMBER b, int func ) +void boolnum( NUMBER *pa, const NUMBER &b, int func ) { NUMBER c; NUMBER a; vector::iterator pcha; - vector::iterator pchb; + vector::const_iterator pchb; vector::iterator pchc; int32_t cdigits; int32_t mexp; diff --git a/src/CalcManager/Ratpack/support.cpp b/src/CalcManager/Ratpack/support.cpp index 92d7d75d..6fa2aff8 100644 --- a/src/CalcManager/Ratpack/support.cpp +++ b/src/CalcManager/Ratpack/support.cpp @@ -566,7 +566,7 @@ void _dumprawrat( const wchar_t *varname, PRAT rat, wostream& out) // // FUNCTION: _dumprawnum // -// ARGUMENTS: const wchar *name of variable, NUMBER num, output stream out +// ARGUMENTS: const wchar *name of variable, const NUMBER &num, output stream out // // RETURN: none, prints the results of a dump of the internal structures // of a NUMBER, suitable for READRAWNUM to stderr.