[epiphany/mcatanzaro/file-launching: 4/4] flatpak-utils: Remember if we're under flatpak



commit 9b894e7f0a5ec8412d370edf9358f22d7625343f
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Mon Jan 7 21:35:38 2019 -0600

    flatpak-utils: Remember if we're under flatpak
    
    I added a bunch of asserts to ensure we're not running under flatpak
    when we shouldn't be. Maybe it makes sense to only check the filesystem
    once per thread, to avoid unnecessary I/O. A microoptimization, but an
    easy and uncomplicated one.

 lib/ephy-flatpak-utils.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/lib/ephy-flatpak-utils.c b/lib/ephy-flatpak-utils.c
index 86fff8949..e9329ae5b 100644
--- a/lib/ephy-flatpak-utils.c
+++ b/lib/ephy-flatpak-utils.c
@@ -37,7 +37,15 @@
 gboolean
 ephy_is_running_inside_flatpak (void)
 {
-  return g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS);
+  static _Thread_local gboolean decided = FALSE;
+  static _Thread_local gboolean under_flatpak = FALSE;
+
+  if (decided)
+    return under_flatpak;
+
+  under_flatpak = g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS);
+  decided = TRUE;
+  return under_flatpak;
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]