From 2694195215719ed373349c7a1d8cd3b74c81ec3f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 29 Sep 2022 18:17:29 +0200 Subject: [PATCH] storage/curl: add `noexcept` and [[gnu::pure]] --- src/storage/plugins/CurlStorage.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/storage/plugins/CurlStorage.cxx b/src/storage/plugins/CurlStorage.cxx index 4b5b84553..f03fd13b8 100644 --- a/src/storage/plugins/CurlStorage.cxx +++ b/src/storage/plugins/CurlStorage.cxx @@ -171,8 +171,9 @@ struct DavResponse { } }; +[[gnu::pure]] static unsigned -ParseStatus(const char *s) +ParseStatus(const char *s) noexcept { /* skip the "HTTP/1.1" prefix */ const char *space = std::strchr(s, ' '); @@ -182,14 +183,16 @@ ParseStatus(const char *s) return strtoul(space + 1, nullptr, 10); } +[[gnu::pure]] 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()); } +[[gnu::pure]] static std::chrono::system_clock::time_point -ParseTimeStamp(const char *s) +ParseTimeStamp(const char *s) noexcept { try { // TODO: make this more robust @@ -199,20 +202,23 @@ ParseTimeStamp(const char *s) } } +[[gnu::pure]] 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()); } +[[gnu::pure]] static uint64_t -ParseU64(const char *s) +ParseU64(const char *s) noexcept { return strtoull(s, nullptr, 10); } +[[gnu::pure]] 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()); }