]> OCCT Git - occt.git/commitdiff
Coding - GeomTools performance update #19
authordpasukhi <dmitry.pasukhin@opencascade.com>
Sun, 14 Apr 2024 10:12:01 +0000 (10:12 +0000)
committerdpasukhi <dpasukhi@opencascade.com>
Sat, 21 Dec 2024 11:13:07 +0000 (11:13 +0000)
Update size of buffer for the brep parsing according standard

src/GeomTools/GeomTools.cxx

index 767fa178a2f8b2a6cc00be1216c06c608513ac8c..0e01cf060e0ef32a53976f4268abf1783209f821 100644 (file)
@@ -96,16 +96,21 @@ Handle(GeomTools_UndefinedTypeHandler) GeomTools::GetUndefinedTypeHandler()
 //purpose  : 
 //=======================================================================
 
-void GeomTools::GetReal(Standard_IStream& IS,Standard_Real& theValue)
+void GeomTools::GetReal(Standard_IStream& IS, Standard_Real& theValue)
 {
   theValue = 0.;
-  if (IS.eof()) 
+  if (IS.eof())
+  {
     return;
-
-  char buffer[256];
-  buffer[0] = '\0';
-  std::streamsize anOldWide = IS.width(256);
-  IS >> buffer;
+  }
+  // According IEEE-754 Specification and standard stream parameters
+  // the most optimal buffer length not less then 25
+  constexpr size_t THE_BUFFER_SIZE = 32;
+  char             aBuffer[THE_BUFFER_SIZE];
+
+  aBuffer[0]                = '\0';
+  std::streamsize anOldWide = IS.width(THE_BUFFER_SIZE - 1);
+  IS >> aBuffer;
   IS.width(anOldWide);
-  theValue = Strtod(buffer, NULL);
+  theValue = Strtod(aBuffer, nullptr);
 }