@@ -14,10 +14,7 @@ size_t count_ada_invalid() {
1414 return how_many;
1515}
1616
17- enum { JUST_PARSE = 1 , PARSE_AND_HREF = 0 };
18-
19- template <bool just_parse = PARSE_AND_HREF,
20- class result_type = ada::url_aggregator>
17+ template <bool just_parse = false , class result_type = ada::url_aggregator>
2118static void BasicBench_AdaURL (benchmark::State& state) {
2219 // volatile to prevent optimizations.
2320 volatile size_t success = 0 ;
@@ -96,15 +93,15 @@ static void BasicBench_AdaURL(benchmark::State& state) {
9693#define BENCHMARK_NAME (name ) CONCAT(BENCHMARK_PREFIX, name)
9794
9895auto BENCHMARK_NAME (BasicBench_AdaURL_href) =
99- BasicBench_AdaURL<PARSE_AND_HREF , ada::url>;
96+ BasicBench_AdaURL<false , ada::url>;
10097static auto * CONCAT (benchmark_register_,
10198 BENCHMARK_NAME (BasicBench_AdaURL_href)) =
10299 ::benchmark::RegisterBenchmark(BENCHMARK_PREFIX_STR
103100 " BasicBench_AdaURL_href" ,
104101 BENCHMARK_NAME (BasicBench_AdaURL_href));
105102
106103auto BENCHMARK_NAME (BasicBench_AdaURL_aggregator_href) =
107- BasicBench_AdaURL<PARSE_AND_HREF , ada::url_aggregator>;
104+ BasicBench_AdaURL<false , ada::url_aggregator>;
108105static auto * CONCAT (benchmark_register_,
109106 BENCHMARK_NAME (BasicBench_AdaURL_aggregator_href)) =
110107 ::benchmark::RegisterBenchmark(
@@ -188,7 +185,7 @@ size_t count_whatwg_invalid() {
188185 return how_many;
189186}
190187
191- template <bool just_parse = PARSE_AND_HREF >
188+ template <bool just_parse = false >
192189static void BasicBench_whatwg (benchmark::State& state) {
193190 // volatile to prevent optimizations.
194191 volatile size_t success = 0 ;
@@ -198,7 +195,7 @@ static void BasicBench_whatwg(benchmark::State& state) {
198195 upa::url url;
199196 if (upa::success (url.parse (url_string, nullptr ))) {
200197 success++;
201- if (!just_parse) {
198+ if constexpr (!just_parse) {
202199 href_size += url.href ().size ();
203200 }
204201 }
@@ -213,7 +210,7 @@ static void BasicBench_whatwg(benchmark::State& state) {
213210 upa::url url;
214211 if (upa::success (url.parse (url_string, nullptr ))) {
215212 success++;
216- if (!just_parse) {
213+ if constexpr (!just_parse) {
217214 href_size += url.href ().size ();
218215 }
219216 }
@@ -255,7 +252,7 @@ BENCHMARK(BasicBench_whatwg);
255252// There is no need for BasicBench_whatwg_just_parse because whatwg appears to
256253// provide the href at a minimal cost, probably because it is already
257254// materialized. auto BasicBench_whatwg_just_parse =
258- // BasicBench_whatwg<JUST_PARSE >; BENCHMARK(BasicBench_whatwg_just_parse);
255+ // BasicBench_whatwg<true >; BENCHMARK(BasicBench_whatwg_just_parse);
259256
260257#endif // ADA_url_whatwg_ENABLED
261258
@@ -290,7 +287,7 @@ static void BasicBench_CURL(benchmark::State& state) {
290287 // Returns a CURLUcode error value, which is (0) if everything went fine.
291288 if (rc == 0 ) {
292289 success++;
293- if (!just_parse) {
290+ if constexpr (!just_parse) {
294291 char * buffer;
295292 // When asked to return the full URL, curl_url_get will return a
296293 // normalized and possibly cleaned up version of what was previously
@@ -313,7 +310,7 @@ static void BasicBench_CURL(benchmark::State& state) {
313310 CURLUcode rc = curl_url_set (url, CURLUPART_URL, url_string.c_str (), 0 );
314311 // Returns a CURLUcode error value, which is (0) if everything went
315312 // fine.
316- if (!just_parse) {
313+ if constexpr (!just_parse) {
317314 char * buffer;
318315 rc = curl_url_get (url, CURLUPART_URL, &buffer, 0 );
319316 if (rc == 0 ) {
@@ -357,7 +354,7 @@ static void BasicBench_CURL(benchmark::State& state) {
357354}
358355BENCHMARK (BasicBench_CURL);
359356// 'just parsing' is faster with curl, but maybe not so important for us.
360- // auto BasicBench_CURL_just_parse = BasicBench_CURL<JUST_PARSE >;
357+ // auto BasicBench_CURL_just_parse = BasicBench_CURL<true >;
361358// BENCHMARK(BasicBench_CURL_just_parse);
362359#endif
363360
@@ -391,7 +388,7 @@ static void BasicBench_BoostURL(benchmark::State& state) {
391388 url u (url_string);
392389 u.normalize ();
393390 success++;
394- if (!just_parse) {
391+ if constexpr (!just_parse) {
395392 href_size += u.buffer ().size ();
396393 }
397394 } catch (...) {
@@ -408,7 +405,7 @@ static void BasicBench_BoostURL(benchmark::State& state) {
408405 url u (url_string);
409406 u.normalize ();
410407 success++;
411- if (!just_parse) {
408+ if constexpr (!just_parse) {
412409 href_size += u.buffer ().size ();
413410 }
414411 } catch (...) {
@@ -450,7 +447,7 @@ static void BasicBench_BoostURL(benchmark::State& state) {
450447}
451448BENCHMARK (BasicBench_BoostURL);
452449// There is no need for 'just_parse' because BoostURL materializes the href.
453- // auto BasicBench_BoostURL_just_parse = BasicBench_BoostURL<JUST_PARSE >;
450+ // auto BasicBench_BoostURL_just_parse = BasicBench_BoostURL<true >;
454451// BENCHMARK(BasicBench_BoostURL_just_parse);
455452#endif // ADA_BOOST_ENABLED
456453
0 commit comments