diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-02 11:20:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-02 12:23:37 +0000 |
commit | 1f5797e0c0cc0425e29b7a945485ac146fec0085 (patch) | |
tree | 9032bd192a0988ba8d50a8f6beff110525f51680 /basic/source | |
parent | 5d2be45a788c450e6f914eea8c3b74d214edaccd (diff) |
flatten some classes in basic
no need to allocate separately where the contained class is only one
pointer big
Change-Id: If5fac0b0e20f80bffebc8611791d07888cbec1e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148089
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic/source')
-rw-r--r-- | basic/source/classes/sb.cxx | 30 | ||||
-rw-r--r-- | basic/source/inc/sbintern.hxx | 12 | ||||
-rw-r--r-- | basic/source/inc/stdobj.hxx | 5 | ||||
-rw-r--r-- | basic/source/runtime/stdobj.cxx | 6 |
4 files changed, 28 insertions, 25 deletions
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 0296e2238ca1..7f02e65d9b55 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -901,18 +901,18 @@ StarBASIC::StarBASIC( StarBASIC* p, bool bIsDocBasic ) if( !GetSbData()->nInst++ ) { - GetSbData()->pSbFac.reset( new SbiFactory ); - AddFactory( GetSbData()->pSbFac.get() ); - GetSbData()->pTypeFac.reset(new SbTypeFactory); - AddFactory( GetSbData()->pTypeFac.get() ); + GetSbData()->pSbFac.emplace(); + AddFactory( &*GetSbData()->pSbFac ); + GetSbData()->pTypeFac.emplace(); + AddFactory( &*GetSbData()->pTypeFac ); GetSbData()->pClassFac.reset(new SbClassFactory); AddFactory( GetSbData()->pClassFac.get() ); - GetSbData()->pOLEFac.reset(new SbOLEFactory); - AddFactory( GetSbData()->pOLEFac.get() ); - GetSbData()->pFormFac.reset(new SbFormFactory); - AddFactory( GetSbData()->pFormFac.get() ); - GetSbData()->pUnoFac.reset( new SbUnoFactory ); - AddFactory( GetSbData()->pUnoFac.get() ); + GetSbData()->pOLEFac.emplace(); + AddFactory( &*GetSbData()->pOLEFac ); + GetSbData()->pFormFac.emplace(); + AddFactory( &*GetSbData()->pFormFac ); + GetSbData()->pUnoFac.emplace(); + AddFactory( &*GetSbData()->pUnoFac ); } pRtl = new SbiStdObject(SB_RTLNAME, this ); // Search via StarBasic is always global @@ -940,17 +940,17 @@ StarBASIC::~StarBASIC() if( !--GetSbData()->nInst ) { - RemoveFactory( GetSbData()->pSbFac.get() ); + RemoveFactory( &*GetSbData()->pSbFac ); GetSbData()->pSbFac.reset(); - RemoveFactory( GetSbData()->pUnoFac.get() ); + RemoveFactory( &*GetSbData()->pUnoFac ); GetSbData()->pUnoFac.reset(); - RemoveFactory( GetSbData()->pTypeFac.get() ); + RemoveFactory( &*GetSbData()->pTypeFac ); GetSbData()->pTypeFac.reset(); RemoveFactory( GetSbData()->pClassFac.get() ); GetSbData()->pClassFac.reset(); - RemoveFactory( GetSbData()->pOLEFac.get() ); + RemoveFactory( &*GetSbData()->pOLEFac ); GetSbData()->pOLEFac.reset(); - RemoveFactory( GetSbData()->pFormFac.get() ); + RemoveFactory( &*GetSbData()->pFormFac ); GetSbData()->pFormFac.reset(); if( SbiGlobals::pGlobals ) diff --git a/basic/source/inc/sbintern.hxx b/basic/source/inc/sbintern.hxx index b00ba29f5521..5ed41d5fb138 100644 --- a/basic/source/inc/sbintern.hxx +++ b/basic/source/inc/sbintern.hxx @@ -21,9 +21,11 @@ #include <basic/sbstar.hxx> #include <sbxfac.hxx> +#include "sbunoobj.hxx" #include <unotools/transliterationwrapper.hxx> #include <comphelper/errcode.hxx> #include <config_features.h> +#include <optional> namespace utl { @@ -105,15 +107,15 @@ struct SbiGlobals static SbiGlobals* pGlobals; SbiInstance* pInst; // all active runtime instances #if HAVE_FEATURE_SCRIPTING - std::unique_ptr<SbiFactory> pSbFac; // StarBASIC-Factory - std::unique_ptr<SbUnoFactory> pUnoFac; // Factory for Uno-Structs at DIM AS NEW - std::unique_ptr<SbTypeFactory> + std::optional<SbiFactory> pSbFac; // StarBASIC-Factory + std::optional<SbUnoFactory> pUnoFac; // Factory for Uno-Structs at DIM AS NEW + std::optional<SbTypeFactory> pTypeFac; // Factory for user defined types std::unique_ptr<SbClassFactory> pClassFac; // Factory for user defined classes (based on class modules) - std::unique_ptr<SbOLEFactory> + std::optional<SbOLEFactory> pOLEFac; // Factory for OLE types - std::unique_ptr<SbFormFactory> + std::optional<SbFormFactory> pFormFac; // Factory for user forms std::unique_ptr<BasicManager> pAppBasMgr; #endif diff --git a/basic/source/inc/stdobj.hxx b/basic/source/inc/stdobj.hxx index 18df1fbbdda7..824cb90ea1a2 100644 --- a/basic/source/inc/stdobj.hxx +++ b/basic/source/inc/stdobj.hxx @@ -20,13 +20,14 @@ #pragma once #include <basic/sbxobj.hxx> +#include <sbstdobj.hxx> +#include <optional> class StarBASIC; -class SbStdFactory; class SbiStdObject final : public SbxObject { - std::unique_ptr<SbStdFactory> pStdFactory; + std::optional<SbStdFactory> pStdFactory; virtual ~SbiStdObject() override; using SbxVariable::GetInfo; diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index 97e9ceede1e9..5b123d00d5a2 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -934,15 +934,15 @@ SbiStdObject::SbiStdObject( const OUString& r, StarBASIC* pb ) : SbxObject( r ) SetParent( pb ); - pStdFactory.reset( new SbStdFactory ); - SbxBase::AddFactory( pStdFactory.get() ); + pStdFactory.emplace(); + SbxBase::AddFactory( &*pStdFactory ); Insert( new SbStdClipboard ); } SbiStdObject::~SbiStdObject() { - SbxBase::RemoveFactory( pStdFactory.get() ); + SbxBase::RemoveFactory( &*pStdFactory ); pStdFactory.reset(); } |