From 5cade8d33750f9647e8a930488a481a85488db4d Mon Sep 17 00:00:00 2001 From: heisenbuug Date: Tue, 26 Oct 2021 13:26:30 +0530 Subject: [PATCH] minor bug --- src/mlpack/core/data/string_algorithms.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mlpack/core/data/string_algorithms.hpp b/src/mlpack/core/data/string_algorithms.hpp index b4414d5a73..ef01815af0 100644 --- a/src/mlpack/core/data/string_algorithms.hpp +++ b/src/mlpack/core/data/string_algorithms.hpp @@ -41,9 +41,12 @@ inline void Trim(std::string& str) while (std::isspace(str[endIndex])) endIndex--; - std::string trimmedStr = (endIndex - startIndex == str.size()) ? - std::move(str) : str.substr(startIndex, - endIndex - startIndex + 1); + std::string trimmedStr; + + if (endIndex - startIndex == str.size()) + trimmedStr = std::move(str); + else + trimmedStr = str.substr(startIndex, endIndex - startIndex + 1); str = trimmedStr; } @@ -88,6 +91,8 @@ inline void TrimIf(std::string &str, std::function func) break; } + std::string trimmedStr; + if (endIndex - startIndex == str.size()) trimmedStr = std::move(str); else