Skip to content

Commit 31b1f28

Browse files
authored
URLPattern: replace std::string with std::string_view (#1032)
1 parent 4f1908e commit 31b1f28

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

include/ada/url_pattern_helpers-inl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ std::string constructor_string_parser<regex_provider>::make_component_string() {
294294
const auto component_start_input_index = component_start_token->index;
295295
// Return the code point substring from component start input index to end
296296
// index within parser's input.
297-
return input.substr(component_start_input_index,
298-
end_index - component_start_input_index);
297+
return std::string(input.substr(component_start_input_index,
298+
end_index - component_start_input_index));
299299
}
300300

301301
template <url_pattern_regex::regex_concept regex_provider>

include/ada/url_pattern_helpers.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ enum class token_policy {
4747
// @see https://urlpattern.spec.whatwg.org/#tokens
4848
class token {
4949
public:
50-
token(token_type _type, size_t _index, std::string&& _value)
51-
: type(_type), index(_index), value(std::move(_value)) {}
50+
token(token_type _type, size_t _index, std::string_view _value)
51+
: type(_type), index(_index), value(_value) {}
5252

5353
// A token has an associated type, a string, initially "invalid-char".
5454
token_type type = token_type::INVALID_CHAR;
@@ -59,7 +59,7 @@ class token {
5959

6060
// A token has an associated value, a string, initially the empty string. It
6161
// contains the code points from the pattern string represented by the token.
62-
std::string value{};
62+
std::string_view value{};
6363
};
6464

6565
// @see https://urlpattern.spec.whatwg.org/#pattern-parser
@@ -137,7 +137,7 @@ class Tokenizer {
137137

138138
private:
139139
// has an associated input, a pattern string, initially the empty string.
140-
std::string input;
140+
std::string_view input;
141141
// has an associated policy, a tokenize policy, initially "strict".
142142
token_policy policy;
143143
// has an associated token list, a token list, initially an empty list.
@@ -231,7 +231,7 @@ struct constructor_string_parser {
231231
// @see https://urlpattern.spec.whatwg.org/#make-a-component-string
232232
std::string make_component_string();
233233
// has an associated input, a string, which must be set upon creation.
234-
std::string input;
234+
std::string_view input;
235235
// has an associated token list, a token list, which must be set upon
236236
// creation.
237237
std::vector<token> token_list;

0 commit comments

Comments
 (0)