diff options
author | 2025-01-14 01:40:41 -0800 | |
---|---|---|
committer | 2025-01-24 07:10:00 -0800 | |
commit | 39d441a04d4f40a78e6b14316eee6ea86bc8cc20 (patch) | |
tree | c60a67f0ff4d9c2276d8751ec6144d6dfa9f7226 | |
parent | ff0184c6afa5d8faab4f1d76a85b7dd7829754e7 (diff) |
Simplify Buffer Handling in Non-Linux Platforms
This change removes unnecessary buffer operations for non-Linux
platforms by directly returning string literals without allocating or
copying into a buffer. On Linux platforms, the buffer (buf) remains
defined and unchanged.
The update ensures consistency while simplifying the code and
eliminating redundant logic.
Change-Id: I3fa7d73c88ba7411378411c7146f1966ae203008
-rw-r--r-- | libartbase/base/utils.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libartbase/base/utils.cc b/libartbase/base/utils.cc index aca7a0d47d..e77d37d29b 100644 --- a/libartbase/base/utils.cc +++ b/libartbase/base/utils.cc @@ -411,17 +411,17 @@ size_t GetOsThreadStat(pid_t tid, char* buf, size_t len) { } std::string GetOsThreadStatQuick(pid_t tid) { +#if defined(__linux__) static constexpr int BUF_SIZE = 100; char buf[BUF_SIZE]; -#if defined(__linux__) if (GetOsThreadStat(tid, buf, BUF_SIZE) == 0) { snprintf(buf, BUF_SIZE, "Unknown state: %d", tid); } + return buf; #else UNUSED(tid); - strcpy(buf, "Unknown state"); // snprintf may not be usable. + return "Unknown state"; #endif - return buf; } std::string GetOtherThreadOsStats() { |