From 005cbe51c4d5aae3067eda82fa3c51a890c653a7 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Thu, 20 Feb 2025 10:18:58 +0100 Subject: [PATCH] use existing functions - std::replace and MDAL::split instead of custom function Co-authored-by: Stefanos Natsis --- mdal/frmts/mdal_mike21.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/mdal/frmts/mdal_mike21.cpp b/mdal/frmts/mdal_mike21.cpp index 65dfdfb4..a5e2b9df 100644 --- a/mdal/frmts/mdal_mike21.cpp +++ b/mdal/frmts/mdal_mike21.cpp @@ -23,12 +23,6 @@ #define DRIVER_NAME "Mike21" -void replaceTabsWithSpaces(std::string& str) { - for (size_t i = 0; i < str.length(); ++i) { - if (str[i] == '\t') { - str[i] = ' '; - } - } } static bool parse_vertex_id_gaps( std::map &vertexIDtoIndex, size_t vertexIndex, size_t vertexID ) @@ -246,8 +240,8 @@ std::unique_ptr MDAL::DriverMike21::load( const std::string &meshFil { if ( 0 < lineNumber && lineNumber < mVertexCount + 1 ) { - replaceTabsWithSpaces(line); - chunks = MDAL::split( MDAL::trim( line ),' '); + std::replace( line.begin(), line.end(), '\t', ' ' ); + chunks = MDAL::split( MDAL::trim( line ), ' ' ); if ( chunks.size() != 5 ) { MDAL::Log::error( MDAL_Status::Err_InvalidData, name(), "vertex line in invalid format." ); @@ -284,8 +278,8 @@ std::unique_ptr MDAL::DriverMike21::load( const std::string &meshFil if ( mVertexCount + 1 < lineNumber ) { - replaceTabsWithSpaces(line); - chunks = MDAL::split( MDAL::trim( line ),' '); + std::replace( line.begin(), line.end(), '\t', ' ' ); + chunks = MDAL::split( MDAL::trim( line ), ' ' ); assert( faceIndex < faceCount ); size_t faceVertexCount = chunks.size() - 1;