diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-04-11 15:36:00 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-04-11 15:36:00 -0400 |
commit | a78a7ee9f7b1db56a6fa7e082f410db5a8db2f18 (patch) | |
tree | a60c5b951f0658d3e9223125b01cf65c36e7bbbc /editeng | |
parent | e981a102333feb2a4d71bb3803210434b14b5d39 (diff) |
Do this special case search only when the array is large enough.
Otherwise the normal linear search should be sufficient. Eventually
we need to use a better algorithm here than this special case handling...
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index f797d2416a9e..c791aa2be165 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -688,7 +688,7 @@ size_t FastGetPos(const _Array& rArray, const _Val* p, size_t& rLastPos) // Through certain filter code-paths we do a lot of appends, which in // turn call GetPos - creating some N^2 nightmares. If we have a // non-trivially large list, do a few checks from the end first. - if (rLastPos > 16) + if (rLastPos > 16 && nArrayLen > 16) { size_t nEnd; if (rLastPos > nArrayLen - 2) @@ -698,7 +698,7 @@ size_t FastGetPos(const _Array& rArray, const _Val* p, size_t& rLastPos) for (size_t nIdx = rLastPos - 2; nIdx < nEnd; ++nIdx) { - if (&rArray[nIdx] == p) + if (&rArray.at(nIdx) == p) { rLastPos = nIdx; return nIdx; @@ -707,7 +707,7 @@ size_t FastGetPos(const _Array& rArray, const _Val* p, size_t& rLastPos) } // The world's lamest linear search from svarray ... for (size_t nIdx = 0; nIdx < nArrayLen; ++nIdx) - if (&rArray[nIdx] == p) + if (&rArray.at(nIdx) == p) return rLastPos = nIdx; // 0xFFFF is used to signify "not found" condition. We need to change this. |