summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-05-20 19:08:19 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-03-23 13:31:07 +0100
commit0b6100fd56691045d141075aad089683d59a76c2 (patch)
tree862388a8f8b00ca930fadff5871c7fed4b9c940b /include
parentc53afa8a577f58e75cdf22683af52553d292dc16 (diff)
tdf#120837 File saving at least 5 times slower
The problem here is that we never actually hit the maExportGraphics cache in SvXMLGraphicHelper, even though we are passing the same image down repeatedly. There are two bugs here: (1) BitmapEx::operator== does not return true if we instantiate 2 Graphic objects from the same XGraphic, so change it to use the more expensive operator==. To mitigate the cost, move the expensive checks to the bottom of the method. (2) in order to use an object in std::unordered_map, the object must implement an equality function and a hash function. If two objects are equal THEY MUST have the same hash value. Using the Impl* as the hash value does not satisfy that condition, so rather use the checksum, which does. After these fixes, the save time drops to less than a second. Also make the checksum method look more like the operator== method, and add a checksum calculation method for SVG data that more accurately reflects the underlying SVG data. Reviewed-on: https://gerrit.libreoffice.org/72615 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit 319c57d2af5d26d3910db4b02dca145d8881af44) Change-Id: I4ca0c7bee60b2efa6fe42301e582c7b278022b46 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90843 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/vcl/graph.hxx7
-rw-r--r--include/vcl/vectorgraphicdata.hxx1
2 files changed, 2 insertions, 6 deletions
diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index 2ad98c871cae..c8bbccd4574f 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -199,11 +199,6 @@ public:
BitmapChecksum GetChecksum() const;
- SAL_DLLPRIVATE std::size_t getHash() const
- {
- return reinterpret_cast<std::size_t>(ImplGetImpGraphic());
- }
-
OUString getOriginURL() const;
void setOriginURL(OUString const & rOriginURL);
@@ -251,7 +246,7 @@ struct hash<Graphic>
{
std::size_t operator()(Graphic const & rGraphic) const
{
- return rGraphic.getHash();
+ return static_cast<std::size_t>(rGraphic.GetChecksum());
}
};
diff --git a/include/vcl/vectorgraphicdata.hxx b/include/vcl/vectorgraphicdata.hxx
index ea7615d2bdf6..159dc7afe286 100644
--- a/include/vcl/vectorgraphicdata.hxx
+++ b/include/vcl/vectorgraphicdata.hxx
@@ -103,6 +103,7 @@ public:
const basegfx::B2DRange& getRange() const;
const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& getPrimitive2DSequence() const;
const BitmapEx& getReplacement() const;
+ BitmapChecksum GetChecksum() const;
};
typedef std::shared_ptr< VectorGraphicData > VectorGraphicDataPtr;