diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-24 13:40:59 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-24 16:09:08 +0200 |
commit | bd44b3eef62f4325a189539d6ab1b90ca63cfc28 (patch) | |
tree | c7acf752ad231602fe05069606df3e5b65caae56 /include/tools | |
parent | 81297c29ceb55dec44999e31a11dea81668c3c8f (diff) |
tdf#89522 PERF FILEOPEN xlsx, part 1
Inherit from tools::WeakBase non-virtually, so that we can use a
static_cast in tools::WeakReference::get instead of a dynamic_cast.
This takes the file-open time from 1m21 to 40s for me.
Add a clang plugin to make sure we don't accidentally end up inheriting
from tools::WeakBase more than once.
Change-Id: I9c7c36403333f99094e1f9d8cce2ecd9200377f9
Reviewed-on: https://gerrit.libreoffice.org/71231
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/tools')
-rw-r--r-- | include/tools/weakbase.hxx | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/include/tools/weakbase.hxx b/include/tools/weakbase.hxx index 9fe3f32775c3..fa16edd2f147 100644 --- a/include/tools/weakbase.hxx +++ b/include/tools/weakbase.hxx @@ -61,9 +61,10 @@ template< class reference_type > inline reference_type * WeakReference< reference_type >::get() const { auto pWeakBase = mpWeakConnection->mpReference; - auto pRet = dynamic_cast<reference_type *>(pWeakBase); - assert((pWeakBase && pRet) || (!pWeakBase && !pRet)); - return pRet; + if (!pWeakBase) + return nullptr; + assert(dynamic_cast<reference_type *>(pWeakBase)); + return static_cast<reference_type *>(pWeakBase); } template< class reference_type > |