storage/curl: add noexcept and [[gnu::pure]]

This commit is contained in:
Max Kellermann 2022-09-29 18:17:29 +02:00
parent 66450d1f3c
commit 2694195215

View File

@ -171,8 +171,9 @@ struct DavResponse {
} }
}; };
[[gnu::pure]]
static unsigned static unsigned
ParseStatus(const char *s) ParseStatus(const char *s) noexcept
{ {
/* skip the "HTTP/1.1" prefix */ /* skip the "HTTP/1.1" prefix */
const char *space = std::strchr(s, ' '); const char *space = std::strchr(s, ' ');
@ -182,14 +183,16 @@ ParseStatus(const char *s)
return strtoul(space + 1, nullptr, 10); return strtoul(space + 1, nullptr, 10);
} }
[[gnu::pure]]
static unsigned static unsigned
ParseStatus(const char *s, size_t length) ParseStatus(const char *s, size_t length) noexcept
{ {
return ParseStatus(std::string(s, length).c_str()); return ParseStatus(std::string(s, length).c_str());
} }
[[gnu::pure]]
static std::chrono::system_clock::time_point static std::chrono::system_clock::time_point
ParseTimeStamp(const char *s) ParseTimeStamp(const char *s) noexcept
{ {
try { try {
// TODO: make this more robust // TODO: make this more robust
@ -199,20 +202,23 @@ ParseTimeStamp(const char *s)
} }
} }
[[gnu::pure]]
static std::chrono::system_clock::time_point static std::chrono::system_clock::time_point
ParseTimeStamp(const char *s, size_t length) ParseTimeStamp(const char *s, size_t length) noexcept
{ {
return ParseTimeStamp(std::string(s, length).c_str()); return ParseTimeStamp(std::string(s, length).c_str());
} }
[[gnu::pure]]
static uint64_t static uint64_t
ParseU64(const char *s) ParseU64(const char *s) noexcept
{ {
return strtoull(s, nullptr, 10); return strtoull(s, nullptr, 10);
} }
[[gnu::pure]]
static uint64_t static uint64_t
ParseU64(const char *s, size_t length) ParseU64(const char *s, size_t length) noexcept
{ {
return ParseU64(std::string(s, length).c_str()); return ParseU64(std::string(s, length).c_str());
} }