[Libreoffice-commits] core.git: sal/Library_sal.mk sal/osl

Tor Lillqvist tml at collabora.com
Tue Jun 19 10:19:38 UTC 2018


 sal/Library_sal.mk     |    5 +++--
 sal/osl/unx/system.cxx |   13 +++++++++++++
 sal/osl/unx/system.mm  |    1 +
 3 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 3b6905e37a6baac08eaff00e6e42aced7d6896df
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Jun 19 10:02:42 2018 +0300

    Don't waste time in macxp_resolveAlias() on files inside the app bundle
    
    LibreOffice uses its low-level API to look up files inside the app
    bundle thousands of times, all the time, and especially when starting
    something. Both when the process starts, and when a specific aspects
    of the application starts (like after typing a first character into a
    Writer document in a session). Having all those, too, go through this
    alias (bookmark) resolve dance is just insane. There won't be any
    aliases (bookmarks) there.
    
    This shaves almost a second from the delay after typing the first
    character into a Writer document in a session. There is still a
    noticeable delay left, though, likely mostly caused by Python
    (Lightproof) initialisation slowness. (It's cross-platform.)
    
    I would say that it is a bit questionable whether the
    macxp_resolveAlias() functionality is worth it at all, even.
    
    Change-Id: I2461141c6b58738befd0db4902eb25e63b788b79

diff --git a/sal/Library_sal.mk b/sal/Library_sal.mk
index d33719097c9d..0227d6ffe32c 100644
--- a/sal/Library_sal.mk
+++ b/sal/Library_sal.mk
@@ -179,21 +179,22 @@ $(eval $(call gb_Library_add_exception_objects,sal,\
 	sal/osl/unx/security \
 	sal/osl/unx/signal \
 	sal/osl/unx/socket \
-	sal/osl/unx/system \
 	sal/osl/unx/tempfile \
 	sal/osl/unx/thread \
 	sal/osl/unx/time \
 	$(if $(filter-out ANDROID IOS,$(OS)), sal/osl/unx/salinit) \
 ))
 
-# Note that the uunxapi.mm file just includes the uunxapi.cxx one
+# Note that the uunxapi.mm file just includes the uunxapi.cxx one. Ditto for system.mm
 ifeq ($(OS),MACOSX)
 $(eval $(call gb_Library_add_objcxxobjects,sal,\
 	sal/osl/unx/uunxapi \
+	sal/osl/unx/system \
 ))
 else
 $(eval $(call gb_Library_add_exception_objects,sal,\
 	sal/osl/unx/uunxapi \
+	sal/osl/unx/system \
 ))
 endif
 
diff --git a/sal/osl/unx/system.cxx b/sal/osl/unx/system.cxx
index aacd91a1290a..dee35f5c3b92 100644
--- a/sal/osl/unx/system.cxx
+++ b/sal/osl/unx/system.cxx
@@ -37,6 +37,10 @@
 #define RTL_MUTEX_LOCK
 #define RTL_MUTEX_UNLOCK
 
+#include <premac.h>
+#include <Foundation/Foundation.h>
+#include <postmac.h>
+
 #else //defined(MACOSX)
 
 static pthread_mutex_t getrtl_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -162,6 +166,15 @@ int macxp_resolveAlias(char *path, int buflen)
   CFErrorRef cferror;
   CFDataRef cfbookmark;
 
+  // Don't even try anything for files inside the app bundle. Just a
+  // waste of time.
+
+  static const char * const appBundle = [[[NSBundle mainBundle] bundlePath] UTF8String];
+
+  const size_t appBundleLen = strlen(appBundle);
+  if (strncmp(path, appBundle, appBundleLen) == 0 && path[appBundleLen] == '/')
+      return 0;
+
   char *unprocessedPath = path;
 
   if ( *unprocessedPath == '/' )
diff --git a/sal/osl/unx/system.mm b/sal/osl/unx/system.mm
new file mode 100644
index 000000000000..7495a3e73058
--- /dev/null
+++ b/sal/osl/unx/system.mm
@@ -0,0 +1 @@
+#include "system.cxx"


More information about the Libreoffice-commits mailing list