From: dpasukhi Date: Sun, 14 Apr 2024 10:12:01 +0000 (+0000) Subject: Coding - GeomTools performance update #19 X-Git-Tag: V7_9_0_beta1~88 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=4bda7ebe40aa00350a33747c191bf499aad9b011;p=occt.git Coding - GeomTools performance update #19 Update size of buffer for the brep parsing according standard --- diff --git a/src/GeomTools/GeomTools.cxx b/src/GeomTools/GeomTools.cxx index 767fa178a2..0e01cf060e 100644 --- a/src/GeomTools/GeomTools.cxx +++ b/src/GeomTools/GeomTools.cxx @@ -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); }