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



commit 6604b0f829fd9b094af28d911339fd2c43d145c7
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]