Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check template arguments with constexpr #735

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/unicode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ bool percent_encode(const std::string_view input, const uint8_t character_set[],
ada_log("percent_encode encoding not needed.");
return false;
}
if (!append) {
if constexpr (!append) {
out.clear();
}
ada_log("percent_encode appending ", std::distance(input.begin(), pointer),
Expand Down
2 changes: 1 addition & 1 deletion src/url-setters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bool url::set_host_or_hostname(const std::string_view input) {
// Note: the 'found_colon' value is true if and only if a colon was
// encountered while not inside brackets.
if (found_colon) {
if (override_hostname) {
if constexpr (override_hostname) {
return false;
}
std::string_view buffer = new_host.substr(location + 1);
Expand Down
8 changes: 4 additions & 4 deletions src/url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ ada_really_inline bool url::parse_scheme(const std::string_view input) {
*http, https), in which case, we can go really fast.
**/
if (is_input_special) { // fast path!!!
if (has_state_override) {
if constexpr (has_state_override) {
// If url's scheme is not a special scheme and buffer is a special scheme,
// then return.
if (is_special() != is_input_special) {
Expand All @@ -360,7 +360,7 @@ ada_really_inline bool url::parse_scheme(const std::string_view input) {

type = parsed_type;

if (has_state_override) {
if constexpr (has_state_override) {
// This is uncommon.
uint16_t urls_scheme_port = get_special_port();

Expand All @@ -380,7 +380,7 @@ ada_really_inline bool url::parse_scheme(const std::string_view input) {
// bool is_ascii =
unicode::to_lower_ascii(_buffer.data(), _buffer.size());

if (has_state_override) {
if constexpr (has_state_override) {
// If url's scheme is a special scheme and buffer is not a special scheme,
// then return. If url's scheme is not a special scheme and buffer is a
// special scheme, then return.
Expand All @@ -404,7 +404,7 @@ ada_really_inline bool url::parse_scheme(const std::string_view input) {

set_scheme(std::move(_buffer));

if (has_state_override) {
if constexpr (has_state_override) {
// This is uncommon.
uint16_t urls_scheme_port = get_special_port();

Expand Down
10 changes: 5 additions & 5 deletions src/url_aggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ template <bool has_state_override>
*http, https), in which case, we can go really fast.
**/
if (is_input_special) { // fast path!!!
if (has_state_override) {
if constexpr (has_state_override) {
// If url's scheme is not a special scheme and buffer is a special scheme,
// then return.
if (is_special() != is_input_special) {
Expand All @@ -52,7 +52,7 @@ template <bool has_state_override>
type = parsed_type;
set_scheme_from_view_with_colon(input_with_colon);

if (has_state_override) {
if constexpr (has_state_override) {
// This is uncommon.
uint16_t urls_scheme_port = get_special_port();

Expand All @@ -69,7 +69,7 @@ template <bool has_state_override>
// need to check the return value.
unicode::to_lower_ascii(_buffer.data(), _buffer.size());

if (has_state_override) {
if constexpr (has_state_override) {
// If url's scheme is a special scheme and buffer is not a special scheme,
// then return. If url's scheme is not a special scheme and buffer is a
// special scheme, then return.
Expand All @@ -94,7 +94,7 @@ template <bool has_state_override>

set_scheme(_buffer);

if (has_state_override) {
if constexpr (has_state_override) {
// This is uncommon.
uint16_t urls_scheme_port = get_special_port();

Expand Down Expand Up @@ -539,7 +539,7 @@ bool url_aggregator::set_host_or_hostname(const std::string_view input) {
// Note: the 'found_colon' value is true if and only if a colon was
// encountered while not inside brackets.
if (found_colon) {
if (override_hostname) {
if constexpr (override_hostname) {
return false;
}
std::string_view sub_buffer = new_host.substr(location + 1);
Expand Down
Loading