diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-04-22 10:22:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-04-22 12:40:29 +0200 |
commit | 43f77f1f86ecb7d28095989eabf5febc7ace8a9a (patch) | |
tree | 6b493e0d8055fe743d37b716463c82f61cbae4a2 /svx | |
parent | 335de1a2216523527f2a6a9aef4f5997f775e648 (diff) |
std::move optimisation
avoid copying the old list to the new list and destroying both, reduces
time rendering complex spreadsheets
Change-Id: I1454cb16f418691743d212a17167c53fbe19ce4a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114469
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/sdr/contact/viewobjectcontact.cxx | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/svx/source/sdr/contact/viewobjectcontact.cxx b/svx/source/sdr/contact/viewobjectcontact.cxx index 6387c39afcbf..e65c2bab1d6e 100644 --- a/svx/source/sdr/contact/viewobjectcontact.cxx +++ b/svx/source/sdr/contact/viewobjectcontact.cxx @@ -346,45 +346,45 @@ drawinglayer::primitive2d::Primitive2DContainer const & ViewObjectContact::getPr } // local up-to-date checks. New list different from local one? - if(mxPrimitive2DSequence != xNewPrimitiveSequence) - { - // has changed, copy content - const_cast< ViewObjectContact* >(this)->mxPrimitive2DSequence = xNewPrimitiveSequence; + if(mxPrimitive2DSequence == xNewPrimitiveSequence) + return mxPrimitive2DSequence; - // check for animated stuff - const_cast< ViewObjectContact* >(this)->checkForPrimitive2DAnimations(); + // has changed, copy content + const_cast< ViewObjectContact* >(this)->mxPrimitive2DSequence = std::move(xNewPrimitiveSequence); - // always update object range when PrimitiveSequence changes - const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D()); - const_cast< ViewObjectContact* >(this)->maObjectRange = mxPrimitive2DSequence.getB2DRange(rViewInformation2D); + // check for animated stuff + const_cast< ViewObjectContact* >(this)->checkForPrimitive2DAnimations(); - // check and eventually embed to GridOffset transform primitive - if(GetObjectContact().supportsGridOffsets()) - { - const basegfx::B2DVector& rGridOffset(getGridOffset()); + // always update object range when PrimitiveSequence changes + const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D()); + const_cast< ViewObjectContact* >(this)->maObjectRange = mxPrimitive2DSequence.getB2DRange(rViewInformation2D); - if(0.0 != rGridOffset.getX() || 0.0 != rGridOffset.getY()) - { - const basegfx::B2DHomMatrix aTranslateGridOffset( - basegfx::utils::createTranslateB2DHomMatrix( - rGridOffset)); - const drawinglayer::primitive2d::Primitive2DReference aEmbed( - new drawinglayer::primitive2d::TransformPrimitive2D( - aTranslateGridOffset, - mxPrimitive2DSequence)); - - // Set values at local data. So for now, the mechanism is to reset some of the - // defining things (mxPrimitive2DSequence, maGridOffset) and re-create the - // buffered data (including maObjectRange). It *could* be changed to keep - // the unmodified PrimitiveSequence and only update the GridOffset, but this - // would require a 2nd instance of maObjectRange and mxPrimitive2DSequence. I - // started doing so, but it just makes the code more complicated. For now, - // just allow re-creation of the PrimitiveSequence (and removing buffered - // decomposed content of it). May be optimized, though. OTOH it only happens - // in calc which traditionally does not have a huge amount of DrawObjects anyways. - const_cast< ViewObjectContact* >(this)->mxPrimitive2DSequence = drawinglayer::primitive2d::Primitive2DContainer { aEmbed }; - const_cast< ViewObjectContact* >(this)->maObjectRange.transform(aTranslateGridOffset); - } + // check and eventually embed to GridOffset transform primitive + if(GetObjectContact().supportsGridOffsets()) + { + const basegfx::B2DVector& rGridOffset(getGridOffset()); + + if(0.0 != rGridOffset.getX() || 0.0 != rGridOffset.getY()) + { + const basegfx::B2DHomMatrix aTranslateGridOffset( + basegfx::utils::createTranslateB2DHomMatrix( + rGridOffset)); + const drawinglayer::primitive2d::Primitive2DReference aEmbed( + new drawinglayer::primitive2d::TransformPrimitive2D( + aTranslateGridOffset, + mxPrimitive2DSequence)); + + // Set values at local data. So for now, the mechanism is to reset some of the + // defining things (mxPrimitive2DSequence, maGridOffset) and re-create the + // buffered data (including maObjectRange). It *could* be changed to keep + // the unmodified PrimitiveSequence and only update the GridOffset, but this + // would require a 2nd instance of maObjectRange and mxPrimitive2DSequence. I + // started doing so, but it just makes the code more complicated. For now, + // just allow re-creation of the PrimitiveSequence (and removing buffered + // decomposed content of it). May be optimized, though. OTOH it only happens + // in calc which traditionally does not have a huge amount of DrawObjects anyways. + const_cast< ViewObjectContact* >(this)->mxPrimitive2DSequence = drawinglayer::primitive2d::Primitive2DContainer { aEmbed }; + const_cast< ViewObjectContact* >(this)->maObjectRange.transform(aTranslateGridOffset); } } |