Skip to content

Commit

Permalink
{style} Prefer brace list returns
Browse files Browse the repository at this point in the history
  • Loading branch information
asmaloney authored and tordex committed Apr 23, 2024
1 parent 0538249 commit 43d7d68
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions src/css_tokenizer.cpp
Expand Up @@ -191,7 +191,7 @@ css_token css_tokenizer::consume_string_token(int ending_code_point)
// This is a parse error. Reconsume the current input code point, create a <bad-string-token>, and return it.
css_parse_error("newline in string");
unconsume_char();
return css_token(BAD_STRING);
return {BAD_STRING};
case '\\':
// If the next input code point is EOF, do nothing.
if (str[index] == 0)
Expand Down Expand Up @@ -410,11 +410,11 @@ css_token css_tokenizer::consume_numeric_token()
if (str[index] == '%')
{
index++;
return css_token(PERCENTAGE, number); // NOTE: number_type is unused in <percentage-token>
return {PERCENTAGE, number}; // NOTE: number_type is unused in <percentage-token>
}

// Otherwise, create a <number-token> with the same value and type flag as number, and return it.
return css_token(NUMBER, number, type);
return {NUMBER, number, type};
}

// https://www.w3.org/TR/css-syntax-3/#consume-remnants-of-bad-url
Expand Down Expand Up @@ -479,7 +479,7 @@ css_token css_tokenizer::consume_url_token()
}
// otherwise, consume the remnants of a bad url, create a <bad-url-token>, and return it.
consume_remnants_of_bad_url();
return css_token(BAD_URL);
return {BAD_URL};

case '"':
case '\'':
Expand All @@ -488,7 +488,7 @@ css_token css_tokenizer::consume_url_token()
// This is a parse error. Consume the remnants of a bad url, create a <bad-url-token>, and return it.
css_parse_error("invalid char in unquoted url");
consume_remnants_of_bad_url();
return css_token(BAD_URL);
return {BAD_URL};

case '\\':
// If the stream starts with a valid escape, consume an escaped code point and
Expand All @@ -500,7 +500,7 @@ css_token css_tokenizer::consume_url_token()
{
css_parse_error("escaped newline in unquoted url");
consume_remnants_of_bad_url();
return css_token(BAD_URL);
return {BAD_URL};
}
break;

Expand Down Expand Up @@ -535,7 +535,7 @@ css_token css_tokenizer::consume_ident_like_token()
{
// This is not exactly what standard says, but equivalent. The purpose is to preserve a whitespace token.
if (is_whitespace(str[index-1])) index--;
return css_token(FUNCTION, string);
return {FUNCTION, string};
}
else // Otherwise, consume a url token, and return it.
{
Expand All @@ -548,11 +548,11 @@ css_token css_tokenizer::consume_ident_like_token()
else if (str[index] == '(')
{
index++;
return css_token(FUNCTION, string);
return {FUNCTION, string};
}

// Otherwise, create an <ident-token> with its value set to string and return it.
return css_token(IDENT, string);
return {IDENT, string};
}

// https://www.w3.org/TR/css-syntax-3/#consume-token
Expand Down
2 changes: 1 addition & 1 deletion src/el_before_after.cpp
Expand Up @@ -212,5 +212,5 @@ litehtml::string litehtml::el_before_after_base::convert_escape( const char* txt
char32_t u_str[2];
u_str[0] = (char32_t) strtol(txt, &str_end, 16);
u_str[1] = 0;
return litehtml::string(litehtml_from_utf32(u_str));
return {litehtml_from_utf32(u_str)};
}
2 changes: 1 addition & 1 deletion src/el_text.cpp
Expand Up @@ -136,5 +136,5 @@ litehtml::string litehtml::el_text::dump_get_name()

std::vector<std::tuple<litehtml::string, litehtml::string>> litehtml::el_text::dump_get_attrs()
{
return std::vector<std::tuple<string, string>>();
return {};
}
10 changes: 5 additions & 5 deletions src/url.cpp
Expand Up @@ -136,7 +136,7 @@ url resolve(const url& b, const url& r)
if (r.has_scheme()) {
return r;
} else if (r.has_authority()) {
return url(b.scheme(), r.authority(), r.path(), r.query(), r.fragment());
return {b.scheme(), r.authority(), r.path(), r.query(), r.fragment()};
} else if (r.has_path()) {

// The relative URL path is either an absolute path or a relative
Expand All @@ -145,18 +145,18 @@ url resolve(const url& b, const url& r)
// against the base path and build the URL using the resolved path.

if (is_url_path_absolute(r.path())) {
return url(b.scheme(), b.authority(), r.path(), r.query(), r.fragment());
return {b.scheme(), b.authority(), r.path(), r.query(), r.fragment()};
} else {
string path = url_path_resolve(b.path(), r.path());
return url(b.scheme(), b.authority(), path, r.query(), r.fragment());
return {b.scheme(), b.authority(), path, r.query(), r.fragment()};
}

} else if (r.has_query()) {
return url(b.scheme(), b.authority(), b.path(), r.query(), r.fragment());
return {b.scheme(), b.authority(), b.path(), r.query(), r.fragment()};
} else {
// The resolved URL never includes the base URL fragment (i.e., it
// always includes the reference URL fragment).
return url(b.scheme(), b.authority(), b.path(), b.query(), r.fragment());
return {b.scheme(), b.authority(), b.path(), b.query(), r.fragment()};
}
}

Expand Down

0 comments on commit 43d7d68

Please sign in to comment.