summaryrefslogtreecommitdiff
path: root/vcl/source/control
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2018-04-29 21:34:26 +0200
committerMatteo Casalin <matteo.casalin@yahoo.com>2018-04-29 22:50:54 +0200
commite7747a338bb3951448a0be2cda1e9ae5eb6cc117 (patch)
treee84aa7d05f5759c33cb45efb48e575eb2a8a7f21 /vcl/source/control
parentb7b323a783abd4055b58f9a765615e2ad887bd77 (diff)
Avoid getTokenCount
Previous implementation looped backward from last token, but just a match seems to be required in order to insert the associated ComboBox position in a std::set (which does not care for insertion order). Change-Id: If92b28a9364e59fca46e728164be41e0755d0977
Diffstat (limited to 'vcl/source/control')
-rw-r--r--vcl/source/control/combobox.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 9f8bd524e0e1..d54c628df8a3 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -89,14 +89,15 @@ struct ComboBox::Impl
static void lcl_GetSelectedEntries( ::std::set< sal_Int32 >& rSelectedPos, const OUString& rText, sal_Unicode cTokenSep, const ImplEntryList* pEntryList )
{
- for (sal_Int32 n = comphelper::string::getTokenCount(rText, cTokenSep); n;)
- {
- OUString aToken = rText.getToken( --n, cTokenSep );
- aToken = comphelper::string::strip(aToken, ' ');
- sal_Int32 nPos = pEntryList->FindEntry( aToken );
+ if (rText.isEmpty())
+ return;
+
+ sal_Int32 nIdx{0};
+ do {
+ const sal_Int32 nPos = pEntryList->FindEntry(comphelper::string::strip(rText.getToken(0, cTokenSep, nIdx), ' '));
if ( nPos != LISTBOX_ENTRY_NOTFOUND )
rSelectedPos.insert( nPos );
- }
+ } while (nIdx>=0);
}
ComboBox::ComboBox(vcl::Window *const pParent, WinBits const nStyle)