Browse Source

Tweaked some timings for mac native menus. Minor clean-ups.

tags/2021-05-28
Julian Storer 13 years ago
parent
commit
3744efa6ea
3 changed files with 34 additions and 60 deletions
  1. +30
    -56
      modules/juce_core/text/juce_String.cpp
  2. +3
    -3
      modules/juce_core/text/juce_String.h
  3. +1
    -1
      modules/juce_gui_basics/native/juce_mac_MainMenu.mm

+ 30
- 56
modules/juce_core/text/juce_String.cpp View File

@@ -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 <typename CharPointer>
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<CharPointerType>::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
//==============================================================================


+ 3
- 3
modules/juce_core/text/juce_String.h View File

@@ -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;


+ 1
- 1
modules/juce_gui_basics/native/juce_mac_MainMenu.mm View File

@@ -163,7 +163,7 @@ public:
[menu performSelector: @selector (cancelTracking)];
}
if (Time::getMillisecondCounter() > lastUpdateTime + 500)
if (Time::getMillisecondCounter() > lastUpdateTime + 100)
(new AsyncMenuUpdater())->post();
}


Loading…
Cancel
Save