From ad105117e1a360286b836dd994fabcf76c3a8ab2 Mon Sep 17 00:00:00 2001 From: lcjh <120989324@qq.com> Date: Sat, 25 Dec 2021 23:51:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=86=97=E4=BD=99=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 去除冗余判断,修正拼写错误 Signed-off-by: lcjh <120989324@qq.com> --- base/include/string_ex.h | 4 ++-- base/src/string_ex.cpp | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/base/include/string_ex.h b/base/include/string_ex.h index bcb7d4b..41be2ad 100755 --- a/base/include/string_ex.h +++ b/base/include/string_ex.h @@ -118,13 +118,13 @@ bool IsAsciiString(const std::string& str); /** * The str16ToStr8 function convert string16 to string8. - * If covert failed, return an empty string. + * If convert failed, return an empty string. */ std::string Str16ToStr8(const std::u16string& str16); /** * The Str8ToStr16 function convert string8 to string16. - * If covert failed, return an empty u16string. + * If convert failed, return an empty u16string. */ std::u16string Str8ToStr16(const std::string& str); } // namespace OHOS diff --git a/base/src/string_ex.cpp b/base/src/string_ex.cpp index 6665223..65ce7d2 100755 --- a/base/src/string_ex.cpp +++ b/base/src/string_ex.cpp @@ -216,14 +216,12 @@ string::size_type GetFirstSubStrBetween(const string& str, const string& left, void GetSubStrBetween(const string& str, const string& left, const string& right, vector& sub) { string subString; - string::size_type pos = 0; string strTmp = str; + string::size_type pos = GetFirstSubStrBetween(strTmp, left, right, subString); while (pos != string::npos) { + sub.push_back(subString); + strTmp = strTmp.substr(pos); pos = GetFirstSubStrBetween(strTmp, left, right, subString); - if (pos != string::npos) { - sub.push_back(subString); - strTmp = strTmp.substr(pos); - } } } -- Gitee