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

refactor: cleanup clang-tidy warnings #672

Merged
merged 1 commit into from
May 17, 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
6 changes: 2 additions & 4 deletions src/helpers.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "ada.h"
#include "ada/checkers-inl.h"
#include "ada/checkers.h"
#include "ada/common_defs.h" // make sure ADA_IS_BIG_ENDIAN gets defined.
#include "ada/unicode.h"
#include "ada/scheme.h"

#include <algorithm>
Expand Down Expand Up @@ -748,7 +746,7 @@ ada_really_inline void strip_trailing_spaces_from_opaque_path(
static constexpr std::array<uint8_t, 256> authority_delimiter_special =
[]() constexpr {
std::array<uint8_t, 256> result{};
for (int i : {'@', '/', '\\', '?'}) {
for (uint8_t i : {'@', '/', '\\', '?'}) {
result[i] = 1;
}
return result;
Expand All @@ -769,7 +767,7 @@ find_authority_delimiter_special(std::string_view view) noexcept {
// @ / ?
static constexpr std::array<uint8_t, 256> authority_delimiter = []() constexpr {
std::array<uint8_t, 256> result{};
for (int i : {'@', '/', '?'}) {
for (uint8_t i : {'@', '/', '?'}) {
result[i] = 1;
}
return result;
Expand Down
1 change: 0 additions & 1 deletion src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "ada/log.h"
#include "ada/parser.h"

#include <numeric>
#include <limits>

namespace ada::parser {
Expand Down
11 changes: 2 additions & 9 deletions src/unicode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,8 @@ contains_forbidden_domain_code_point_or_upper(const char* input,
constexpr static std::array<bool, 256> is_alnum_plus_table = []() constexpr {
std::array<bool, 256> result{};
for (size_t c = 0; c < 256; c++) {
if (c >= '0' && c <= '9') {
result[c] = true;
} else if (c >= 'a' && c <= 'z') {
result[c] = true;
} else if (c >= 'A' && c <= 'Z') {
result[c] = true;
} else if (c == '+' || c == '-' || c == '.') {
result[c] = true;
}
result[c] = (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') || c == '+' || c == '-' || c == '.';
}
return result;
}();
Expand Down
1 change: 0 additions & 1 deletion src/url-getters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "ada/helpers.h"
#include "ada/scheme.h"

#include <algorithm>
#include <string>

namespace ada {
Expand Down
1 change: 0 additions & 1 deletion src/url-setters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ void url::set_hash(const std::string_view input) {
helpers::remove_ascii_tab_or_newline(new_value);
hash = unicode::percent_encode(new_value,
ada::character_sets::FRAGMENT_PERCENT_ENCODE);
return;
}

void url::set_search(const std::string_view input) {
Expand Down
2 changes: 1 addition & 1 deletion src/url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool url::parse_ipv4(std::string_view input) {
segment_result = 0;
input.remove_prefix(2);
} else {
std::from_chars_result r;
std::from_chars_result r{};
if (is_hex) {
r = std::from_chars(input.data() + 2, input.data() + input.size(),
segment_result, 16);
Expand Down
10 changes: 4 additions & 6 deletions src/url_aggregator.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#include "ada.h"
#include "ada/checkers-inl.h"
#include "ada/checkers.h"
#include "ada/helpers.h"
#include "ada/implementation.h"
#include "ada/scheme.h"
#include "ada/unicode-inl.h"
#include "ada/url_components.h"
#include "ada/url_aggregator.h"
#include "ada/url_aggregator-inl.h"
#include "ada/parser.h"

#include <string>
#include <string_view>
Expand Down Expand Up @@ -701,7 +699,7 @@ bool url_aggregator::set_hostname(const std::string_view input) {
// if we have an empty host, then the space between components.host_end and
// components.pathname_start may be occupied by /.
if (start == components.host_end) {
return std::string_view();
return {};
}
return helpers::substring(buffer, start, components.pathname_start);
}
Expand All @@ -725,7 +723,7 @@ bool url_aggregator::set_hostname(const std::string_view input) {
components.pathname_start, " buffer.size() = ", buffer.size(),
" components.search_start = ", components.search_start,
" components.hash_start = ", components.hash_start);
uint32_t ending_index = uint32_t(buffer.size());
auto ending_index = uint32_t(buffer.size());
if (components.search_start != url_components::omitted) {
ending_index = components.search_start;
} else if (components.hash_start != url_components::omitted) {
Expand All @@ -741,7 +739,7 @@ bool url_aggregator::set_hostname(const std::string_view input) {
if (components.search_start == url_components::omitted) {
return "";
}
uint32_t ending_index = uint32_t(buffer.size());
auto ending_index = uint32_t(buffer.size());
if (components.hash_start != url_components::omitted) {
ending_index = components.hash_start;
}
Expand Down Expand Up @@ -879,7 +877,7 @@ bool url_aggregator::parse_ipv4(std::string_view input, bool in_place) {
segment_result = 0;
input.remove_prefix(2);
} else {
std::from_chars_result r;
std::from_chars_result r{};
if (is_hex) {
ada_log("parse_ipv4 trying to parse hex number");
r = std::from_chars(input.data() + 2, input.data() + input.size(),
Expand Down
1 change: 0 additions & 1 deletion src/url_components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ namespace ada {
if (hash_start < index) {
return false;
}
index = hash_start;
}

return true;
Expand Down
Loading