Skip to content

Commit f77b593

Browse files
cperkinsintelKornevNikita
authored andcommitted
[SYCL][NFC] Prefer std::string_view over std::string to refer to string literals (#18272)
Expected to address one Coverity issue as well. --------- Signed-off-by: Chris Perkins <[email protected]>
1 parent e18fb32 commit f77b593

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sycl/source/detail/kernel_compiler/kernel_compiler_opencl.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,16 @@ static std::unique_ptr<void, std::function<void(void *)>>
7171
void loadOclocLibrary(const std::vector<uint32_t> &IPVersionVec) {
7272
#ifdef __SYCL_RT_OS_WINDOWS
7373
// first the environment, if not compatible will move on to absolute path.
74-
static const std::vector<std::string> OclocPaths = {
74+
static const std::vector<std::string_view> OclocPaths = {
7575
"ocloc64.dll",
7676
"C:\\Program Files (x86)\\Intel\\oneAPI\\ocloc\\latest\\ocloc64.dll"};
7777
#else
78-
static const std::vector<std::string> OclocPaths = {"libocloc.so"};
78+
static const std::vector<std::string_view> OclocPaths = {"libocloc.so"};
7979
#endif
8080

8181
// attemptLoad() sets OclocLibrary value by side effect.
82-
auto attemptLoad = [&](std::string OclocPath) {
82+
auto attemptLoad = [&](std::string_view OclocPath_sv) {
83+
std::string OclocPath(OclocPath_sv);
8384
try {
8485
// Load then perform checks. Each check throws.
8586
void *tempPtr = sycl::detail::ur::loadOsLibrary(OclocPath);
@@ -98,7 +99,7 @@ void loadOclocLibrary(const std::vector<uint32_t> &IPVersionVec) {
9899
}
99100
return true;
100101
};
101-
for (auto result : OclocPaths) {
102+
for (const std::string_view result : OclocPaths) {
102103
if (attemptLoad(result))
103104
return; // exit on successful attempt
104105
}

0 commit comments

Comments
 (0)