From e95ee497af16c5d5b7709db5d7e9cc398fdef74e Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 29 Jan 2022 13:54:01 +0100 Subject: [PATCH] src: slightly simplify V8CoverageConnection::GetFilename PR-URL: https://github.com/nodejs/node/pull/41748 Reviewed-By: Darshan Sen Reviewed-By: Colin Ihrig Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Rich Trott Reviewed-By: Mestery --- src/inspector_profiler.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/inspector_profiler.cc b/src/inspector_profiler.cc index e40b4b99cc8db3..db8bda8524d3b4 100644 --- a/src/inspector_profiler.cc +++ b/src/inspector_profiler.cc @@ -170,18 +170,12 @@ static bool EnsureDirectory(const std::string& directory, const char* type) { } std::string V8CoverageConnection::GetFilename() const { - std::string thread_id = std::to_string(env()->thread_id()); - std::string pid = std::to_string(uv_os_getpid()); - std::string timestamp = std::to_string( - static_cast(GetCurrentTimeInMicroseconds() / 1000)); - char filename[1024]; - snprintf(filename, - sizeof(filename), - "coverage-%s-%s-%s.json", - pid.c_str(), - timestamp.c_str(), - thread_id.c_str()); - return filename; + uint64_t timestamp = + static_cast(GetCurrentTimeInMicroseconds() / 1000); + return SPrintF("coverage-%s-%s-%s.json", + uv_os_getpid(), + timestamp, + env()->thread_id()); } void V8ProfilerConnection::WriteProfile(Local result) {