Cache getOS result

This commit is contained in:
badaix 2020-03-22 11:53:19 +01:00
parent dac7c8f4f7
commit a8d1769ca7

View file

@ -90,7 +90,11 @@ static std::string getProp(const std::string& key, const std::string& def = "")
static std::string getOS() static std::string getOS()
{ {
std::string os; static std::string os("");
if (!os.empty())
return os;
#ifdef ANDROID #ifdef ANDROID
os = strutils::trim_copy("Android " + getProp("ro.build.version.release")); os = strutils::trim_copy("Android " + getProp("ro.build.version.release"));
#else #else
@ -114,7 +118,8 @@ static std::string getOS()
uname(&u); uname(&u);
os = u.sysname; os = u.sysname;
} }
return strutils::trim_copy(os); strutils::trim(os);
return os;
} }