From 0314370eb58303bf0176b3222044bf27739ee5f5 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 25 Dec 2018 11:27:22 -0800 Subject: Cache the process binary path and name --- Alc/helpers.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Alc/helpers.cpp') diff --git a/Alc/helpers.cpp b/Alc/helpers.cpp index beee4bff..2db544b8 100644 --- a/Alc/helpers.cpp +++ b/Alc/helpers.cpp @@ -310,9 +310,11 @@ void FPUCtl::leave() noexcept #ifdef _WIN32 -PathNamePair GetProcBinary() +const PathNamePair &GetProcBinary() { - PathNamePair ret; + static PathNamePair ret; + if(!ret.fname.empty() || !ret.path.empty()) + return ret; al::vector fullpath(256); DWORD len; @@ -477,11 +479,13 @@ void SetRTPriority(void) #else -PathNamePair GetProcBinary() +const PathNamePair &GetProcBinary() { - PathNamePair ret; - al::vector pathname; + static PathNamePair ret; + if(!ret.fname.empty() || !ret.path.empty()) + return ret; + al::vector pathname; #ifdef __FreeBSD__ size_t pathlen; int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; -- cgit v1.2.3