summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2018-04-29 17:15:34 +0200
committerMatteo Casalin <matteo.casalin@yahoo.com>2018-04-29 22:50:51 +0200
commit2a39163aef4211c9d19cb1faee7f55d3718355b6 (patch)
tree273d159ffb01ddd9bbbc5956fb8ddd0f92356f0f
parent132138eeb0d518218d9051744e2092d3340156af (diff)
Rework code to avoid getTokenCount/getToken
Change-Id: I46985c3edda9509f0a014ea351016dce599bda4a
-rw-r--r--vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx24
1 files changed, 15 insertions, 9 deletions
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
index e499350b12b4..a28af32d3595 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
@@ -41,7 +41,6 @@
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/ui/dialogs/ControlActions.hpp>
#include <com/sun/star/uno/Any.hxx>
-#include <comphelper/string.hxx>
#include <unx/gtk/gtkdata.hxx>
#include <unx/gtk/gtkinst.hxx>
@@ -705,16 +704,23 @@ namespace
bool lcl_matchFilter( const rtl::OUString& rFilter, const rtl::OUString& rExt )
{
- const int nCount = comphelper::string::getTokenCount( rFilter, ';' );
+ const sal_Int32 nBegin = rFilter.indexOf(rExt);
- for ( int n = 0; n != nCount; ++n )
- {
- const rtl::OUString aToken = rFilter.getToken( n, ';' );
- if ( aToken == rExt )
- return true;
- }
+ if (nBegin<0) // not found
+ return false;
- return false;
+ const sal_Unicode cSep{';'};
+
+ // Check if the found occurrence is an exact match: left side
+ if (nBegin>0 && rFilter[nBegin-1]!=cSep)
+ return false;
+
+ // Check if the found occurrence is an exact match: right side
+ const sal_Int32 nEnd = nBegin + rExt.getLength();
+ if (nEnd<rFilter.getLength() && rFilter[nEnd]!=cSep)
+ return false;
+
+ return true;
}
}