From 4cc70cb73ce5139b406fef1ed1e03ab1148e8174 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 31 May 2023 14:10:57 +0000 Subject: [PATCH] Optimize --- code/AssetLib/Obj/ObjFileParser.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/Obj/ObjFileParser.cpp b/code/AssetLib/Obj/ObjFileParser.cpp index 38fc0533e..432023264 100644 --- a/code/AssetLib/Obj/ObjFileParser.cpp +++ b/code/AssetLib/Obj/ObjFileParser.cpp @@ -456,8 +456,16 @@ void ObjFileParser::getFace(aiPrimitiveType type) { iPos = 0; } else { //OBJ USES 1 Base ARRAYS!!!! - std::string number(&(*m_DataIt), m_DataItEnd - m_DataIt); - const int iVal(::atoi(number.c_str())); + int iVal; + auto end = m_DataIt; + while (end < m_DataItEnd && *end != '\0') + ++end; + if (end != m_DataItEnd) { + iVal = ::atoi(&(*m_DataIt)); + } else { + std::string number(&(*m_DataIt), m_DataItEnd - m_DataIt); + iVal = ::atoi(number.c_str()); + } // increment iStep position based off of the sign and # of digits int tmp = iVal;