From ba0773e50b7058f12981c4d29fb05c34d7486290 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Fri, 2 Feb 2024 18:16:40 +0000 Subject: preload: open and close empty documents of main types in preinit. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Caolán McNamara (cherry picked from commit d85cb3832286ae1fdcf4a8494abb8212f21e4e9a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163148 Tested-by: Jenkins --- desktop/source/lib/init.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'desktop/source/lib') 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 xCompLoader(frame::Desktop::create(xContext)); + + // Preload and close each of the main components once to initialize global state + uno::Sequence 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); } -- cgit