@@ -47,7 +47,7 @@ using namespace Firebird;
4747namespace {
4848
4949const CInt128 i64max (MAX_SINT64), i64min(MIN_SINT64);
50- const double p2_32 = 4294967296.0 ;
50+ constexpr double p2_32 = 4294967296.0 ;
5151const I128limit i128limit;
5252const CInt128 minus1 (-1 );
5353
@@ -166,7 +166,7 @@ void Int128::toString(int scale, string& to) const
166166 }
167167 else
168168 {
169- unsigned posScale = -scale;
169+ const unsigned posScale = -scale;
170170 if (posScale > to.length ())
171171 {
172172 string tmp (posScale - to.length (), ' 0' );
@@ -241,12 +241,12 @@ Int128 Int128::div(Int128 op2, int scale) const
241241 return op1;
242242}
243243
244- void Int128::zerodivide ()
244+ [[noreturn]] void Int128::zerodivide ()
245245{
246246 (Arg::Gds (isc_arith_except) << Arg::Gds (isc_exception_integer_divide_by_zero)).raise ();
247247}
248248
249- void Int128::overflow ()
249+ [[noreturn]] void Int128::overflow ()
250250{
251251 (Arg::Gds (isc_arith_except) << Arg::Gds (isc_exception_integer_overflow)).raise ();
252252}
@@ -288,7 +288,7 @@ CInt128 MAX_Int128(CInt128::MkMax);
288288namespace {
289289
290290const CInt128 i64max (MAX_SINT64), i64min(MIN_SINT64);
291- const double p2_32 = 4294967296.0 ;
291+ constexpr double p2_32 = 4294967296.0 ;
292292const I128limit i128limit;
293293const CInt128 minus1 (-1 );
294294
@@ -425,7 +425,7 @@ void Int128::toString(int scale, unsigned length, char* to) const
425425void Int128::toString (int scale, string& to) const
426426{
427427 v.ToStringBase (to);
428- bool sgn = to[0 ] == ' -' ;
428+ const bool sgn = to[0 ] == ' -' ;
429429 if (sgn)
430430 to.erase (0 , 1 );
431431
@@ -444,7 +444,7 @@ void Int128::toString(int scale, string& to) const
444444 }
445445 else
446446 {
447- unsigned posScale = -scale;
447+ const unsigned posScale = -scale;
448448 if (posScale > to.length ())
449449 {
450450 string tmp (posScale - to.length (), ' 0' );
@@ -511,7 +511,7 @@ Int128 Int128::div(Int128 op2, int scale) const
511511
512512 // Scale op1 by as many of the needed powers of 10 as possible without an overflow.
513513 CInt128 op1 (*this );
514- int sign1 = op1.sign ();
514+ const int sign1 = op1.sign ();
515515 while ((scale < 0 ) && (sign1 >= 0 ? op1.compare (MAX_BY10) <= 0 : op1.compare (MIN_BY10) >= 0 ))
516516 {
517517 op1 *= 10 ;
@@ -537,17 +537,17 @@ Int128 Int128::div(Int128 op2, int scale) const
537537 return op1;
538538}
539539
540- void Int128::getTable32 (unsigned * dwords) const
540+ void Int128::getTable32 (unsigned * dwords) const noexcept
541541{
542542 static_assert ((sizeof (v.table [0 ]) == 4 ) || (sizeof (v.table [0 ]) == 8 ),
543543 " Unsupported size of integer in ttmath" );
544544
545- if (sizeof (v.table [0 ]) == 4 )
545+ if constexpr (sizeof (v.table [0 ]) == 4 )
546546 {
547547 for (int i = 0 ; i < 4 ; ++i)
548548 dwords[i] = v.table [i];
549549 }
550- else if (sizeof (v.table [0 ]) == 8 )
550+ else if constexpr (sizeof (v.table [0 ]) == 8 )
551551 {
552552 for (int i = 0 ; i < 2 ; ++i)
553553 {
@@ -557,12 +557,12 @@ void Int128::getTable32(unsigned* dwords) const
557557 }
558558}
559559
560- void Int128::setTable32 (const unsigned * dwords)
560+ void Int128::setTable32 (const unsigned * dwords) noexcept
561561{
562562 static_assert ((sizeof (v.table [0 ]) == 4 ) || (sizeof (v.table [0 ]) == 8 ),
563563 " Unsupported size of integer in ttmath" );
564564
565- if (sizeof (v.table [0 ]) == 4 )
565+ if constexpr (sizeof (v.table [0 ]) == 4 )
566566 {
567567 for (int i = 0 ; i < 4 ; ++i)
568568 v.table [i] = dwords[i];
@@ -582,7 +582,7 @@ Int128 Int128::operator&=(FB_UINT64 mask)
582582{
583583 v.table [0 ] &= mask;
584584 unsigned i = 1 ;
585- if (sizeof (v.table [0 ]) == 4 )
585+ if constexpr (sizeof (v.table [0 ]) == 4 )
586586 {
587587 i = 2 ;
588588 v.table [1 ] &= (mask >> 32 );
@@ -602,12 +602,12 @@ Int128 Int128::operator&=(ULONG mask)
602602 return *this ;
603603}
604604
605- void Int128::zerodivide ()
605+ [[noreturn]] void Int128::zerodivide ()
606606{
607607 (Arg::Gds (isc_arith_except) << Arg::Gds (isc_exception_integer_divide_by_zero)).raise ();
608608}
609609
610- void Int128::overflow ()
610+ [[noreturn]] void Int128::overflow ()
611611{
612612 (Arg::Gds (isc_arith_except) << Arg::Gds (isc_exception_integer_overflow)).raise ();
613613}
0 commit comments