tdf#92456 improve VLOOKUP perf
shave 5% of the time here - ref-counting triggered by copying svl::SharedString is significant, so return by const& instead of by value Change-Id: Ic702632da45d75dddab33d6ce1e6f1097ff70de9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109900 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
46e525c36e
commit
aa98ed61a7
@ -209,10 +209,12 @@ void FormulaToken::SetDoubleType( sal_Int16 )
|
|||||||
assert( !"virtual dummy called" );
|
assert( !"virtual dummy called" );
|
||||||
}
|
}
|
||||||
|
|
||||||
svl::SharedString FormulaToken::GetString() const
|
const svl::SharedString INVALID_STRING;
|
||||||
|
|
||||||
|
const svl::SharedString & FormulaToken::GetString() const
|
||||||
{
|
{
|
||||||
SAL_WARN( "formula.core", "FormulaToken::GetString: virtual dummy called" );
|
SAL_WARN( "formula.core", "FormulaToken::GetString: virtual dummy called" );
|
||||||
return svl::SharedString(); // invalid string
|
return INVALID_STRING; // invalid string
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormulaToken::SetString( const svl::SharedString& )
|
void FormulaToken::SetString( const svl::SharedString& )
|
||||||
@ -1877,7 +1879,7 @@ FormulaToken* FormulaStringToken::Clone() const
|
|||||||
return new FormulaStringToken(*this);
|
return new FormulaStringToken(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
svl::SharedString FormulaStringToken::GetString() const
|
const svl::SharedString & FormulaStringToken::GetString() const
|
||||||
{
|
{
|
||||||
return maString;
|
return maString;
|
||||||
}
|
}
|
||||||
@ -1903,7 +1905,7 @@ FormulaToken* FormulaStringOpToken::Clone() const
|
|||||||
return new FormulaStringOpToken(*this);
|
return new FormulaStringOpToken(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
svl::SharedString FormulaStringOpToken::GetString() const
|
const svl::SharedString & FormulaStringOpToken::GetString() const
|
||||||
{
|
{
|
||||||
return maString;
|
return maString;
|
||||||
}
|
}
|
||||||
@ -1943,7 +1945,7 @@ bool FormulaErrorToken::operator==( const FormulaToken& r ) const
|
|||||||
}
|
}
|
||||||
double FormulaMissingToken::GetDouble() const { return 0.0; }
|
double FormulaMissingToken::GetDouble() const { return 0.0; }
|
||||||
|
|
||||||
svl::SharedString FormulaMissingToken::GetString() const
|
const svl::SharedString & FormulaMissingToken::GetString() const
|
||||||
{
|
{
|
||||||
return svl::SharedString::getEmptyString();
|
return svl::SharedString::getEmptyString();
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ public:
|
|||||||
virtual double& GetDoubleAsReference();
|
virtual double& GetDoubleAsReference();
|
||||||
virtual sal_Int16 GetDoubleType() const;
|
virtual sal_Int16 GetDoubleType() const;
|
||||||
virtual void SetDoubleType( sal_Int16 nType );
|
virtual void SetDoubleType( sal_Int16 nType );
|
||||||
virtual svl::SharedString GetString() const;
|
virtual const svl::SharedString & GetString() const;
|
||||||
virtual void SetString( const svl::SharedString& rStr );
|
virtual void SetString( const svl::SharedString& rStr );
|
||||||
virtual sal_uInt16 GetIndex() const;
|
virtual sal_uInt16 GetIndex() const;
|
||||||
virtual void SetIndex( sal_uInt16 n );
|
virtual void SetIndex( sal_uInt16 n );
|
||||||
@ -320,7 +320,7 @@ public:
|
|||||||
FormulaStringToken( const FormulaStringToken& r );
|
FormulaStringToken( const FormulaStringToken& r );
|
||||||
|
|
||||||
virtual FormulaToken* Clone() const override;
|
virtual FormulaToken* Clone() const override;
|
||||||
virtual svl::SharedString GetString() const override;
|
virtual const svl::SharedString & GetString() const override;
|
||||||
virtual void SetString( const svl::SharedString& rStr ) override;
|
virtual void SetString( const svl::SharedString& rStr ) override;
|
||||||
virtual bool operator==( const FormulaToken& rToken ) const override;
|
virtual bool operator==( const FormulaToken& rToken ) const override;
|
||||||
};
|
};
|
||||||
@ -336,7 +336,7 @@ public:
|
|||||||
FormulaStringOpToken( const FormulaStringOpToken& r );
|
FormulaStringOpToken( const FormulaStringOpToken& r );
|
||||||
|
|
||||||
virtual FormulaToken* Clone() const override;
|
virtual FormulaToken* Clone() const override;
|
||||||
virtual svl::SharedString GetString() const override;
|
virtual const svl::SharedString & GetString() const override;
|
||||||
virtual void SetString( const svl::SharedString& rStr ) override;
|
virtual void SetString( const svl::SharedString& rStr ) override;
|
||||||
virtual bool operator==( const FormulaToken& rToken ) const override;
|
virtual bool operator==( const FormulaToken& rToken ) const override;
|
||||||
};
|
};
|
||||||
@ -391,7 +391,7 @@ public:
|
|||||||
|
|
||||||
virtual FormulaToken* Clone() const override { return new FormulaMissingToken(*this); }
|
virtual FormulaToken* Clone() const override { return new FormulaMissingToken(*this); }
|
||||||
virtual double GetDouble() const override;
|
virtual double GetDouble() const override;
|
||||||
virtual svl::SharedString GetString() const override;
|
virtual const svl::SharedString & GetString() const override;
|
||||||
virtual bool operator==( const FormulaToken& rToken ) const override;
|
virtual bool operator==( const FormulaToken& rToken ) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class SVL_DLLPUBLIC SharedString
|
|||||||
rtl_uString* mpDataIgnoreCase;
|
rtl_uString* mpDataIgnoreCase;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static SharedString getEmptyString();
|
static const SharedString & getEmptyString();
|
||||||
|
|
||||||
SharedString();
|
SharedString();
|
||||||
SharedString( rtl_uString* pData, rtl_uString* pDataIgnoreCase );
|
SharedString( rtl_uString* pData, rtl_uString* pDataIgnoreCase );
|
||||||
|
@ -320,7 +320,7 @@ public:
|
|||||||
bool IsValueNoError();
|
bool IsValueNoError();
|
||||||
bool IsValueNoError() const;
|
bool IsValueNoError() const;
|
||||||
double GetValue();
|
double GetValue();
|
||||||
svl::SharedString GetString();
|
const svl::SharedString & GetString();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a numeric value without potentially triggering re-calculation.
|
* Get a numeric value without potentially triggering re-calculation.
|
||||||
@ -330,7 +330,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Get a string value without potentially triggering re-calculation.
|
* Get a string value without potentially triggering re-calculation.
|
||||||
*/
|
*/
|
||||||
svl::SharedString GetRawString() const;
|
const svl::SharedString & GetRawString() const;
|
||||||
const ScMatrix* GetMatrix();
|
const ScMatrix* GetMatrix();
|
||||||
bool GetMatrixOrigin( const ScDocument& rDoc, ScAddress& rPos ) const;
|
bool GetMatrixOrigin( const ScDocument& rDoc, ScAddress& rPos ) const;
|
||||||
void GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows );
|
void GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows );
|
||||||
@ -407,7 +407,7 @@ public:
|
|||||||
|
|
||||||
void SetResultToken( const formula::FormulaToken* pToken );
|
void SetResultToken( const formula::FormulaToken* pToken );
|
||||||
|
|
||||||
svl::SharedString GetResultString() const;
|
const svl::SharedString & GetResultString() const;
|
||||||
|
|
||||||
bool HasHybridStringResult() const;
|
bool HasHybridStringResult() const;
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ public:
|
|||||||
|
|
||||||
/** Return string if type formula::svString or formula::svHybridCell or formula::svMatrixCell and
|
/** Return string if type formula::svString or formula::svHybridCell or formula::svMatrixCell and
|
||||||
upper left formula::svString, else empty string. */
|
upper left formula::svString, else empty string. */
|
||||||
svl::SharedString GetString() const;
|
const svl::SharedString & GetString() const;
|
||||||
|
|
||||||
/** Return matrix if type formula::svMatrixCell and ScMatrix present, else NULL. */
|
/** Return matrix if type formula::svMatrixCell and ScMatrix present, else NULL. */
|
||||||
ScConstMatrixRef GetMatrix() const;
|
ScConstMatrixRef GetMatrix() const;
|
||||||
|
@ -144,7 +144,7 @@ public:
|
|||||||
ScExternalSingleRefToken & operator =(ScExternalSingleRefToken &&) = delete; // due to FormulaToken
|
ScExternalSingleRefToken & operator =(ScExternalSingleRefToken &&) = delete; // due to FormulaToken
|
||||||
|
|
||||||
virtual sal_uInt16 GetIndex() const override;
|
virtual sal_uInt16 GetIndex() const override;
|
||||||
virtual svl::SharedString GetString() const override;
|
virtual const svl::SharedString & GetString() const override;
|
||||||
virtual const ScSingleRefData* GetSingleRef() const override;
|
virtual const ScSingleRefData* GetSingleRef() const override;
|
||||||
virtual ScSingleRefData* GetSingleRef() override;
|
virtual ScSingleRefData* GetSingleRef() override;
|
||||||
virtual bool operator==( const formula::FormulaToken& rToken ) const override;
|
virtual bool operator==( const formula::FormulaToken& rToken ) const override;
|
||||||
@ -168,7 +168,7 @@ public:
|
|||||||
ScExternalDoubleRefToken & operator =(ScExternalDoubleRefToken &&) = delete; // due to FormulaToken
|
ScExternalDoubleRefToken & operator =(ScExternalDoubleRefToken &&) = delete; // due to FormulaToken
|
||||||
|
|
||||||
virtual sal_uInt16 GetIndex() const override;
|
virtual sal_uInt16 GetIndex() const override;
|
||||||
virtual svl::SharedString GetString() const override;
|
virtual const svl::SharedString & GetString() const override;
|
||||||
virtual const ScSingleRefData* GetSingleRef() const override;
|
virtual const ScSingleRefData* GetSingleRef() const override;
|
||||||
virtual ScSingleRefData* GetSingleRef() override;
|
virtual ScSingleRefData* GetSingleRef() override;
|
||||||
virtual const ScSingleRefData* GetSingleRef2() const override;
|
virtual const ScSingleRefData* GetSingleRef2() const override;
|
||||||
@ -195,7 +195,7 @@ public:
|
|||||||
ScExternalNameToken & operator =(ScExternalNameToken &&) = delete; // due to FormulaToken
|
ScExternalNameToken & operator =(ScExternalNameToken &&) = delete; // due to FormulaToken
|
||||||
|
|
||||||
virtual sal_uInt16 GetIndex() const override;
|
virtual sal_uInt16 GetIndex() const override;
|
||||||
virtual svl::SharedString GetString() const override;
|
virtual const svl::SharedString & GetString() const override;
|
||||||
virtual bool operator==( const formula::FormulaToken& rToken ) const override;
|
virtual bool operator==( const formula::FormulaToken& rToken ) const override;
|
||||||
virtual FormulaToken* Clone() const override { return new ScExternalNameToken(*this); }
|
virtual FormulaToken* Clone() const override { return new ScExternalNameToken(*this); }
|
||||||
};
|
};
|
||||||
@ -286,7 +286,7 @@ public:
|
|||||||
bool IsInherited() const { return bInherited; }
|
bool IsInherited() const { return bInherited; }
|
||||||
bool IsDisplayedAsString() const { return bDisplayedAsString; }
|
bool IsDisplayedAsString() const { return bDisplayedAsString; }
|
||||||
virtual double GetDouble() const override;
|
virtual double GetDouble() const override;
|
||||||
virtual svl::SharedString GetString() const override;
|
virtual const svl::SharedString & GetString() const override;
|
||||||
virtual bool operator==( const formula::FormulaToken& rToken ) const override;
|
virtual bool operator==( const formula::FormulaToken& rToken ) const override;
|
||||||
virtual FormulaToken* Clone() const override { return new ScEmptyCellToken(*this); }
|
virtual FormulaToken* Clone() const override { return new ScEmptyCellToken(*this); }
|
||||||
};
|
};
|
||||||
@ -306,7 +306,7 @@ public:
|
|||||||
ScMatrixCellResultToken( const ScMatrixCellResultToken& );
|
ScMatrixCellResultToken( const ScMatrixCellResultToken& );
|
||||||
virtual ~ScMatrixCellResultToken() override;
|
virtual ~ScMatrixCellResultToken() override;
|
||||||
virtual double GetDouble() const override;
|
virtual double GetDouble() const override;
|
||||||
virtual svl::SharedString GetString() const override;
|
virtual const svl::SharedString & GetString() const override;
|
||||||
virtual const ScMatrix* GetMatrix() const override;
|
virtual const ScMatrix* GetMatrix() const override;
|
||||||
virtual bool operator==( const formula::FormulaToken& rToken ) const override;
|
virtual bool operator==( const formula::FormulaToken& rToken ) const override;
|
||||||
virtual FormulaToken* Clone() const override;
|
virtual FormulaToken* Clone() const override;
|
||||||
@ -391,7 +391,7 @@ public:
|
|||||||
bool IsEmptyDisplayedAsString() const { return mbEmptyDisplayedAsString; }
|
bool IsEmptyDisplayedAsString() const { return mbEmptyDisplayedAsString; }
|
||||||
virtual double GetDouble() const override;
|
virtual double GetDouble() const override;
|
||||||
|
|
||||||
virtual svl::SharedString GetString() const override;
|
virtual const svl::SharedString & GetString() const override;
|
||||||
virtual bool operator==( const formula::FormulaToken& rToken ) const override;
|
virtual bool operator==( const formula::FormulaToken& rToken ) const override;
|
||||||
virtual FormulaToken* Clone() const override { return new ScHybridCellToken(*this); }
|
virtual FormulaToken* Clone() const override { return new ScHybridCellToken(*this); }
|
||||||
};
|
};
|
||||||
|
@ -2616,7 +2616,7 @@ void ScFormulaCell::SetResultToken( const formula::FormulaToken* pToken )
|
|||||||
aResult.SetToken(pToken);
|
aResult.SetToken(pToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
svl::SharedString ScFormulaCell::GetResultString() const
|
const svl::SharedString & ScFormulaCell::GetResultString() const
|
||||||
{
|
{
|
||||||
return aResult.GetString();
|
return aResult.GetString();
|
||||||
}
|
}
|
||||||
@ -2795,7 +2795,7 @@ double ScFormulaCell::GetValue()
|
|||||||
return GetRawValue();
|
return GetRawValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
svl::SharedString ScFormulaCell::GetString()
|
const svl::SharedString & ScFormulaCell::GetString()
|
||||||
{
|
{
|
||||||
MaybeInterpret();
|
MaybeInterpret();
|
||||||
return GetRawString();
|
return GetRawString();
|
||||||
@ -2809,7 +2809,7 @@ double ScFormulaCell::GetRawValue() const
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
svl::SharedString ScFormulaCell::GetRawString() const
|
const svl::SharedString & ScFormulaCell::GetRawString() const
|
||||||
{
|
{
|
||||||
if ((pCode->GetCodeError() == FormulaError::NONE) &&
|
if ((pCode->GetCodeError() == FormulaError::NONE) &&
|
||||||
aResult.GetResultError() == FormulaError::NONE)
|
aResult.GetResultError() == FormulaError::NONE)
|
||||||
|
@ -1025,7 +1025,7 @@ public:
|
|||||||
|
|
||||||
FormulaError GetError() const { return nGlobalError; }
|
FormulaError GetError() const { return nGlobalError; }
|
||||||
formula::StackVar GetResultType() const { return xResult->GetType(); }
|
formula::StackVar GetResultType() const { return xResult->GetType(); }
|
||||||
svl::SharedString GetStringResult() const;
|
const svl::SharedString & GetStringResult() const;
|
||||||
double GetNumResult() const { return xResult->GetDouble(); }
|
double GetNumResult() const { return xResult->GetDouble(); }
|
||||||
const formula::FormulaConstTokenRef& GetResultToken() const { return xResult; }
|
const formula::FormulaConstTokenRef& GetResultToken() const { return xResult; }
|
||||||
SvNumFormatType GetRetFormatType() const { return nRetFmtType; }
|
SvNumFormatType GetRetFormatType() const { return nRetFmtType; }
|
||||||
|
@ -511,7 +511,7 @@ double ScFormulaResult::GetDouble() const
|
|||||||
return mfValue;
|
return mfValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
svl::SharedString ScFormulaResult::GetString() const
|
const svl::SharedString & ScFormulaResult::GetString() const
|
||||||
{
|
{
|
||||||
if (mbToken && mpToken)
|
if (mbToken && mpToken)
|
||||||
{
|
{
|
||||||
|
@ -4747,7 +4747,7 @@ void ScInterpreter::AssertFormulaMatrix()
|
|||||||
bMatrixFormula = true;
|
bMatrixFormula = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
svl::SharedString ScInterpreter::GetStringResult() const
|
const svl::SharedString & ScInterpreter::GetStringResult() const
|
||||||
{
|
{
|
||||||
return xResult->GetString();
|
return xResult->GetString();
|
||||||
}
|
}
|
||||||
|
@ -727,7 +727,7 @@ sal_uInt16 ScExternalSingleRefToken::GetIndex() const
|
|||||||
return mnFileId;
|
return mnFileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
svl::SharedString ScExternalSingleRefToken::GetString() const
|
const svl::SharedString & ScExternalSingleRefToken::GetString() const
|
||||||
{
|
{
|
||||||
return maTabName;
|
return maTabName;
|
||||||
}
|
}
|
||||||
@ -773,7 +773,7 @@ sal_uInt16 ScExternalDoubleRefToken::GetIndex() const
|
|||||||
return mnFileId;
|
return mnFileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
svl::SharedString ScExternalDoubleRefToken::GetString() const
|
const svl::SharedString & ScExternalDoubleRefToken::GetString() const
|
||||||
{
|
{
|
||||||
return maTabName;
|
return maTabName;
|
||||||
}
|
}
|
||||||
@ -836,7 +836,7 @@ sal_uInt16 ScExternalNameToken::GetIndex() const
|
|||||||
return mnFileId;
|
return mnFileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
svl::SharedString ScExternalNameToken::GetString() const
|
const svl::SharedString & ScExternalNameToken::GetString() const
|
||||||
{
|
{
|
||||||
return maName;
|
return maName;
|
||||||
}
|
}
|
||||||
@ -956,7 +956,7 @@ ScJumpMatrixToken::~ScJumpMatrixToken()
|
|||||||
|
|
||||||
double ScEmptyCellToken::GetDouble() const { return 0.0; }
|
double ScEmptyCellToken::GetDouble() const { return 0.0; }
|
||||||
|
|
||||||
svl::SharedString ScEmptyCellToken::GetString() const
|
const svl::SharedString & ScEmptyCellToken::GetString() const
|
||||||
{
|
{
|
||||||
return svl::SharedString::getEmptyString();
|
return svl::SharedString::getEmptyString();
|
||||||
}
|
}
|
||||||
@ -977,7 +977,7 @@ double ScMatrixCellResultToken::GetDouble() const { return xUpperLeft-
|
|||||||
|
|
||||||
ScMatrixCellResultToken::~ScMatrixCellResultToken() {}
|
ScMatrixCellResultToken::~ScMatrixCellResultToken() {}
|
||||||
|
|
||||||
svl::SharedString ScMatrixCellResultToken::GetString() const
|
const svl::SharedString & ScMatrixCellResultToken::GetString() const
|
||||||
{
|
{
|
||||||
return xUpperLeft->GetString();
|
return xUpperLeft->GetString();
|
||||||
}
|
}
|
||||||
@ -1113,7 +1113,7 @@ ScHybridCellToken::ScHybridCellToken(
|
|||||||
|
|
||||||
double ScHybridCellToken::GetDouble() const { return mfDouble; }
|
double ScHybridCellToken::GetDouble() const { return mfDouble; }
|
||||||
|
|
||||||
svl::SharedString ScHybridCellToken::GetString() const
|
const svl::SharedString & ScHybridCellToken::GetString() const
|
||||||
{
|
{
|
||||||
return maString;
|
return maString;
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,15 @@
|
|||||||
|
|
||||||
namespace svl {
|
namespace svl {
|
||||||
|
|
||||||
SharedString SharedString::getEmptyString()
|
/** ref-counting traffic associated with SharedString temporaries can be significant, so use a singleton here, so we can return a const& from getEmptyString */
|
||||||
|
static OUString EMPTY(u"");
|
||||||
|
const SharedString EMPTY_SHARED_STRING(EMPTY.pData, EMPTY.pData);
|
||||||
|
|
||||||
|
const SharedString & SharedString::getEmptyString()
|
||||||
{
|
{
|
||||||
// unicode string array for empty string is globally shared in OUString.
|
// unicode string array for empty string is globally shared in OUString.
|
||||||
// Let's take advantage of that.
|
// Let's take advantage of that.
|
||||||
rtl_uString* pData = nullptr;
|
return EMPTY_SHARED_STRING;
|
||||||
rtl_uString_new(&pData);
|
|
||||||
return SharedString(pData, pData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedString::SharedString() : mpData(nullptr), mpDataIgnoreCase(nullptr) {}
|
SharedString::SharedString() : mpData(nullptr), mpDataIgnoreCase(nullptr) {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user