Skip to content

Commit caf31e7

Browse files
authored
fix: use google clang-format style (#303)
* fix: use google clang-format style * refactor: remove unused url_base::get_scheme_type()
1 parent 5119ebe commit caf31e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+6834
-5617
lines changed

benchmarks/bbc_bench.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ std::string url_examples[] = {
2525

2626
void init_data(const char* v = nullptr) {}
2727

28-
double url_examples_bytes = []() -> double {
28+
double url_examples_bytes = []() -> double {
2929
size_t bytes{0};
30-
for (std::string &url_string : url_examples) {
30+
for (std::string& url_string : url_examples) {
3131
bytes += url_string.size();
3232
}
3333
return double(bytes);

benchmarks/bench.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,39 @@ std::string url_examples_default[] = {
1818
"41Gc3C8UysL.css?AUIClients/AmazonGatewayAuiAssets",
1919
"https://www.reddit.com/?after=t3_zvz1ze",
2020
"https://www.reddit.com/login/?dest=https%3A%2F%2Fwww.reddit.com%2F",
21-
"postgresql://other:9818274x1!!@localhost:5432/otherdb?connect_timeout=10&application_name=myapp",
22-
"http://192.168.1.1", // ipv4
23-
"http://[2606:4700:4700::1111]", // ipv6
21+
"postgresql://other:9818274x1!!@localhost:5432/"
22+
"otherdb?connect_timeout=10&application_name=myapp",
23+
"http://192.168.1.1", // ipv4
24+
"http://[2606:4700:4700::1111]", // ipv6
2425
};
2526

2627
std::vector<std::string> url_examples;
2728

28-
double url_examples_bytes = []() -> double {
29-
size_t bytes{0};
30-
for(std::string& url_string : url_examples) { bytes += url_string.size(); }
31-
return double(bytes);
32-
}();
29+
double url_examples_bytes = []() -> double {
30+
size_t bytes{0};
31+
for (std::string& url_string : url_examples) {
32+
bytes += url_string.size();
33+
}
34+
return double(bytes);
35+
}();
3336

3437
#ifdef ADA_URL_FILE
3538
const char* default_file = ADA_URL_FILE;
3639
#else
3740
const char* default_file = nullptr;
3841
#endif
3942

40-
4143
size_t init_data(const char* input = default_file) {
4244
// compute the number of bytes.
43-
auto compute = []() -> double {
45+
auto compute = []() -> double {
4446
size_t bytes{0};
45-
for(std::string& url_string : url_examples) { bytes += url_string.size(); }
47+
for (std::string& url_string : url_examples) {
48+
bytes += url_string.size();
49+
}
4650
return double(bytes);
4751
};
48-
if(input == nullptr) {
49-
for(const std::string& s : url_examples_default) {
52+
if (input == nullptr) {
53+
for (const std::string& s : url_examples_default) {
5054
url_examples.emplace_back(s);
5155
}
5256
url_examples_bytes = compute();
@@ -55,7 +59,7 @@ size_t init_data(const char* input = default_file) {
5559

5660
if (!file_exists(input)) {
5761
std::cout << "File not found !" << input << std::endl;
58-
for(const std::string& s : url_examples_default) {
62+
for (const std::string& s : url_examples_default) {
5963
url_examples.emplace_back(s);
6064
}
6165
} else {

benchmarks/benchmark_header.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ size_t N = 1000;
2121

2222
#include <benchmark/benchmark.h>
2323

24-
25-
bool file_exists(const char *filename) {
24+
bool file_exists(const char* filename) {
2625
namespace fs = std::filesystem;
2726
std::filesystem::path f{filename};
2827
if (std::filesystem::exists(filename)) {
@@ -33,8 +32,6 @@ bool file_exists(const char *filename) {
3332
}
3433
}
3534

36-
37-
3835
std::string read_file(std::string filename) {
3936
constexpr auto read_size = std::size_t(4096);
4037
auto stream = std::ifstream(filename.c_str());
@@ -55,9 +52,15 @@ std::vector<std::string> split_string(const std::string& str) {
5552
std::string_view view = line;
5653
// Some parsers like boost/url will refuse to parse a URL with trailing
5754
// whitespace.
58-
while(!view.empty() && std::isspace(view.back())) { view.remove_suffix(1); }
59-
while(!view.empty() && std::isspace(view.front())) { view.remove_prefix(1); }
60-
if(!view.empty()) { result.emplace_back(view); }
55+
while (!view.empty() && std::isspace(view.back())) {
56+
view.remove_suffix(1);
57+
}
58+
while (!view.empty() && std::isspace(view.front())) {
59+
view.remove_prefix(1);
60+
}
61+
if (!view.empty()) {
62+
result.emplace_back(view);
63+
}
6164
}
6265
return result;
6366
}

0 commit comments

Comments
 (0)