1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 14:02:57 +02:00

Less use of wxArrayString::Index() ...

... instead use the utility make_iterator_range and its index() or contains()
method.  This generic utility works with any container defining begin() and
end().

This further lessens dependency on wxWidgets container idioms.
This commit is contained in:
Paul Licameli
2019-03-04 02:13:40 -05:00
parent c68e336247
commit dd8eb9e3d9
21 changed files with 42 additions and 37 deletions

View File

@@ -1603,7 +1603,7 @@ void CommandManager::GetCategories(wxArrayString &cats)
for (const auto &entry : mCommandList) {
wxString cat = entry->labelTop;
if (cats.Index(cat) == wxNOT_FOUND) {
if ( ! make_iterator_range( cats ).contains(cat) ) {
cats.push_back(cat);
}
}

View File

@@ -277,7 +277,7 @@ bool BuiltinCommandsModule::IsPluginValid(const wxString & path, bool bFast)
{
// bFast is unused as checking in the list is fast.
static_cast<void>(bFast); // avoid unused variable warning
return mNames.Index(path) != wxNOT_FOUND;
return make_iterator_range( mNames ).contains( path );
}
ComponentInterface *BuiltinCommandsModule::CreateInstance(const wxString & path)
@@ -302,9 +302,10 @@ void BuiltinCommandsModule::DeleteInstance(ComponentInterface *instance)
std::unique_ptr<AudacityCommand> BuiltinCommandsModule::Instantiate(const wxString & path)
{
wxASSERT(path.StartsWith(BUILTIN_GENERIC_COMMAND_PREFIX));
wxASSERT(mNames.Index(path) != wxNOT_FOUND);
auto index = make_iterator_range( mNames ).index( path );
wxASSERT( index != wxNOT_FOUND );
switch (mNames.Index(path))
switch ( index )
{
COMMAND_LIST;
EXCLUDE_LIST;

View File

@@ -107,7 +107,7 @@ public:
bool Validate(const wxVariant &v) override
{
SetConverted(v);
return (mOptions.Index(v.GetString()) != wxNOT_FOUND);
return make_iterator_range( mOptions ).contains( v.GetString() );
}
wxString GetDescription() const override
{