Kaydet (Commit) 69f279d7 authored tarafından Dennis Francis's avatar Dennis Francis Kaydeden (comit) Dennis Francis

Re-order the members of ScFormulaResult...

to make the common access pattern cache friendly.

For example, in case of a large sum like =SUM(A1:A50000)
where the column A itself is composed of formulas, the inner
loop of computation involves accessing ScFormulaResult's of
each formulacell of column A. Recently this was made faster
by the use of a "cache" flag (commit 77f7b476), so to get
the result it just need access to the cache bool-flag and the
mfValue member. Hence it makes sense to group the bools
together with the mfValue member.

Change-Id: If12d0736ba98b9d74e7b96304fce71e8e6e66619
Reviewed-on: https://gerrit.libreoffice.org/63063
Tested-by: Jenkins
Reviewed-by: 's avatarDennis Francis <dennis.francis@collabora.com>
üst e3f013da
...@@ -77,13 +77,13 @@ class ScFormulaResult ...@@ -77,13 +77,13 @@ class ScFormulaResult
double mfValue; // double result direct for performance and memory consumption double mfValue; // double result direct for performance and memory consumption
const formula::FormulaToken* mpToken; // if not, result token obtained from interpreter const formula::FormulaToken* mpToken; // if not, result token obtained from interpreter
}; };
FormulaError mnError; // error code
bool mbToken :1; // whether content of union is a token bool mbToken :1; // whether content of union is a token
bool mbEmpty :1; // empty cell result bool mbEmpty :1; // empty cell result
bool mbEmptyDisplayedAsString :1; // only if mbEmpty bool mbEmptyDisplayedAsString :1; // only if mbEmpty
Multiline meMultiline :2; // result is multiline
// If set it implies that the result is a simple double (in mfValue) and no error // If set it implies that the result is a simple double (in mfValue) and no error
bool mbValueCached :1; bool mbValueCached :1;
Multiline meMultiline :2; // result is multiline
FormulaError mnError; // error code
/** Reset mnError, mbEmpty and mbEmptyDisplayedAsString to their defaults /** Reset mnError, mbEmpty and mbEmptyDisplayedAsString to their defaults
prior to assigning other types */ prior to assigning other types */
......
...@@ -23,17 +23,21 @@ FormulaResultValue::FormulaResultValue( FormulaError nErr ) : meType(Error), mfV ...@@ -23,17 +23,21 @@ FormulaResultValue::FormulaResultValue( FormulaError nErr ) : meType(Error), mfV
} }
ScFormulaResult::ScFormulaResult() : ScFormulaResult::ScFormulaResult() :
mpToken(nullptr), mnError(FormulaError::NONE), mbToken(true), mpToken(nullptr),
mbEmpty(false), mbEmptyDisplayedAsString(false), mbToken(true),
mbEmpty(false),
mbEmptyDisplayedAsString(false),
mbValueCached(false),
meMultiline(MULTILINE_UNKNOWN), meMultiline(MULTILINE_UNKNOWN),
mbValueCached(false) {} mnError(FormulaError::NONE) {}
ScFormulaResult::ScFormulaResult( const ScFormulaResult & r ) : ScFormulaResult::ScFormulaResult( const ScFormulaResult & r ) :
mnError( r.mnError), mbToken( r.mbToken), mbToken( r.mbToken),
mbEmpty( r.mbEmpty), mbEmpty( r.mbEmpty),
mbEmptyDisplayedAsString( r.mbEmptyDisplayedAsString), mbEmptyDisplayedAsString( r.mbEmptyDisplayedAsString),
mbValueCached( r.mbValueCached),
meMultiline( r.meMultiline), meMultiline( r.meMultiline),
mbValueCached( r.mbValueCached) mnError( r.mnError)
{ {
if (mbToken) if (mbToken)
{ {
...@@ -60,8 +64,12 @@ ScFormulaResult::ScFormulaResult( const ScFormulaResult & r ) : ...@@ -60,8 +64,12 @@ ScFormulaResult::ScFormulaResult( const ScFormulaResult & r ) :
} }
ScFormulaResult::ScFormulaResult( const formula::FormulaToken* p ) : ScFormulaResult::ScFormulaResult( const formula::FormulaToken* p ) :
mnError(FormulaError::NONE), mbToken(false), mbEmpty(false), mbEmptyDisplayedAsString(false), mbToken(false),
meMultiline(MULTILINE_UNKNOWN), mbValueCached(false) mbEmpty(false),
mbEmptyDisplayedAsString(false),
mbValueCached(false),
meMultiline(MULTILINE_UNKNOWN),
mnError(FormulaError::NONE)
{ {
SetToken( p); SetToken( p);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment