diff options
author | Pierre-Eric Pelloux-Prayer <pierre-eric@lanedo.com> | 2013-08-16 16:29:38 +0200 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.de> | 2013-08-27 14:50:59 +0000 |
commit | 3fed166279377f7ad702b8911899243b8adff3bf (patch) | |
tree | 5e41e2700d3369b6a45f8a67bc84ab2fe42e679f | |
parent | 805e43c8c7d10568186cf218f8c1baf39691e3b1 (diff) |
interpr/vlookup: use ScMatrix func to find matching cells
Moves the cpu intensive code to ScMatrix, where we can use our
knowledge of the internal structure: use mdds::multi_type_matrix::walk
instead of browsing cells one by one.
Change-Id: Ie1df20e2be6414b8e21b4d58b7697a0801222c1e
Reviewed-on: https://gerrit.libreoffice.org/5455
Reviewed-by: Kohei Yoshida <kohei.yoshida@suse.de>
Tested-by: Kohei Yoshida <kohei.yoshida@suse.de>
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 5043272679a3..ba265810ebcc 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -6565,18 +6565,25 @@ void ScInterpreter::CalculateLookup(bool HLookup) } else { - for (SCSIZE i = 0; i < nMatCount; i++) + if (HLookup) { - if (HLookup ? pMat->IsString(i, 0) : pMat->IsString(0, i)) + for (SCSIZE i = 0; i < nMatCount; i++) { - if ( ScGlobal::GetpTransliteration()->isEqual( - HLookup ? pMat->GetString(i,0) : pMat->GetString(0,i), rParamStr)) + if (pMat->IsString(i, 0)) { - nDelta = i; - i = nMatCount + 1; + if ( ScGlobal::GetpTransliteration()->isEqual( + pMat->GetString(i,0), rParamStr)) + { + nDelta = i; + i = nMatCount + 1; + } } } } + else + { + nDelta = pMat->MatchStringInColumns(rParamStr, 0, 0); + } } } else @@ -6597,17 +6604,24 @@ void ScInterpreter::CalculateLookup(bool HLookup) } else { - for (SCSIZE i = 0; i < nMatCount; i++) + if (HLookup) { - if (!(HLookup ? pMat->IsString(i, 0) : pMat->IsString(0, i))) + for (SCSIZE i = 0; i < nMatCount; i++) { - if ((HLookup ? pMat->GetDouble(i,0) : pMat->GetDouble(0,i)) == rItem.mfVal) + if (! pMat->IsString(i, 0) ) { - nDelta = i; - i = nMatCount + 1; + if ( pMat->GetDouble(i,0) == rItem.mfVal) + { + nDelta = i; + i = nMatCount + 1; + } } } } + else + { + nDelta = pMat->MatchDoubleInColumns(rItem.mfVal, 0, 0); + } } } if ( nDelta != SCSIZE_MAX ) |