diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-05-26 12:29:37 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-05-26 15:55:53 +0200 |
commit | ef4964a4e598c3c9714cdc18ffa40bcb120dbef6 (patch) | |
tree | 9646b70a5b4d90977e0e14a2ce6639de9011cfff /drawinglayer | |
parent | 3a93748c9c4faadeb9ab4eb21706d187677549fa (diff) |
reduce dynamic_cast usage in an O(N^2) algorithm
When scrolling down in tdf#130431 this is the major CPU cost.
Move the dynamic_cast out of the loops as much as possible.
Change-Id: I0ea9f457bb17fbdde880f09b059f07dec4b1790b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94858
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/primitive2d/borderlineprimitive2d.cxx | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx index a5c2a51bc44e..b264e2c028af 100644 --- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx @@ -305,18 +305,11 @@ namespace drawinglayer::primitive2d ImplPrimitive2DIDBlock(BorderLinePrimitive2D, PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D) Primitive2DReference tryMergeBorderLinePrimitive2D( - const Primitive2DReference& rCandidateA, - const Primitive2DReference& rCandidateB) + const BorderLinePrimitive2D* pCandidateA, + const BorderLinePrimitive2D* pCandidateB) { - // try to cast to BorderLinePrimitive2D - const primitive2d::BorderLinePrimitive2D* pCandidateA = dynamic_cast< const primitive2d::BorderLinePrimitive2D* >(rCandidateA.get()); - const primitive2d::BorderLinePrimitive2D* pCandidateB = dynamic_cast< const primitive2d::BorderLinePrimitive2D* >(rCandidateB.get()); - - // we need a comparable BorderLinePrimitive2D - if(nullptr == pCandidateA || nullptr == pCandidateB) - { - return Primitive2DReference(); - } + assert(pCandidateA); + assert(pCandidateB); // start of candidate has to match end of this if(!pCandidateA->getEnd().equal(pCandidateB->getStart())) |