summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2018-09-02 15:34:55 +0200
committerMatteo Casalin <matteo.casalin@yahoo.com>2018-09-09 21:07:55 +0200
commit559449ba62565966aa4a42a822a70b07e6c98079 (patch)
tree327f180b15b053be92356184b3f65b8cc22697c4
parent42e961972a56a6508c9a38c2b80a996ee2e679e1 (diff)
Avoid getTokenCount and temporaries, reduce scope
Change-Id: Ic97e9952de387040bb87e854eb34a183f0cf60ec
-rw-r--r--sc/source/ui/dbgui/csvruler.cxx24
1 files changed, 15 insertions, 9 deletions
diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx
index 9370a3decc89..86acdc1ec807 100644
--- a/sc/source/ui/dbgui/csvruler.cxx
+++ b/sc/source/ui/dbgui/csvruler.cxx
@@ -34,9 +34,6 @@ using namespace com::sun::star::uno;
static void load_FixedWidthList(ScCsvSplits &rSplits)
{
- OUString sSplits;
- OUString sFixedWidthLists;
-
Sequence<Any>aValues;
const Any *pProperties;
Sequence<OUString> aNames { FIXED_WIDTH_LIST };
@@ -48,14 +45,23 @@ static void load_FixedWidthList(ScCsvSplits &rSplits)
if( pProperties[0].hasValue() )
{
rSplits.Clear();
- pProperties[0] >>= sFixedWidthLists;
- sSplits = sFixedWidthLists;
+ OUString sFixedWidthLists;
+ pProperties[0] >>= sFixedWidthLists;
- // String ends with a semi-colon so there is no 'int' after the last one.
- sal_Int32 n = comphelper::string::getTokenCount(sSplits, ';') - 1;
- for (sal_Int32 i = 0; i < n; ++i)
- rSplits.Insert( sSplits.getToken(i, ';').toInt32() );
+ sal_Int32 nIdx {0};
+ for(;;)
+ {
+ const sal_Int32 n {sFixedWidthLists.getToken(0, ';', nIdx).toInt32()};
+ if (nIdx<0)
+ {
+ // String ends with a semi-colon so there
+ // is no useful 'int' after the last one.
+ // This also works in case of empty string
+ break;
+ }
+ rSplits.Insert(n);
+ }
}
}
static void save_FixedWidthList(const ScCsvSplits& rSplits)