]> OCCT Git - occt.git/commitdiff
Coding - Resolving C26498 warning
authordpasukhi <dpasukhi@opencascade.com>
Mon, 9 Sep 2024 18:23:10 +0000 (18:23 +0000)
committerdpasukhi <dpasukhi@opencascade.com>
Sat, 14 Sep 2024 20:26:41 +0000 (20:26 +0000)
C26498 - marking variables constexpr to improve performance

12 files changed:
src/BRepBuilderAPI/BRepBuilderAPI_FastSewing.cxx
src/Bnd/Bnd_Box.cxx
src/BndLib/BndLib_AddSurface.cxx
src/GccAna/GccAna_Lin2dTanPer.cxx
src/Graphic3d/Graphic3d_Structure.cxx
src/IntTools/IntTools_FaceFace.cxx
src/LocOpe/LocOpe_CSIntersector.cxx
src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx
src/QABugs/QABugs_11.cxx
src/Standard/Standard_ShortReal.hxx
src/TopOpeBRepTool/TopOpeBRepTool_ShapeTool.cxx
src/math/math_BissecNewton.cxx

index a4ac6438fc56556da04283375d15e271f92e18c5..712847cc0dab78721818b8da7f80aaf365c9096b 100644 (file)
@@ -43,7 +43,7 @@ static Standard_Integer
       IntersectionOfSets( const NCollection_List<Standard_Integer>& theSet1,
                           const NCollection_List<Standard_Integer>& theSet2)
 {
-  const Standard_Integer anIntMax = IntegerLast();
+  constexpr Standard_Integer anIntMax = IntegerLast();
   Standard_Integer aRetVal = anIntMax;
   for(NCollection_List<Standard_Integer>::Iterator
                             anIt1 = theSet1.begin().Iterator();
index eba846a5f54a6595e5804f133ec321c7d6ffee17..370db15bbc24c60ff0503f9b6dbdb5ce6b4c2e91 100644 (file)
@@ -720,7 +720,7 @@ static Standard_Boolean IsSegmentOut(Standard_Real x1,Standard_Real y1,
                                      Standard_Real xs1,Standard_Real ys1,
                                      Standard_Real xs2,Standard_Real ys2)
 {
-  Standard_Real eps = RealSmall();
+  constexpr Standard_Real eps = RealSmall();
   Standard_Real xsmin = Min (xs1, xs2);
   Standard_Real xsmax = Max (xs1, xs2);
   Standard_Real ysmin = Min (ys1, ys2);
@@ -765,7 +765,7 @@ Standard_Boolean Bnd_Box::IsOut(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Dir
   if        (IsWhole())  return Standard_False;
   else if   (IsVoid())   return Standard_True;
 
-  Standard_Real eps = RealSmall();
+  constexpr Standard_Real eps = RealSmall();
   Standard_Real myXmin, myYmin, myZmin, myXmax, myYmax, myZmax;
   Get (myXmin, myYmin, myZmin, myXmax, myYmax, myZmax);
 
index e02780b13ab64f3e5db01dbdb2aad1692b1ca308..9a9bc53accf17605a466e4068f206258408c16f8 100644 (file)
@@ -180,7 +180,7 @@ static void TreatInfinitePlane(const gp_Pln        &aPlane,
 {
   // Get 3 coordinate axes of the plane.
   const gp_Dir        &aNorm        = aPlane.Axis().Direction();
-  const Standard_Real  anAngularTol = RealEpsilon();
+  constexpr Standard_Real  anAngularTol = RealEpsilon();
 
   // Get location of the plane as its barycenter
   gp_Pnt aLocation = BaryCenter(aPlane, aUMin, aUMax, aVMin, aVMax);
index fc30993b7dfc2ece88a40a0772401f2871e8bd29..6b1433311ed77d26354a463a26db2a7c5fe4eb06 100644 (file)
@@ -99,7 +99,7 @@ GccAna_Lin2dTanPer::
    IntAna2d_AnaIntersection Intp(linsol(1),TheCircle);
    if (Intp.IsDone()) {
      if (!Intp.IsEmpty()) {
-       Standard_Real maxdist = RealLast();
+       constexpr Standard_Real maxdist = RealLast();
        for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
         if (Intp.Point(i).Value().Distance(ThePnt) < maxdist) {
           pntint2sol(1) = Intp.Point(i).Value();
@@ -244,7 +244,7 @@ GccAna_Lin2dTanPer::
      IntAna2d_AnaIntersection Intp(linsol(NbrSol),TheCircle);
      if (Intp.IsDone()) {
        if (!Intp.IsEmpty()) {
-        Standard_Real maxdist = RealLast();
+        constexpr Standard_Real maxdist = RealLast();
         for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
           if (Intp.Point(i).Value().Distance(pnttg1sol(NbrSol)) < maxdist) {
             pntint2sol(NbrSol) = Intp.Point(i).Value();
index eace8db06f574d6c7ae66bdecbbdf241de7ba148..e4ff9c89bfd48366310f5644370185bf880e4d3c 100644 (file)
@@ -668,8 +668,8 @@ Bnd_Box Graphic3d_Structure::MinMaxValues (const Standard_Boolean theToIgnoreInf
   aResult.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
                   aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
 
-  Standard_Real aLimMin = ShortRealFirst() + 1.0;
-  Standard_Real aLimMax = ShortRealLast()  - 1.0;
+  constexpr Standard_Real aLimMin = ShortRealFirst() + 1.0;
+  constexpr Standard_Real aLimMax = ShortRealLast()  - 1.0;
   gp_Pnt aMin = aResult.CornerMin();
   gp_Pnt aMax = aResult.CornerMax();
   if (aMin.X() < aLimMin && aMin.Y() < aLimMin && aMin.Z() < aLimMin
@@ -847,8 +847,8 @@ void Graphic3d_Structure::Transforms (const gp_Trsf& theTrsf,
                                       const Standard_Real theX,    const Standard_Real theY,    const Standard_Real theZ,
                                       Standard_Real&      theNewX, Standard_Real&      theNewY, Standard_Real&      theNewZ)
 {
-  const Standard_Real aRL = RealLast();
-  const Standard_Real aRF = RealFirst();
+  constexpr Standard_Real aRL = RealLast();
+  constexpr Standard_Real aRF = RealFirst();
   theNewX = theX;
   theNewY = theY;
   theNewZ = theZ;
index d2c99d7acbe9df8799121c2e6fee14c2b316ff7f..3299a49e2935eb96be112c73fff47f2b073cd8c9 100644 (file)
@@ -977,7 +977,7 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
       fprm=aSeqFprm(i);
       lprm=aSeqLprm(i);
       //
-      Standard_Real aRealEpsilon=RealEpsilon();
+      constexpr Standard_Real aRealEpsilon=RealEpsilon();
       if (Abs(fprm) > aRealEpsilon || Abs(lprm-2.*M_PI) > aRealEpsilon) {
         //==============================================
         ////
index bc4ef66d298ea843f4daa6483ea60906bfabb209..26cf667e8ba8a65ff314366fa2a22c2e4f7bf03f 100644 (file)
@@ -89,8 +89,8 @@ void LocOpe_CSIntersector::Perform(const LocOpe_SequenceOfLin& Slin)
   myPoints = 
     (LocOpe_SequenceOfPntFace *) new LocOpe_SequenceOfPntFace[myNbelem];
 
-  Standard_Real binf = RealFirst();
-  Standard_Real bsup = RealLast();
+  constexpr Standard_Real binf = RealFirst();
+  constexpr Standard_Real bsup = RealLast();
   TopExp_Explorer exp(myShape,TopAbs_FACE);
   for (; exp.More(); exp.Next()) {
     const TopoDS_Face& theface = TopoDS::Face(exp.Current());
index 01ece0cefe92497f4e65856881120cf8e54d212b..655edb7966372b97332a909ed3e63c0e1d20435a 100644 (file)
@@ -79,7 +79,8 @@ public:
 static inline Standard_Integer getNearestPow2( Standard_Integer theValue )
 {
   // Precaution against overflow
-  Standard_Integer aHalfMax = IntegerLast() >> 1, aRes = 1;
+  constexpr Standard_Integer aHalfMax = IntegerLast() >> 1;
+  Standard_Integer aRes = 1;
   if ( theValue > aHalfMax ) theValue = aHalfMax;
   while ( aRes < theValue ) aRes <<= 1;
   return aRes;
index e84883a962f530c90139982fa13cff201361f3ec..d871614a920f3d0aac029e4f0e2f9befd0ead5dd 100644 (file)
@@ -2187,10 +2187,20 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       di << "(Integer) Overflow...";
       //std::cout.flush();
       di << "\n";
-      Standard_Integer res, i=IntegerLast();
-      res = i + 1;
-      //++++ std::cout << " -- "<<res<<"="<<i<<"+1   Does not Caught... KO"<< std::endl;
-      //++++ Succes = Standard_False;
+#if defined(__clang__)
+  #pragma clang diagnostic push
+  #pragma clang diagnostic ignored "-Winteger-overflow"
+#elif defined(__GNUC__)
+  #pragma GCC diagnostic push
+  #pragma GCC diagnostic ignored "-Woverflow"
+#endif
+      constexpr Standard_Integer i=IntegerLast();
+      Standard_Integer res = i + 1;
+#if defined(__clang__)
+  #pragma clang diagnostic pop
+#elif defined(__GNUC__)
+  #pragma GCC diagnostic pop
+#endif
       di << "Not caught: " << i << " + 1 = " << res << ", still OK\n";
     }
     catch(Standard_Overflow const&) {
@@ -2212,8 +2222,8 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       di << "(Real) Overflow...";
       //std::cout.flush();
       di << "\n";
-      Standard_Real res, r=RealLast();
-      res = r * r;
+      constexpr Standard_Real r = RealLast();
+      Standard_Real res = r * r;
       
       (void)sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
 
@@ -2244,8 +2254,8 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       di << "(Real) Underflow";
       //std::cout.flush();
       di << "\n";
-      Standard_Real res, r = RealSmall();
-      res = r * r;
+      constexpr Standard_Real r = RealSmall();
+      Standard_Real res = r * r;
       //res = res + 1.;
       //++++ std::cout<<"-- "<<res<<"="<<r<<"*"<<r<<"   Does not Caught... KO"<<std::endl;
       //++++ Succes = Standard_False;
@@ -4540,7 +4550,7 @@ Standard_Integer OCC17424 (Draw_Interpretor& di, Standard_Integer argc, const ch
   gp_Dir dir(X_Dir, Y_Dir, Z_Dir);
   gp_Lin ray(origin, dir);
 
-  Standard_Real PSup = RealLast();
+  constexpr Standard_Real PSup = RealLast();
   intersector.PerformNearest(ray, PInf, PSup);
   if (intersector.NbPnt() != 0)
     {
index 34230ca46983d139616363b4d49470f048bdef56..cf9927248ecdba0e60580f7ab90392055e89b968 100644 (file)
@@ -60,9 +60,8 @@ constexpr Standard_ShortReal  ShortRealEpsilon()
 //-------------------------------------------------------------------
 // ShortRealFirst : Returns the minimum negative value of a ShortReal
 //-------------------------------------------------------------------
-inline Standard_ShortReal     ShortRealFirst() 
-{ Standard_ShortReal MaxFloatTmp = -FLT_MAX;
-  return MaxFloatTmp; }
+constexpr Standard_ShortReal     ShortRealFirst() 
+{ return -FLT_MAX; }
   
 //-------------------------------------------------------------------
 // ShortRealFirst10Exp : Returns the minimum value of exponent(base 10) of
index 7b86a04d8bf11ae77ed38e118862c88bebc7b693..db2f57b9a861b2b0cd95b3a444a3238dc9ddae35 100644 (file)
@@ -566,7 +566,8 @@ Standard_Real TopOpeBRepTool_ShapeTool::EdgeData
   C = BL.Curvature();
 
   // xpu150399 cto900R4
-  Standard_Real tol1 = Epsilon(0.), tol2 = RealLast();
+  const Standard_Real tol1 = Epsilon(0.);
+  constexpr Standard_Real tol2 = RealLast();
   Standard_Real tolm = Max(tol,Max(tol1,tol2));
 
   if ( Abs(C) > tolm ) BL.Normal(N);
index 88eecc5a2eaf8f6012ddf1fa436622b39f242ea2..db1289271992dac377eb594723fcab162a64d5ab 100644 (file)
@@ -67,7 +67,7 @@ void math_BissecNewton::Perform(math_FunctionWithDerivative& F,
     return;
   }
 //  Modified by Sergey KHROMOV - Wed Jan 22 12:06:45 2003 Begin
-  Standard_Real aFTol = RealEpsilon();
+  constexpr Standard_Real aFTol = RealEpsilon();
 
 //   if(fl * fh >= 0.0) {
   if(fl * fh > aFTol*aFTol) {