On Monday, 8 April 2019 at 18:54:10 UTC, Julian wrote:
  @property
  string root_dir() {
      static string cache;
      static bool isInit = false;
      if (!isInit) {
          isInit = true;
          cache = dirName(thisExePath());
      }
      return cache;
  }

Shorter:

  string root_dir() {
      static string cache;
      return cache ? cache : (cache = dirName(thisExePath()));
  }

This might spam readlink() syscalls if they somehow return the empty string,
but how would that even happen...

Reply via email to