diff options
author | B Stack <bgstack15@gmail.com> | 2018-11-15 11:22:00 +0000 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2018-11-15 11:22:00 +0000 |
commit | 77c5c2503d459288720a8894349ac74e5eeec7c6 (patch) | |
tree | 30bf08d782d58174a0ca212b2e4b172fabd9c42c /zen/zstring.cpp | |
parent | Merge branch '10.5' into 'master' (diff) | |
parent | 10.6 (diff) | |
download | FreeFileSync-77c5c2503d459288720a8894349ac74e5eeec7c6.tar.gz FreeFileSync-77c5c2503d459288720a8894349ac74e5eeec7c6.tar.bz2 FreeFileSync-77c5c2503d459288720a8894349ac74e5eeec7c6.zip |
Merge branch '10.6' into 'master'10.6
10.6
See merge request opensource-tracking/FreeFileSync!3
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) |