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

New commits:
commit d85cb3832286ae1fdcf4a8494abb8212f21e4e9a
Author:     Michael Meeks <[email protected]>
AuthorDate: Fri Feb 2 18:16:40 2024 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Fri Feb 2 22:47:28 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 <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 80442dc5ffa2..c76e7a014725 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7553,6 +7553,23 @@ static void preloadData()
 #pragma GCC diagnostic pop
 #endif
 
+    static const OUString preloadComponents[] = {
+        "private:factory/swriter",
+        "private:factory/scalc",
+        "private:factory/simpress",
+        "private:factory/sdraw"
+    };
+    // getting the remote LibreOffice service manager
+    uno::Reference<frame::XDesktop2> 
xCompLoader(frame::Desktop::create(xContext), uno::UNO_QUERY);
+
+    // Preload and close each of the main components once to initialize global 
state
+    uno::Sequence<css::beans::PropertyValue> szEmptyArgs(0);
+    for (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