daemon: sysroot: Avoid copying the path every time we call sysroot ()

This path never changes once the daemon has started up, so we don't
need to call into C code and copy the string every time.
This commit is contained in:
Richard W.M. Jones
2025-08-12 13:09:16 +01:00
committed by rwmjones
parent 1e0099671a
commit c931ab3bc8
2 changed files with 6 additions and 3 deletions

View File

@@ -28,10 +28,10 @@
#include "daemon.h"
extern value guestfs_int_daemon_sysroot (value unitv);
extern value guestfs_int_daemon_get_sysroot (value unitv);
value
guestfs_int_daemon_sysroot (value unitv)
guestfs_int_daemon_get_sysroot (value unitv)
{
return caml_copy_string (sysroot);
}

View File

@@ -18,7 +18,10 @@
open Std_utils
external sysroot : unit -> string = "guestfs_int_daemon_sysroot"
external get_sysroot : unit -> string = "guestfs_int_daemon_get_sysroot"
let sysroot = lazy (get_sysroot ())
let sysroot () = Lazy.force sysroot
let sysroot_path path =
let sysroot = sysroot () in