diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index 34f00ceae2..7065cf1aa5 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -430,7 +430,7 @@ namespace NumberToStringConverters return dp; } - char* doubleToString (char* buffer, int numChars, double n, int numDecPlaces, size_t& len) noexcept + char* doubleToString (char* buffer, const int numChars, double n, int numDecPlaces, size_t& len) noexcept { if (numDecPlaces > 0 && n > -1.0e20 && n < 1.0e20) { @@ -983,76 +983,50 @@ bool String::containsWholeWordIgnoreCase (const String& wordToLookFor) const noe } //============================================================================== -namespace WildCardHelpers +template +struct WildCardMatcher { - int indexOfMatch (const String::CharPointerType& wildcard, - String::CharPointerType test, - const bool ignoreCase) noexcept + static bool matches (CharPointer wildcard, CharPointer test, const bool ignoreCase) noexcept { - int start = 0; - - while (! test.isEmpty()) + for (;;) { - String::CharPointerType t (test); - String::CharPointerType w (wildcard); + const juce_wchar wc = *wildcard; + const juce_wchar tc = *test; - for (;;) + if (wc == tc + || (ignoreCase && CharacterFunctions::toLowerCase (wc) == CharacterFunctions::toLowerCase (tc)) + || (wc == '?' && tc != 0)) { - const juce_wchar wc = *w; - const juce_wchar tc = *t; + if (wc == 0) + return true; - if (wc == tc - || (ignoreCase && w.toLowerCase() == t.toLowerCase()) - || (wc == '?' && tc != 0)) - { - if (wc == 0) - return start; - - ++t; - ++w; - } - else - { - if (wc == '*' && (w[1] == 0 || indexOfMatch (w + 1, t, ignoreCase) >= 0)) - return start; - - break; - } + ++test; + ++wildcard; + } + else + { + return wc == '*' && (wildcard[1] == 0 || matchesAnywhere (wildcard + 1, test, ignoreCase)); } - - ++start; - ++test; } - - return -1; } -} - -bool String::matchesWildcard (const String& wildcard, const bool ignoreCase) const noexcept -{ - CharPointerType w (wildcard.text); - CharPointerType t (text); - for (;;) + static bool matchesAnywhere (const CharPointer& wildcard, CharPointer test, const bool ignoreCase) noexcept { - const juce_wchar wc = *w; - const juce_wchar tc = *t; - - if (wc == tc - || (ignoreCase && w.toLowerCase() == t.toLowerCase()) - || (wc == '?' && tc != 0)) + while (! test.isEmpty()) { - if (wc == 0) + if (matches (wildcard, test, ignoreCase)) return true; - ++w; - ++t; - } - else - { - return wc == '*' && (w[1] == 0 || WildCardHelpers::indexOfMatch (w + 1, t, ignoreCase) >= 0); + ++test; } + + return false; } +}; + +bool String::matchesWildcard (const String& wildcard, const bool ignoreCase) const noexcept +{ + return WildCardMatcher::matches (wildcard.text, text, ignoreCase); } //============================================================================== @@ -2090,7 +2064,7 @@ String String::fromUTF8 (const char* const buffer, int bufferSizeBytes) } #if JUCE_MSVC - #pragma warning (pop) + #pragma warning (pop) #endif //============================================================================== diff --git a/modules/juce_core/text/juce_String.h b/modules/juce_core/text/juce_String.h index 7153b5fce7..fb7d5b2148 100644 --- a/modules/juce_core/text/juce_String.h +++ b/modules/juce_core/text/juce_String.h @@ -33,8 +33,8 @@ #endif #if JUCE_MSVC - #pragma warning (push) - #pragma warning (disable: 4514 4996) + #pragma warning (push) + #pragma warning (disable: 4514 4996) #endif #include "../memory/juce_Atomic.h" @@ -44,7 +44,7 @@ #include "juce_CharPointer_ASCII.h" #if JUCE_MSVC - #pragma warning (pop) + #pragma warning (pop) #endif class OutputStream; diff --git a/modules/juce_gui_basics/native/juce_mac_MainMenu.mm b/modules/juce_gui_basics/native/juce_mac_MainMenu.mm index 1b0fc5ef3f..58c7eb9abe 100644 --- a/modules/juce_gui_basics/native/juce_mac_MainMenu.mm +++ b/modules/juce_gui_basics/native/juce_mac_MainMenu.mm @@ -163,7 +163,7 @@ public: [menu performSelector: @selector (cancelTracking)]; } - if (Time::getMillisecondCounter() > lastUpdateTime + 500) + if (Time::getMillisecondCounter() > lastUpdateTime + 100) (new AsyncMenuUpdater())->post(); }