Skip to content

Commit cf62c91

Browse files
committed
Merge pull request #112 from csk-ableton/master
1 parent 0eb9ccd commit cf62c91

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

‎include/network/uri/uri.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,12 @@ class uri {
416416
*/
417417
std::u32string u32string() const;
418418

419+
/**
420+
* \brief Returns the URI as a string_view object.
421+
* \returns A URI string view.
422+
*/
423+
string_view view() const noexcept;
424+
419425
/**
420426
* \brief Checks if the uri object is empty, i.e. it has no parts.
421427
* \returns \c true if there are no parts, \c false otherwise.

‎src/uri.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@ std::u32string uri::u32string() const {
446446
return std::u32string(std::begin(*this), std::end(*this));
447447
}
448448

449+
uri::string_view uri::view() const noexcept {
450+
return uri_view_;
451+
}
452+
449453
bool uri::empty() const noexcept { return uri_.empty(); }
450454

451455
bool uri::is_absolute() const noexcept { return has_scheme(); }
@@ -685,18 +689,15 @@ bool uri::initialize(const string_type &uri) {
685689
void swap(uri &lhs, uri &rhs) noexcept { lhs.swap(rhs); }
686690

687691
bool operator==(const uri &lhs, const uri &rhs) noexcept {
688-
return lhs.compare(rhs, uri_comparison_level::syntax_based) == 0;
692+
return lhs.view() == rhs.view();
689693
}
690694

691695
bool operator==(const uri &lhs, const char *rhs) noexcept {
692-
if (std::strlen(rhs) !=
693-
std::size_t(std::distance(std::begin(lhs), std::end(lhs)))) {
694-
return false;
695-
}
696-
return std::equal(std::begin(lhs), std::end(lhs), rhs);
696+
return lhs.view() == string_view{rhs};
697697
}
698698

699699
bool operator<(const uri &lhs, const uri &rhs) noexcept {
700-
return lhs.compare(rhs, uri_comparison_level::syntax_based) < 0;
700+
return lhs.view() < rhs.view();
701701
}
702+
702703
} // namespace network

0 commit comments

Comments
 (0)