Skip to content

Commit

Permalink
Optimize: don't allocate memory
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Sep 20, 2024
1 parent 477a757 commit 2420a3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/libpcsc-cpp/include/pcsc-cpp/pcsc-cpp-utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ inline std::string int2hexstr(const T value)

/** Remove absolute path prefix until 'src' from the given path, '/path/to/src/main.cpp' becomes
* 'src/main.cpp'. */
inline std::string removeAbsolutePathPrefix(std::string filePath)
constexpr const char* removeAbsolutePathPrefix(std::string_view filePath)
{
const auto lastSrc = filePath.rfind("src");
return lastSrc == std::string::npos ? std::move(filePath) : filePath.erase(0, lastSrc);
return lastSrc == std::string::npos ? filePath.data() : filePath.substr(lastSrc).data();
}

} // namespace pcsc_cpp
Expand Down
2 changes: 1 addition & 1 deletion lib/libpcsc-cpp/src/listReaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ std::vector<const string_t::value_type*> getReaderNamePointerList(const string_t
if (readerNames.empty())
return readerNamePointerList;

// Reader names are \0 separated and end with double \0.
// Reader names are \0 separated and end with double \0.
#ifdef _WIN32
for (const string_t::value_type* name = readerNames.c_str(); *name; name += wcslen(name) + 1) {
#else
Expand Down

0 comments on commit 2420a3d

Please sign in to comment.