From a8d1769ca70497a559ffdaef8c0d30f58cb2a09d Mon Sep 17 00:00:00 2001 From: badaix Date: Sun, 22 Mar 2020 11:53:19 +0100 Subject: [PATCH] Cache getOS result --- common/utils.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/utils.hpp b/common/utils.hpp index 70d84016..84cb7233 100644 --- a/common/utils.hpp +++ b/common/utils.hpp @@ -90,7 +90,11 @@ static std::string getProp(const std::string& key, const std::string& def = "") static std::string getOS() { - std::string os; + static std::string os(""); + + if (!os.empty()) + return os; + #ifdef ANDROID os = strutils::trim_copy("Android " + getProp("ro.build.version.release")); #else @@ -114,7 +118,8 @@ static std::string getOS() uname(&u); os = u.sysname; } - return strutils::trim_copy(os); + strutils::trim(os); + return os; }