Skip to content

Commit

Permalink
#3250: Save a few string conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jan 10, 2021
1 parent c6f0ddf commit 86f7ee7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
10 changes: 4 additions & 6 deletions libs/wxutil/dataview/ResourceTreeView.cpp
Expand Up @@ -5,7 +5,6 @@
#include "ifavourites.h"
#include "../menu/IconTextMenuItem.h"
#include "TreeViewItemStyle.h"
#include "string/case_conv.h"
#include <wx/artprov.h>

namespace wxutil
Expand Down Expand Up @@ -200,10 +199,10 @@ void ResourceTreeView::PopulateContextMenu(wxutil::PopupMenu& popupMenu)
);
}

void ResourceTreeView::SetFilterText(const std::string& filterText)
void ResourceTreeView::SetFilterText(const wxString& filterText)
{
// We use the lower-case copy of the given filter text
_filterText = string::to_lower_copy(filterText);
_filterText = filterText.Lower();

wxDataViewItem item = GetSelection();

Expand Down Expand Up @@ -525,10 +524,9 @@ bool ResourceTreeView::RowContainsSearchString(wxutil::TreeModel::Row& row)
{
wxDataViewIconText iconAndName = row[_columns.iconAndName];

auto displayString = iconAndName.GetText().ToStdString();
string::to_lower(displayString);
auto displayString = iconAndName.GetText().Lower();

return displayString.find(_filterText) != std::string::npos;
return displayString.Contains(_filterText);
}

bool ResourceTreeView::IsTreeModelRowFilteredRecursively(wxutil::TreeModel::Row& row)
Expand Down
4 changes: 2 additions & 2 deletions libs/wxutil/dataview/ResourceTreeView.h
Expand Up @@ -88,7 +88,7 @@ class ResourceTreeView :

decl::Type _declType;

std::string _filterText;
wxString _filterText;

public:
ResourceTreeView(wxWindow* parent, const Columns& columns, long style = wxDV_SINGLE);
Expand All @@ -107,7 +107,7 @@ class ResourceTreeView :
// this string will match against the default iconAndName column,
// all rows not containing the string will be hidden.
// Filtering happens case-insensitively.
virtual void SetFilterText(const std::string& filterText);
virtual void SetFilterText(const wxString& filterText);

// Removes the string filter
virtual void ClearFilterText();
Expand Down
2 changes: 1 addition & 1 deletion libs/wxutil/dataview/ResourceTreeViewToolbar.cpp
Expand Up @@ -44,7 +44,7 @@ ResourceTreeViewToolbar::ResourceTreeViewToolbar(wxWindow* parent, ResourceTreeV
{
if (_treeView != nullptr)
{
_treeView->SetFilterText(ev.GetString().ToStdString());
_treeView->SetFilterText(ev.GetString());
}
});
filterEntry->Bind(wxEVT_CHAR, &ResourceTreeViewToolbar::_onEntryChar, this);
Expand Down

0 comments on commit 86f7ee7

Please sign in to comment.