desktop/source/lib/init.cxx |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

New commits:
commit ba0773e50b7058f12981c4d29fb05c34d7486290
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Fri Feb 2 18:16:40 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Feb 9 12:54:46 2024 +0100

    preload: open and close empty documents of main types in preinit.
    
    Some quick testing suggest this saves ~800k for writer, ~3Mb for
    impress each loading an ~empty hello-world document.
    
    Change-Id: I9a7bc25d38d82b5556dfb04a99d5c145dd71ffec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162939
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    (cherry picked from commit d85cb3832286ae1fdcf4a8494abb8212f21e4e9a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163148
    Tested-by: Jenkins

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 0db7e1010156..1742488a7cf9 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7543,6 +7543,23 @@ static void preloadData()
 #pragma GCC diagnostic pop
 #endif
 
+    static constexpr OUString preloadComponents[] = {
+        u"private:factory/swriter"_ustr,
+        u"private:factory/scalc"_ustr,
+        u"private:factory/simpress"_ustr,
+        u"private:factory/sdraw"_ustr
+    };
+    // getting the remote LibreOffice service manager
+    uno::Reference<frame::XDesktop2> 
xCompLoader(frame::Desktop::create(xContext));
+
+    // Preload and close each of the main components once to initialize global 
state
+    uno::Sequence<css::beans::PropertyValue> szEmptyArgs(0);
+    for (const auto& component : preloadComponents)
+    {
+        auto xComp = xCompLoader->loadComponentFromURL(component, "_blank", 0, 
szEmptyArgs);
+        xComp->dispose();
+    }
+
     // Set user profile's path back to the original one
     rtl::Bootstrap::set(u"UserInstallation"_ustr, sUserPath);
 }

Reply via email to