Skip to content

Commit d221298

Browse files
authored
[SYCL] Fix traceKernel function to avoid temporary string creation (#17868)
When the `traceKernel` function is called with a C-string as a parameter, a temporary `std::string` object is created. This PR change the `traceKernel` function to accept `std::string_view` instead `const std::string &`.
1 parent bbff13d commit d221298

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sycl/source/detail/kernel_program_cache.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,15 @@ class KernelProgramCache {
340340

341341
// Sends message to std:cerr stream when SYCL_CACHE_TRACE environemnt is
342342
// set.
343-
static inline void traceKernel(const std::string &Msg,
344-
const std::string &KernelName,
343+
static inline void traceKernel(std::string_view Msg,
344+
std::string_view KernelName,
345345
bool IsKernelFastCache = false) {
346346
if (!SYCLConfig<SYCL_CACHE_TRACE>::isTraceInMemCache())
347347
return;
348348

349349
std::string Identifier =
350350
"[IsFastCache: " + std::to_string(IsKernelFastCache) +
351-
"][Key:{Name = " + KernelName + "}]: ";
351+
"][Key:{Name = " + KernelName.data() + "}]: ";
352352

353353
std::cerr << "[In-Memory Cache][Thread Id:" << std::this_thread::get_id()
354354
<< "][Kernel Cache]" << Identifier << Msg << std::endl;

0 commit comments

Comments
 (0)