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 authored and mrts committed Sep 20, 2024
1 parent 51d8015 commit 3c9662d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions include/electronic-id/enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace electronic_id
class CertificateType
{
public:
enum CertificateTypeEnum: int8_t { AUTHENTICATION, SIGNING, NONE = -1 };
enum CertificateTypeEnum : int8_t { AUTHENTICATION, SIGNING, NONE = -1 };

CertificateType() = default;
constexpr CertificateType(const CertificateTypeEnum _value) : value(_value) {}
Expand All @@ -53,7 +53,7 @@ class CertificateType
class HashAlgorithm
{
public:
enum HashAlgorithmEnum: int16_t {
enum HashAlgorithmEnum : int16_t {
SHA224 = 224, // SHA2
SHA256 = 256,
SHA384 = 384,
Expand Down Expand Up @@ -172,7 +172,7 @@ class SignatureAlgorithm
class JsonWebSignatureAlgorithm
{
public:
enum JsonWebSignatureAlgorithmEnum: int8_t {
enum JsonWebSignatureAlgorithmEnum : int8_t {
ES256, // ECDSA
ES384,
ES512,
Expand Down
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 3c9662d

Please sign in to comment.