From 5de1d0472b319e9d48972eb067fd8189507fa640 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 3 Jan 2023 20:19:56 +0200 Subject: use sal_uInt8 for maMatFlag which is way more cache-dense than double Change-Id: I04503eb3a4054cce5312a7a0048c9b6679a8fd16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145018 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sc/source/core/tool/scmatrix.cxx | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'sc/source/core/tool/scmatrix.cxx') diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index f5d04bdb3fb9..8afeb796b35e 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -64,10 +64,18 @@ struct matrix_trait typedef mdds::mtv::custom_block_func1 element_block_func; }; +struct matrix_flag_trait +{ + typedef sc::string_block string_element_block; + typedef mdds::mtv::uint8_element_block integer_element_block; + + typedef mdds::mtv::custom_block_func1 element_block_func; +}; } typedef mdds::multi_type_matrix MatrixImplType; +typedef mdds::multi_type_matrix MatrixFlagImplType; namespace { @@ -218,16 +226,14 @@ Comp CompareMatrixElemFunc::maComp; } -/* TODO: it would be good if mdds had get/set additionally to - * get/set, we're abusing double here. */ -typedef double TMatFlag; -const TMatFlag SC_MATFLAG_EMPTYRESULT = 1.0; -const TMatFlag SC_MATFLAG_EMPTYPATH = 2.0; +typedef uint8_t TMatFlag; +const TMatFlag SC_MATFLAG_EMPTYRESULT = 1; +const TMatFlag SC_MATFLAG_EMPTYPATH = 2; class ScMatrixImpl { MatrixImplType maMat; - MatrixImplType maMatFlag; + MatrixFlagImplType maMatFlag; ScInterpreter* pErrorInterpreter; public: @@ -706,7 +712,7 @@ svl::SharedString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE return maMat.get_string(aPos); case mdds::mtm::element_empty: { - if (maMatFlag.get_numeric(nR, nC) != SC_MATFLAG_EMPTYPATH) + if (maMatFlag.get(nR, nC) != SC_MATFLAG_EMPTYPATH) // not an empty path. return svl::SharedString::getEmptyString(); @@ -769,8 +775,8 @@ ScMatrixValue ScMatrixImpl::Get(SCSIZE nC, SCSIZE nR) const case mdds::mtm::element_empty: aVal.nType = ScMatValType::Empty; break; - case mdds::mtm::element_numeric: - aVal.nType = maMatFlag.get(nR, nC) + case mdds::mtm::element_integer: + aVal.nType = maMatFlag.get(nR, nC) == SC_MATFLAG_EMPTYPATH ? ScMatValType::EmptyPath : ScMatValType::Empty; break; default: @@ -816,7 +822,7 @@ bool ScMatrixImpl::IsEmpty( SCSIZE nC, SCSIZE nR ) const // but not an 'empty path' element. ValidColRowReplicated( nC, nR ); return maMat.get_type(nR, nC) == mdds::mtm::element_empty && - maMatFlag.get_numeric(nR, nC) != SC_MATFLAG_EMPTYPATH; + maMatFlag.get_integer(nR, nC) != SC_MATFLAG_EMPTYPATH; } bool ScMatrixImpl::IsEmptyCell( SCSIZE nC, SCSIZE nR ) const @@ -834,7 +840,7 @@ bool ScMatrixImpl::IsEmptyResult( SCSIZE nC, SCSIZE nR ) const // 'empty' or 'empty cell' or 'empty path' element. ValidColRowReplicated( nC, nR ); return maMat.get_type(nR, nC) == mdds::mtm::element_empty && - maMatFlag.get_numeric(nR, nC) == SC_MATFLAG_EMPTYRESULT; + maMatFlag.get_integer(nR, nC) == SC_MATFLAG_EMPTYRESULT; } bool ScMatrixImpl::IsEmptyPath( SCSIZE nC, SCSIZE nR ) const @@ -842,7 +848,7 @@ bool ScMatrixImpl::IsEmptyPath( SCSIZE nC, SCSIZE nR ) const // Flag must indicate an 'empty path' element. if (ValidColRowOrReplicated( nC, nR )) return maMat.get_type(nR, nC) == mdds::mtm::element_empty && - maMatFlag.get_numeric(nR, nC) == SC_MATFLAG_EMPTYPATH; + maMatFlag.get_integer(nR, nC) == SC_MATFLAG_EMPTYPATH; else return true; } @@ -973,7 +979,7 @@ void ScMatrixImpl::PutEmptyResultVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) { maMat.set_empty(nR, nC, nCount); // Flag to indicate that this is 'empty result', not 'empty' or 'empty path'. - std::vector aVals(nCount, SC_MATFLAG_EMPTYRESULT); + std::vector aVals(nCount, SC_MATFLAG_EMPTYRESULT); maMatFlag.set(nR, nC, aVals.begin(), aVals.end()); } else @@ -988,7 +994,7 @@ void ScMatrixImpl::PutEmptyPathVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) { maMat.set_empty(nR, nC, nCount); // Flag to indicate 'empty path'. - std::vector aVals(nCount, SC_MATFLAG_EMPTYPATH); + std::vector aVals(nCount, SC_MATFLAG_EMPTYPATH); maMatFlag.set(nR, nC, aVals.begin(), aVals.end()); } else -- cgit v1.2.1