diff options
author | B Stack <bgstack15@gmail.com> | 2018-11-13 06:58:56 -0500 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2018-11-13 06:58:56 -0500 |
commit | 076498028ff511afd88d93e7b0bf1d1a81093b3d (patch) | |
tree | 30bf08d782d58174a0ca212b2e4b172fabd9c42c /zen/zstring.cpp | |
parent | Merge branch '10.5' into 'master' (diff) | |
download | FreeFileSync-076498028ff511afd88d93e7b0bf1d1a81093b3d.tar.gz FreeFileSync-076498028ff511afd88d93e7b0bf1d1a81093b3d.tar.bz2 FreeFileSync-076498028ff511afd88d93e7b0bf1d1a81093b3d.zip |
10.6
Diffstat (limited to 'zen/zstring.cpp')
-rwxr-xr-x | zen/zstring.cpp | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/zen/zstring.cpp b/zen/zstring.cpp index 68609030..f8a34045 100755 --- a/zen/zstring.cpp +++ b/zen/zstring.cpp @@ -77,22 +77,19 @@ Zstring replaceCpyAsciiNoCase(const Zstring& str, const Zstring& oldTerm, const { if (oldTerm.empty()) return str; - - Zstring strU = str; - Zstring oldU = oldTerm; - - for (Zchar& c : strU) c = asciiToUpper(c); //can't use makeUpperCopy(): input/output sizes may differ! - for (Zchar& c : oldU) c = asciiToUpper(c); // Zstring output; for (size_t pos = 0;;) { - const size_t posFound = strU.find(oldU, pos); - if (posFound == Zstring::npos) + const size_t posFound = std::search(str.begin() + pos, str.end(), //can't use makeUpperCopy(): input/output sizes may differ! + oldTerm.begin(), oldTerm.end(), + [](Zchar charL, Zchar charR) { return asciiToUpper(charL) == asciiToUpper(charR); }) - str.begin(); + + if (posFound == str.size()) { if (pos == 0) //optimize "oldTerm not found": return ref-counted copy - return str; + return str; output.append(str.begin() + pos, str.end()); return output; } @@ -126,7 +123,7 @@ OS X (UTF8 char) ________________________ time per call | function */ -int compareLocalPath(const Zstring& lhs, const Zstring& rhs) +int compareNativePath(const Zstring& lhs, const Zstring& rhs) { assert(lhs.find(Zchar('\0')) == Zstring::npos); //don't expect embedded nulls! assert(rhs.find(Zchar('\0')) == Zstring::npos); // @@ -250,8 +247,3 @@ int compareNatural(const Zstring& lhs, const Zstring& rhs) } } - - -warn_static("clean up implementation of these two:") -//template <> inline bool isWhiteSpace(char c) -//template <> inline bool isWhiteSpace(wchar_t c) |