summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2018-08-04 20:10:55 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-06 15:00:37 +0200
commitdf1d4bd528027c60bcab2f2e0a87303610fad326 (patch)
tree2764688c376bed313da5974757e594fb91054867
parentd027b4ae533d5b8d7b00f5e1b8351b8c9e203085 (diff)
ScCompiler::IsString, pass down the string length if we know it
instead of making the constructor first perform strlen (normally for the second time). And drop an unnecessary if (.. > MAXSTRLEN) which is impossible to hit, since we check that before adding to this array. Change-Id: I8ef2e027fb4a22e06be81e8b5955350869599d85 Reviewed-on: https://gerrit.libreoffice.org/58597 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/source/core/tool/compiler.cxx24
1 files changed, 8 insertions, 16 deletions
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 831f8ec677f1..446f1b08f86f 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2703,7 +2703,7 @@ Label_MaskStateMachine:
--nSrcPos;
}
if ( bAutoCorrect )
- aCorrectedSymbol = cSymbol;
+ aCorrectedSymbol = OUString(cSymbol, pSym - cSymbol);
if (bAutoIntersection && nSpaces > 1)
--nSpaces; // replace '!!' with only one space
return nSpaces;
@@ -2996,25 +2996,17 @@ bool ScCompiler::IsValue( const OUString& rSym )
bool ScCompiler::IsString()
{
- const sal_Unicode* p = cSymbol;
+ if ( cSymbol[0] != '"' )
+ return false;
+ const sal_Unicode* p = cSymbol+1;
while ( *p )
p++;
sal_Int32 nLen = sal::static_int_cast<sal_Int32>( p - cSymbol - 1 );
- bool bQuote = ((cSymbol[0] == '"') && (cSymbol[nLen] == '"'));
- if ((bQuote ? nLen-2 : nLen) > MAXSTRLEN)
- {
- SetError(FormulaError::StringOverflow);
+ if (cSymbol[nLen] != '"')
return false;
- }
- if ( bQuote )
- {
- cSymbol[nLen] = '\0';
- const sal_Unicode* pStr = cSymbol+1;
- svl::SharedString aSS = pDoc->GetSharedStringPool().intern(OUString(pStr));
- maRawToken.SetString(aSS.getData(), aSS.getDataIgnoreCase());
- return true;
- }
- return false;
+ svl::SharedString aSS = pDoc->GetSharedStringPool().intern(OUString(cSymbol+1, nLen-1));
+ maRawToken.SetString(aSS.getData(), aSS.getDataIgnoreCase());
+ return true;
}
bool ScCompiler::IsPredetectedErrRefReference( const OUString& rName, const OUString* pErrRef )