Commit 9a164668 authored by Max Kellermann's avatar Max Kellermann

util/UriExtract: migrate uri_get_scheme() to std::string_view

parent 6876d160
...@@ -82,17 +82,17 @@ uri_after_scheme(const char *uri) noexcept ...@@ -82,17 +82,17 @@ uri_after_scheme(const char *uri) noexcept
bool bool
uri_has_scheme(const char *uri) noexcept uri_has_scheme(const char *uri) noexcept
{ {
return !uri_get_scheme(uri).IsNull(); return !uri_get_scheme(uri).empty();
} }
StringView std::string_view
uri_get_scheme(const char *uri) noexcept uri_get_scheme(std::string_view uri) noexcept
{ {
const char *end = strstr(uri, "://"); auto end = uri.find("://");
if (end == nullptr) if (end == std::string_view::npos)
return nullptr; return {};
return {uri, end}; return uri.substr(0, end);
} }
bool bool
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "Compiler.h" #include "Compiler.h"
struct StringView; #include <string_view>
/** /**
* Checks whether the specified URI has a scheme in the form * Checks whether the specified URI has a scheme in the form
...@@ -46,8 +46,8 @@ uri_has_scheme(const char *uri) noexcept; ...@@ -46,8 +46,8 @@ uri_has_scheme(const char *uri) noexcept;
* Returns the scheme name of the specified URI, or an empty string. * Returns the scheme name of the specified URI, or an empty string.
*/ */
gcc_pure gcc_pure
StringView std::string_view
uri_get_scheme(const char *uri) noexcept; uri_get_scheme(std::string_view uri) noexcept;
gcc_pure gcc_pure
bool bool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment