diff options
author | Chris Robinson <[email protected]> | 2018-12-25 11:27:22 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-25 11:27:22 -0800 |
commit | 0314370eb58303bf0176b3222044bf27739ee5f5 (patch) | |
tree | e5f5dab4bbcde138d6ad885be1c6c3e5a027491c /Alc/helpers.cpp | |
parent | 208ea76922e8d69dc9ad93cbb0cf43634d9782a4 (diff) |
Cache the process binary path and name
Diffstat (limited to 'Alc/helpers.cpp')
-rw-r--r-- | Alc/helpers.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
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<WCHAR> fullpath(256); DWORD len; @@ -477,11 +479,13 @@ void SetRTPriority(void) #else -PathNamePair GetProcBinary() +const PathNamePair &GetProcBinary() { - PathNamePair ret; - al::vector<char> pathname; + static PathNamePair ret; + if(!ret.fname.empty() || !ret.path.empty()) + return ret; + al::vector<char> pathname; #ifdef __FreeBSD__ size_t pathlen; int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; |