_ZN3ada7unicode14percent_encodeILb1EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEE:
 7679|  3.17k|                    std::string& out) {
 7680|  3.17k|  ada_log("percent_encode ", input, " to output string while ",
 7681|  3.17k|          append ? "appending" : "overwriting");
 7682|  3.17k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7683|  3.17k|    return character_sets::bit_at(character_set, c);
 7684|  3.17k|  });
 7685|  3.17k|  ada_log("percent_encode done checking, moved to ",
 7686|  3.17k|          std::distance(input.begin(), pointer));
 7687|       |
 7688|       |  // Optimization: Don't iterate if percent encode is not required
 7689|  3.17k|  if (pointer == input.end()) {
  ------------------
  |  Branch (7689:7): [True: 1.80k, False: 1.37k]
  ------------------
 7690|  1.80k|    ada_log("percent_encode encoding not needed.");
 7691|  1.80k|    return false;
 7692|  1.80k|  }
 7693|       |  if constexpr (!append) {
 7694|       |    out.clear();
 7695|       |  }
 7696|  1.37k|  ada_log("percent_encode appending ", std::distance(input.begin(), pointer),
 7697|  1.37k|          " bytes");
 7698|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7699|  1.37k|  out.append(input.data(), std::distance(input.begin(), pointer));
 7700|  1.37k|  ada_log("percent_encode processing ", std::distance(pointer, input.end()),
 7701|  1.37k|          " bytes");
 7702|  56.2k|  for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7702:10): [True: 54.9k, False: 1.37k]
  ------------------
 7703|  54.9k|    if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7703:9): [True: 39.2k, False: 15.6k]
  ------------------
 7704|  39.2k|      out.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7705|  39.2k|    } else {
 7706|  15.6k|      out += *pointer;
 7707|  15.6k|    }
 7708|  54.9k|  }
 7709|  1.37k|  return true;
 7710|  3.17k|}
_ZN3ada7unicode22form_urlencoded_decodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7579|  58.4k|std::string form_urlencoded_decode(const std::string_view input) {
 7580|  58.4k|  const size_t len = input.size();
 7581|  58.4k|  if (len == 0) [[unlikely]] {
  ------------------
  |  Branch (7581:7): [True: 28.5k, False: 29.9k]
  ------------------
 7582|  28.5k|    return {};
 7583|  28.5k|  }
 7584|       |
 7585|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7586|  29.9k|  const char* const src = input.data();
 7587|  29.9k|  const char* const end = src + len;
 7588|  29.9k|  const char* p = src;
 7589|       |
 7590|       |  // Advance over the untransformed prefix.
 7591|   115k|  while (p < end && *p != '+' && *p != '%') {
  ------------------
  |  Branch (7591:10): [True: 103k, False: 12.4k]
  |  Branch (7591:21): [True: 101k, False: 1.45k]
  |  Branch (7591:34): [True: 85.6k, False: 16.0k]
  ------------------
 7592|  85.6k|    ++p;
 7593|  85.6k|  }
 7594|  29.9k|  if (p == end) {
  ------------------
  |  Branch (7594:7): [True: 12.4k, False: 17.5k]
  ------------------
 7595|  12.4k|    return std::string(input);
 7596|  12.4k|  }
 7597|       |
 7598|       |  // Output is always at most as long as the input: write into a single
 7599|       |  // pre-sized buffer, then shrink to the final length.
 7600|  17.5k|  std::string out(len, '\0');
 7601|  17.5k|  char* d = out.data();
 7602|  17.5k|  char* const d0 = d;
 7603|       |
 7604|  17.5k|  const size_t prefix = static_cast<size_t>(p - src);
 7605|  17.5k|  std::memcpy(d, src, prefix);
 7606|  17.5k|  d += prefix;
 7607|       |
 7608|  61.9k|  while (p < end) {
  ------------------
  |  Branch (7608:10): [True: 44.4k, False: 17.5k]
  ------------------
 7609|  44.4k|    const char c = *p;
 7610|  44.4k|    if (c == '+') {
  ------------------
  |  Branch (7610:9): [True: 9.25k, False: 35.1k]
  ------------------
 7611|  9.25k|      *d++ = ' ';
 7612|  9.25k|      ++p;
 7613|  35.1k|    } else if (c == '%') {
  ------------------
  |  Branch (7613:16): [True: 23.6k, False: 11.4k]
  ------------------
 7614|       |      // Decode runs of valid %XX tightly (common for nested URL query values).
 7615|   145k|      while (p + 2 < end && *p == '%') {
  ------------------
  |  Branch (7615:14): [True: 129k, False: 15.6k]
  |  Branch (7615:29): [True: 123k, False: 6.52k]
  ------------------
 7616|   123k|        const uint8_t hi = unhex_table[static_cast<uint8_t>(p[1])];
 7617|   123k|        const uint8_t lo = unhex_table[static_cast<uint8_t>(p[2])];
 7618|   123k|        if ((hi | lo) >= 16) {
  ------------------
  |  Branch (7618:13): [True: 1.50k, False: 121k]
  ------------------
 7619|  1.50k|          break;
 7620|  1.50k|        }
 7621|   121k|        *d++ = static_cast<char>((hi << 4) | lo);
 7622|   121k|        p += 3;
 7623|   121k|      }
 7624|  23.6k|      if (p < end && *p == '%') {
  ------------------
  |  Branch (7624:11): [True: 11.1k, False: 12.5k]
  |  Branch (7624:22): [True: 3.21k, False: 7.90k]
  ------------------
 7625|       |        // Invalid escape: copy '%' literally and continue.
 7626|  3.21k|        *d++ = *p++;
 7627|  3.21k|      }
 7628|  23.6k|    } else {
 7629|       |      // Copy a plain run until the next '+' or '%'.
 7630|  11.4k|      const char* start = p;
 7631|  11.4k|      ++p;
 7632|  38.3k|      while (p < end && *p != '+' && *p != '%') {
  ------------------
  |  Branch (7632:14): [True: 36.3k, False: 2.04k]
  |  Branch (7632:25): [True: 32.7k, False: 3.56k]
  |  Branch (7632:38): [True: 26.8k, False: 5.89k]
  ------------------
 7633|  26.8k|        ++p;
 7634|  26.8k|      }
 7635|  11.4k|      const size_t n = static_cast<size_t>(p - start);
 7636|  11.4k|      std::memcpy(d, start, n);
 7637|  11.4k|      d += n;
 7638|  11.4k|    }
 7639|  44.4k|  }
 7640|       |
 7641|  17.5k|  out.resize(static_cast<size_t>(d - d0));
 7642|  17.5k|  return out;
 7643|  29.9k|}
_ZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 7649|   122k|                           const uint8_t character_set[]) {
 7650|   122k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7651|   122k|    return character_sets::bit_at(character_set, c);
 7652|   122k|  });
 7653|       |  // Optimization: Don't iterate if percent encode is not required
 7654|   122k|  if (pointer == input.end()) {
  ------------------
  |  Branch (7654:7): [True: 82.1k, False: 40.2k]
  ------------------
 7655|  82.1k|    return std::string(input);
 7656|  82.1k|  }
 7657|       |
 7658|  40.2k|  std::string result;
 7659|  40.2k|  result.reserve(input.length());  // in the worst case, percent encoding might
 7660|       |                                   // produce 3 characters.
 7661|  40.2k|  result.append(input.substr(0, std::distance(input.begin(), pointer)));
 7662|  40.2k|  if (static_cast<size_t>(input.end() - pointer) >= 48) {
  ------------------
  |  Branch (7662:7): [True: 3.58k, False: 36.6k]
  ------------------
 7663|  3.58k|    percent_encode_suffix(&*pointer, input.data() + input.size(), character_set,
 7664|  3.58k|                          result);
 7665|  36.6k|  } else {
 7666|   211k|    for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7666:12): [True: 174k, False: 36.6k]
  ------------------
 7667|   174k|      if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7667:11): [True: 150k, False: 24.0k]
  ------------------
 7668|   150k|        result.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7669|   150k|      } else {
 7670|  24.0k|        result += *pointer;
 7671|  24.0k|      }
 7672|   174k|    }
 7673|  36.6k|  }
 7674|  40.2k|  return result;
 7675|   122k|}
_ZN3ada7unicode21percent_encode_suffixEPKcS2_PKhRNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE:
 8054|  3.58k|                           const uint8_t character_set[], std::string& out) {
 8055|  3.58k|#if ADA_UNICODE_SSSE3 || ADA_NEON || ADA_RVV
 8056|  3.58k|#ifdef ADA_UNICODE_NEED_SSSE3_TARGET
 8057|  3.58k|  static const bool ssse3_supported = __builtin_cpu_supports("ssse3") != 0;
 8058|  3.58k|  const bool use_wide = ssse3_supported;
 8059|       |#else
 8060|       |  const bool use_wide = true;
 8061|       |#endif
 8062|  3.58k|  if (use_wide && static_cast<size_t>(end - p) >= kPercentEncodeSimdMin) {
  ------------------
  |  Branch (8062:7): [True: 3.58k, False: 0]
  |  Branch (8062:19): [True: 3.58k, False: 0]
  ------------------
 8063|  3.58k|    percent_encode_to_wide(p, end, character_set, out);
 8064|  3.58k|    return;
 8065|  3.58k|  }
 8066|      0|#endif
 8067|      0|  percent_encode_to_scalar(p, end, character_set, out);
 8068|      0|}
_ZN3ada5parseINS_14url_aggregatorEEEN2tl8expectedIT_NS_6errorsEEENSt3__117basic_string_viewIcNS7_11char_traitsIcEEEEPKS4_:
 8609|  2.93k|    std::string_view input, const result_type* base_url) {
 8610|  2.93k|  result_type u = ada::parser::parse_url_impl<result_type>(input, base_url);
 8611|  2.93k|  if (!u.is_valid) {
  ------------------
  |  Branch (8611:7): [True: 0, False: 2.93k]
  ------------------
 8612|      0|    return tl::unexpected(errors::type_error);
 8613|      0|  }
 8614|  2.93k|  return u;
 8615|  2.93k|}
_ZN3ada20get_max_input_lengthEv:
 8230|  10.8k|uint32_t get_max_input_length() {
 8231|  10.8k|  return max_input_length_.load(std::memory_order_relaxed);
 8232|  10.8k|}
_ZN3ada7helpers18trim_c0_whitespaceERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9597|    491|void trim_c0_whitespace(std::string_view& input) noexcept {
 9598|    491|  while (!input.empty() &&
  ------------------
  |  Branch (9598:10): [True: 491, False: 0]
  ------------------
 9599|    491|         ada::unicode::is_c0_control_or_space(input.front())) {
  ------------------
  |  Branch (9599:10): [True: 0, False: 491]
  ------------------
 9600|      0|    input.remove_prefix(1);
 9601|      0|  }
 9602|  2.77k|  while (!input.empty() && ada::unicode::is_c0_control_or_space(input.back())) {
  ------------------
  |  Branch (9602:10): [True: 2.77k, False: 0]
  |  Branch (9602:28): [True: 2.27k, False: 491]
  ------------------
 9603|  2.27k|    input.remove_suffix(1);
 9604|  2.27k|  }
 9605|    491|}
_ZN3ada7helpers8overlapsENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERKNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 9769|  2.93k|bool overlaps(std::string_view input1, const std::string& input2) noexcept {
 9770|  2.93k|  ada_log("helpers::overlaps check if string_view '", input1, "' [",
 9771|  2.93k|          input1.size(), " bytes] is part of string '", input2, "' [",
 9772|  2.93k|          input2.size(), " bytes]");
 9773|  2.93k|  return !input1.empty() && !input2.empty() && input1.data() >= input2.data() &&
  ------------------
  |  Branch (9773:10): [True: 1.57k, False: 1.35k]
  |  Branch (9773:29): [True: 1.57k, False: 0]
  |  Branch (9773:48): [True: 1.14k, False: 425]
  ------------------
 9774|  1.14k|         input1.data() < input2.data() + input2.size();
  ------------------
  |  Branch (9774:10): [True: 0, False: 1.14k]
  ------------------
 9775|  2.93k|}
_ZN3ada6parser25try_parse_simple_absoluteINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_:
12329|  2.93k|                                                result_type& out) {
12330|  2.93k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
12331|  2.93k|  constexpr bool is_aggregator =
12332|  2.93k|      std::is_same_v<result_type, ada::url_aggregator>;
12333|  2.93k|  static_assert(is_ada_url || is_aggregator);
12334|       |
12335|  2.93k|  const size_t len = input.size();
12336|       |  // Shortest accepted form is "ws://x" (6).
12337|  2.93k|  if (len < 6) [[unlikely]] {
  ------------------
  |  Branch (12337:7): [True: 0, False: 2.93k]
  ------------------
12338|      0|    return false;
12339|      0|  }
12340|  2.93k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
12341|       |
12342|  2.93k|  size_t pos = 0;
12343|  2.93k|  ada::scheme::type scheme_type = ada::scheme::type::NOT_SPECIAL;
12344|  2.93k|  uint32_t protocol_end = 0;
12345|  2.93k|#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
12346|  2.93k|    defined(_M_X64) || defined(_M_IX86) || defined(_M_AMD64)
12347|       |  // One 8-byte load + integer compare is a single cmp/jcc on x86-64.
12348|       |  // Masked compares cover the shorter special schemes without extra loads.
12349|  2.93k|  if (len >= 8) {
  ------------------
  |  Branch (12349:7): [True: 2.93k, False: 0]
  ------------------
12350|  2.93k|    uint64_t first8 = 0;
12351|  2.93k|    std::memcpy(&first8, b, 8);
12352|  2.93k|    if (first8 == 0x2f2f3a7370747468ull) {  // "https://"
  ------------------
  |  Branch (12352:9): [True: 2.93k, False: 0]
  ------------------
12353|  2.93k|      pos = 8;
12354|  2.93k|      scheme_type = ada::scheme::type::HTTPS;
12355|  2.93k|      protocol_end = 6;
12356|  2.93k|    } else if ((first8 & 0x00ffffffffffffffull) ==
  ------------------
  |  Branch (12356:16): [True: 0, False: 0]
  ------------------
12357|      0|               0x002f2f3a70747468ull) {  // "http://"
12358|      0|      pos = 7;
12359|      0|      scheme_type = ada::scheme::type::HTTP;
12360|      0|      protocol_end = 5;
12361|      0|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (12361:16): [True: 0, False: 0]
  ------------------
12362|      0|               0x00002f2f3a737377ull) {  // "wss://"
12363|      0|      pos = 6;
12364|      0|      scheme_type = ada::scheme::type::WSS;
12365|      0|      protocol_end = 4;
12366|      0|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (12366:16): [True: 0, False: 0]
  ------------------
12367|      0|               0x00002f2f3a707466ull) {  // "ftp://"
12368|      0|      pos = 6;
12369|      0|      scheme_type = ada::scheme::type::FTP;
12370|      0|      protocol_end = 4;
12371|      0|    } else if ((first8 & 0x000000ffffffffffull) ==
  ------------------
  |  Branch (12371:16): [True: 0, False: 0]
  ------------------
12372|      0|               0x0000002f2f3a7377ull) {  // "ws://"
12373|      0|      pos = 5;
12374|      0|      scheme_type = ada::scheme::type::WS;
12375|      0|      protocol_end = 3;
12376|      0|    } else {
12377|      0|      return false;
12378|      0|    }
12379|  2.93k|  } else if (b[0] == 'w' && b[1] == 's') {
  ------------------
  |  Branch (12379:14): [True: 0, False: 0]
  |  Branch (12379:29): [True: 0, False: 0]
  ------------------
12380|      0|    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
  ------------------
  |  Branch (12380:9): [True: 0, False: 0]
  |  Branch (12380:24): [True: 0, False: 0]
  |  Branch (12380:39): [True: 0, False: 0]
  ------------------
12381|      0|      pos = 5;
12382|      0|      scheme_type = ada::scheme::type::WS;
12383|      0|      protocol_end = 3;
12384|      0|    } else if (b[2] == 's' && b[3] == ':' && b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12384:16): [True: 0, False: 0]
  |  Branch (12384:31): [True: 0, False: 0]
  |  Branch (12384:46): [True: 0, False: 0]
  |  Branch (12384:61): [True: 0, False: 0]
  ------------------
12385|      0|      pos = 6;
12386|      0|      scheme_type = ada::scheme::type::WSS;
12387|      0|      protocol_end = 4;
12388|      0|    } else {
12389|      0|      return false;
12390|      0|    }
12391|      0|  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
  ------------------
  |  Branch (12391:14): [True: 0, False: 0]
  |  Branch (12391:29): [True: 0, False: 0]
  |  Branch (12391:44): [True: 0, False: 0]
  |  Branch (12391:59): [True: 0, False: 0]
  ------------------
12392|      0|             b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12392:14): [True: 0, False: 0]
  |  Branch (12392:29): [True: 0, False: 0]
  ------------------
12393|      0|    pos = 6;
12394|      0|    scheme_type = ada::scheme::type::FTP;
12395|      0|    protocol_end = 4;
12396|      0|  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
  ------------------
  |  Branch (12396:14): [True: 0, False: 0]
  |  Branch (12396:26): [True: 0, False: 0]
  |  Branch (12396:41): [True: 0, False: 0]
  |  Branch (12396:56): [True: 0, False: 0]
  ------------------
12397|      0|             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
  ------------------
  |  Branch (12397:14): [True: 0, False: 0]
  |  Branch (12397:29): [True: 0, False: 0]
  |  Branch (12397:44): [True: 0, False: 0]
  |  Branch (12397:59): [True: 0, False: 0]
  ------------------
12398|      0|    pos = 7;
12399|      0|    scheme_type = ada::scheme::type::HTTP;
12400|      0|    protocol_end = 5;
12401|      0|  } else {
12402|      0|    return false;
12403|      0|  }
12404|       |#else
12405|       |  // Big-endian / uncommon arches: byte-wise special-scheme match.
12406|       |  if (len >= 8 && b[0] == 'h' && b[1] == 't' && b[2] == 't' && b[3] == 'p' &&
12407|       |      b[4] == 's' && b[5] == ':' && b[6] == '/' && b[7] == '/') {
12408|       |    pos = 8;
12409|       |    scheme_type = ada::scheme::type::HTTPS;
12410|       |    protocol_end = 6;
12411|       |  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
12412|       |             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
12413|       |    pos = 7;
12414|       |    scheme_type = ada::scheme::type::HTTP;
12415|       |    protocol_end = 5;
12416|       |  } else if (b[0] == 'w' && b[1] == 's') {
12417|       |    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
12418|       |      pos = 5;
12419|       |      scheme_type = ada::scheme::type::WS;
12420|       |      protocol_end = 3;
12421|       |    } else if (len >= 6 && b[2] == 's' && b[3] == ':' && b[4] == '/' &&
12422|       |               b[5] == '/') {
12423|       |      pos = 6;
12424|       |      scheme_type = ada::scheme::type::WSS;
12425|       |      protocol_end = 4;
12426|       |    } else {
12427|       |      return false;
12428|       |    }
12429|       |  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
12430|       |             b[4] == '/' && b[5] == '/') {
12431|       |    pos = 6;
12432|       |    scheme_type = ada::scheme::type::FTP;
12433|       |    protocol_end = 4;
12434|       |  } else {
12435|       |    return false;
12436|       |  }
12437|       |#endif
12438|  2.93k|  if (pos < len && (b[pos] == '/' || b[pos] == '\\')) [[unlikely]] {
  ------------------
  |  Branch (12438:7): [True: 2.93k, False: 0]
  |  Branch (12438:21): [True: 0, False: 2.93k]
  |  Branch (12438:38): [True: 0, False: 2.93k]
  ------------------
12439|      0|    return false;
12440|      0|  }
12441|       |
12442|       |  // Digit-led hosts are IPv4/numeric; '[' is IPv6. Skip before scanning.
12443|  2.93k|  if (pos < len && ((b[pos] >= '0' && b[pos] <= '9') || b[pos] == '[')) {
  ------------------
  |  Branch (12443:7): [True: 2.93k, False: 0]
  |  Branch (12443:22): [True: 2.93k, False: 0]
  |  Branch (12443:39): [True: 0, False: 2.93k]
  |  Branch (12443:57): [True: 0, False: 2.93k]
  ------------------
12444|      0|    return false;
12445|      0|  }
12446|       |
12447|  2.93k|  const size_t host_start = pos;
12448|  2.93k|  bool has_upper = false;
12449|  2.93k|  bool has_x = false;
12450|  2.93k|  size_t host_end = pos;
12451|  2.93k|  if (!scan_plain_host(b, pos, len, host_end, has_upper, has_x)) {
  ------------------
  |  Branch (12451:7): [True: 0, False: 2.93k]
  ------------------
12452|      0|    return false;
12453|      0|  }
12454|  2.93k|  if (host_start == host_end) [[unlikely]] {
  ------------------
  |  Branch (12454:7): [True: 0, False: 2.93k]
  ------------------
12455|      0|    return false;
12456|      0|  }
12457|  2.93k|  const size_t host_len = host_end - host_start;
12458|  2.93k|  if (host_len > 253) [[unlikely]] {
  ------------------
  |  Branch (12458:7): [True: 0, False: 2.93k]
  ------------------
12459|      0|    return false;
12460|      0|  }
12461|  2.93k|  {
12462|  2.93k|    std::string_view hv(input.data() + host_start, host_len);
12463|  2.93k|    char host_buf[256];
12464|  2.93k|    if (has_upper) [[unlikely]] {
  ------------------
  |  Branch (12464:9): [True: 0, False: 2.93k]
  ------------------
12465|      0|      std::memcpy(host_buf, input.data() + host_start, host_len);
12466|      0|      unicode::to_lower_ascii(host_buf, host_len);
12467|      0|      hv = std::string_view(host_buf, host_len);
12468|      0|    }
12469|  2.93k|    if (ada::checkers::last_label_may_be_a_number(hv)) [[unlikely]] {
  ------------------
  |  Branch (12469:9): [True: 0, False: 2.93k]
  ------------------
12470|      0|      return false;
12471|      0|    }
12472|       |    // Punycode is "xn--...". The host scan already notes a lowercase 'x';
12473|       |    // uppercase 'X' is covered by has_upper after the in-place lower.
12474|  2.93k|    static constexpr std::string_view xn{"xn-", 3};
12475|  2.93k|    if ((has_x || has_upper) && hv.find(xn) != std::string_view::npos)
  ------------------
  |  Branch (12475:10): [True: 2.93k, False: 0]
  |  Branch (12475:19): [True: 0, False: 0]
  |  Branch (12475:33): [True: 0, False: 2.93k]
  ------------------
12476|      0|        [[unlikely]] {
12477|      0|      return false;
12478|      0|    }
12479|  2.93k|  }
12480|       |
12481|  2.93k|  if (host_end < len && b[host_end] == ':') [[unlikely]] {
  ------------------
  |  Branch (12481:7): [True: 2.93k, False: 0]
  |  Branch (12481:25): [True: 0, False: 2.93k]
  ------------------
12482|      0|    return finish_simple_absolute_with_port(input, out, scheme_type,
12483|      0|                                            protocol_end, host_start, host_end,
12484|      0|                                            host_len, has_upper);
12485|      0|  }
12486|       |
12487|  2.93k|  size_t i = host_end;
12488|  2.93k|  size_t path_start = host_end;
12489|  2.93k|  size_t path_end = host_end;
12490|  2.93k|  size_t query_start = std::string_view::npos;
12491|  2.93k|  size_t hash_start = std::string_view::npos;
12492|  2.93k|  bool has_path = false;
12493|  2.93k|  bool maybe_dot_segment = false;
12494|  2.93k|  bool rest_simple = true;
12495|       |
12496|  2.93k|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (12496:7): [True: 2.93k, False: 0]
  |  Branch (12496:18): [True: 2.93k, False: 0]
  ------------------
12497|  2.93k|    has_path = true;
12498|  2.93k|    path_start = i;
12499|  2.93k|    ++i;
12500|  2.93k|    scan_path_run(b, i, len, maybe_dot_segment);
12501|  2.93k|    if (i < len) {
  ------------------
  |  Branch (12501:9): [True: 2.93k, False: 0]
  ------------------
12502|  2.93k|      const uint8_t cls = k_path[b[i]];
12503|  2.93k|      if (cls == 1) {
  ------------------
  |  Branch (12503:11): [True: 2.93k, False: 0]
  ------------------
12504|  2.93k|        path_end = i;
12505|  2.93k|        if (b[i] == '?') {
  ------------------
  |  Branch (12505:13): [True: 2.93k, False: 0]
  ------------------
12506|  2.93k|          query_start = i;
12507|  2.93k|          ++i;
12508|  2.93k|          goto scan_query;
12509|  2.93k|        }
12510|      0|        hash_start = i;
12511|      0|        ++i;
12512|      0|        goto scan_hash;
12513|  2.93k|      }
12514|      0|      rest_simple = false;
12515|      0|      hash_start = input.find('#', i);
12516|      0|      query_start = input.substr(0, hash_start).find('?', i);
12517|      0|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12517:11): [True: 0, False: 0]
  ------------------
12518|      0|        path_end = query_start;
12519|      0|      } else {
12520|      0|        path_end = hash_start != std::string_view::npos ? hash_start : len;
  ------------------
  |  Branch (12520:20): [True: 0, False: 0]
  ------------------
12521|      0|      }
12522|      0|      goto after_rest;
12523|  2.93k|    }
12524|      0|    path_end = i;
12525|      0|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12525:14): [True: 0, False: 0]
  |  Branch (12525:25): [True: 0, False: 0]
  ------------------
12526|      0|    query_start = i;
12527|      0|    ++i;
12528|      0|    goto scan_query;
12529|      0|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12529:14): [True: 0, False: 0]
  |  Branch (12529:25): [True: 0, False: 0]
  ------------------
12530|      0|    hash_start = i;
12531|      0|    ++i;
12532|      0|    goto scan_hash;
12533|      0|  }
12534|      0|  goto after_rest;
12535|       |
12536|  2.93k|scan_query:
12537|  2.93k|  scan_query_run(b, i, len);
12538|  2.93k|  if (i < len) {
  ------------------
  |  Branch (12538:7): [True: 1.58k, False: 1.34k]
  ------------------
12539|  1.58k|    if (b[i] == '#') {
  ------------------
  |  Branch (12539:9): [True: 238, False: 1.34k]
  ------------------
12540|    238|      hash_start = i;
12541|    238|      ++i;
12542|    238|      goto scan_hash;
12543|    238|    }
12544|  1.34k|    rest_simple = false;
12545|  1.34k|    goto scan_query_boundary;
12546|  1.58k|  }
12547|  1.34k|  goto after_rest;
12548|       |
12549|  1.34k|scan_query_boundary:
12550|  1.34k|  hash_start = input.find('#', i);
12551|  1.34k|  goto after_rest;
12552|       |
12553|    238|scan_hash:
12554|    238|  scan_hash_run(b, i, len);
12555|    238|  if (i < len) {
  ------------------
  |  Branch (12555:7): [True: 154, False: 84]
  ------------------
12556|    154|    rest_simple = false;
12557|    154|  }
12558|       |
12559|  2.93k|after_rest:
12560|  2.93k|  if (rest_simple && maybe_dot_segment) {
  ------------------
  |  Branch (12560:7): [True: 1.43k, False: 1.50k]
  |  Branch (12560:22): [True: 0, False: 1.43k]
  ------------------
12561|      0|    const std::string_view path_body(input.data() + path_start,
12562|      0|                                     path_end - path_start);
12563|      0|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12563:9): [True: 0, False: 0]
  ------------------
12564|      0|      rest_simple = false;
12565|      0|    }
12566|      0|  }
12567|       |
12568|       |  // The slow path removes ASCII tab/newline anywhere in the input and trims a
12569|       |  // trailing C0 control or space; this fast path does neither. A query or
12570|       |  // fragment reaching the helpers below would keep those bytes percent-encoded
12571|       |  // ("?a\nb" -> "?a%0Ab", "#f " -> "#f%20") instead of stripped, so hand such
12572|       |  // inputs back to the slow path.
12573|  2.93k|  if (!rest_simple && (unicode::is_c0_control_or_space(input.back()) ||
  ------------------
  |  Branch (12573:7): [True: 1.50k, False: 1.43k]
  |  Branch (12573:24): [True: 347, False: 1.15k]
  ------------------
12574|  1.15k|                       unicode::has_tabs_or_newline(input))) {
  ------------------
  |  Branch (12574:24): [True: 144, False: 1.01k]
  ------------------
12575|    491|    return false;
12576|    491|  }
12577|       |
12578|  2.44k|  out.type = scheme_type;
12579|  2.44k|  out.is_valid = true;
12580|  2.44k|  out.has_opaque_path = false;
12581|  2.44k|  out.host_type = DEFAULT;
12582|       |
12583|  2.44k|  if (!rest_simple) {
  ------------------
  |  Branch (12583:7): [True: 1.01k, False: 1.43k]
  ------------------
12584|       |    // Host is a plain domain. Finish path/query/hash with
12585|       |    // the regular helpers
12586|       |    // so percent-encoding and dot segments do not re-parse the authority.
12587|  1.01k|    const std::string_view path_view =
12588|  1.01k|        has_path
  ------------------
  |  Branch (12588:9): [True: 1.01k, False: 0]
  ------------------
12589|  1.01k|            ? std::string_view(input.data() + path_start, path_end - path_start)
12590|  1.01k|            : std::string_view{};
12591|  1.01k|    auto apply_query_and_hash = [&]() {
12592|  1.01k|      if (query_start != std::string_view::npos) {
12593|  1.01k|        const size_t q_end =
12594|  1.01k|            (hash_start != std::string_view::npos) ? hash_start : len;
12595|  1.01k|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12596|  1.01k|                                                q_end - query_start - 1),
12597|  1.01k|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12598|  1.01k|      }
12599|  1.01k|      if (hash_start != std::string_view::npos) {
12600|  1.01k|        out.update_unencoded_base_hash(std::string_view(
12601|  1.01k|            input.data() + hash_start + 1, len - hash_start - 1));
12602|  1.01k|      }
12603|  1.01k|    };
12604|  1.01k|    if constexpr (is_aggregator) {
12605|  1.01k|      out.buffer.assign(input.substr(0, host_end));
12606|  1.01k|      if (has_upper) {
  ------------------
  |  Branch (12606:11): [True: 0, False: 1.01k]
  ------------------
12607|      0|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12608|      0|      }
12609|  1.01k|      out.components.protocol_end = protocol_end;
12610|  1.01k|      out.components.username_end = protocol_end + 2;
12611|  1.01k|      out.components.host_start = protocol_end + 2;
12612|  1.01k|      out.components.host_end = static_cast<uint32_t>(host_end);
12613|  1.01k|      out.components.port = url_components::omitted;
12614|  1.01k|      out.components.pathname_start = static_cast<uint32_t>(host_end);
12615|  1.01k|      out.components.search_start = url_components::omitted;
12616|  1.01k|      out.components.hash_start = url_components::omitted;
12617|  1.01k|      out.parse_path(path_view);
12618|  1.01k|      apply_query_and_hash();
12619|       |    } else {
12620|       |      std::string host_str(input.substr(host_start, host_len));
12621|       |      if (has_upper) {
12622|       |        unicode::to_lower_ascii(host_str.data(), host_str.size());
12623|       |      }
12624|       |      out.host = std::move(host_str);
12625|       |      out.parse_path(path_view);
12626|       |      apply_query_and_hash();
12627|       |    }
12628|  1.01k|    return true;
12629|  1.01k|  }
12630|       |
12631|  1.43k|  const bool need_slash = !has_path;
12632|  1.43k|  if constexpr (is_aggregator) {
12633|  1.43k|    if (!need_slash) {
  ------------------
  |  Branch (12633:9): [True: 1.43k, False: 0]
  ------------------
12634|       |      // assign copies once. resize()+memcpy would value-init then overwrite.
12635|  1.43k|      out.buffer.assign(input);
12636|  1.43k|      if (has_upper) {
  ------------------
  |  Branch (12636:11): [True: 0, False: 1.43k]
  ------------------
12637|      0|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12638|      0|      }
12639|  1.43k|      out.components.protocol_end = protocol_end;
12640|  1.43k|      out.components.username_end = protocol_end + 2;
12641|  1.43k|      out.components.host_start = protocol_end + 2;
12642|  1.43k|      out.components.host_end = static_cast<uint32_t>(host_end);
12643|  1.43k|      out.components.port = url_components::omitted;
12644|  1.43k|      out.components.pathname_start = static_cast<uint32_t>(path_start);
12645|  1.43k|      out.components.search_start = (query_start != std::string_view::npos)
  ------------------
  |  Branch (12645:37): [True: 1.43k, False: 0]
  ------------------
12646|  1.43k|                                        ? static_cast<uint32_t>(query_start)
12647|  1.43k|                                        : url_components::omitted;
12648|  1.43k|      out.components.hash_start = (hash_start != std::string_view::npos)
  ------------------
  |  Branch (12648:35): [True: 84, False: 1.34k]
  ------------------
12649|  1.43k|                                      ? static_cast<uint32_t>(hash_start)
12650|  1.43k|                                      : url_components::omitted;
12651|  1.43k|    } else {
12652|      0|      out.buffer.clear();
12653|      0|      out.buffer.reserve(len + 1);
12654|      0|      out.buffer.append(input.substr(0, host_end));
12655|      0|      out.buffer.push_back('/');
12656|      0|      if (host_end < len) {
  ------------------
  |  Branch (12656:11): [True: 0, False: 0]
  ------------------
12657|      0|        out.buffer.append(input.substr(host_end));
12658|      0|      }
12659|      0|      if (has_upper) {
  ------------------
  |  Branch (12659:11): [True: 0, False: 0]
  ------------------
12660|      0|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12661|      0|      }
12662|      0|      out.components.protocol_end = protocol_end;
12663|      0|      out.components.username_end = protocol_end + 2;
12664|      0|      out.components.host_start = protocol_end + 2;
12665|      0|      out.components.host_end = static_cast<uint32_t>(host_end);
12666|      0|      out.components.port = url_components::omitted;
12667|      0|      out.components.pathname_start = static_cast<uint32_t>(host_end);
12668|      0|      out.components.search_start = (query_start != std::string_view::npos)
  ------------------
  |  Branch (12668:37): [True: 0, False: 0]
  ------------------
12669|      0|                                        ? static_cast<uint32_t>(query_start + 1)
12670|      0|                                        : url_components::omitted;
12671|      0|      out.components.hash_start = (hash_start != std::string_view::npos)
  ------------------
  |  Branch (12671:35): [True: 0, False: 0]
  ------------------
12672|      0|                                      ? static_cast<uint32_t>(hash_start + 1)
12673|      0|                                      : url_components::omitted;
12674|      0|    }
12675|       |  } else {
12676|       |    std::string host_str(input.substr(host_start, host_len));
12677|       |    if (has_upper) {
12678|       |      unicode::to_lower_ascii(host_str.data(), host_str.size());
12679|       |    }
12680|       |    out.host = std::move(host_str);
12681|       |    if (need_slash) {
12682|       |      out.path = "/";
12683|       |    } else {
12684|       |      out.path.assign(input.data() + path_start, path_end - path_start);
12685|       |    }
12686|       |    if (query_start != std::string_view::npos) {
12687|       |      const size_t q_end =
12688|       |          (hash_start != std::string_view::npos) ? hash_start : len;
12689|       |      out.query.emplace(input.data() + query_start + 1,
12690|       |                        q_end - query_start - 1);
12691|       |    }
12692|       |    if (hash_start != std::string_view::npos) {
12693|       |      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
12694|       |    }
12695|       |  }
12696|  1.43k|  return true;
12697|  2.44k|}
_ZN3ada6parser14parse_url_implINS_14url_aggregatorELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_:
12886|  2.93k|                           const result_type* base_url) {
12887|       |  // We can specialize the implementation per type.
12888|       |  // Important: result_type_is_ada_url is evaluated at *compile time*. This
12889|       |  // means that doing if constexpr(result_type_is_ada_url) { something } else {
12890|       |  // something else } is free (at runtime). This means that ada::url_aggregator
12891|       |  // and ada::url **do not have to support the exact same API**.
12892|  2.93k|  constexpr bool result_type_is_ada_url = std::is_same_v<url, result_type>;
12893|  2.93k|  constexpr bool result_type_is_ada_url_aggregator =
12894|  2.93k|      std::is_same_v<url_aggregator, result_type>;
12895|  2.93k|  static_assert(result_type_is_ada_url ||
12896|  2.93k|                result_type_is_ada_url_aggregator);  // We don't support
12897|       |                                                     // anything else for now.
12898|       |
12899|  2.93k|  ada_log("ada::parser::parse_url('", user_input, "' [", user_input.size(),
12900|  2.93k|          " bytes],", (base_url != nullptr ? base_url->to_string() : "null"),
12901|  2.93k|          ")");
12902|       |
12903|  2.93k|  result_type url{};
12904|       |
12905|  2.93k|  const uint32_t max_input_length = ada::get_max_input_length();
12906|       |
12907|       |  // Normalization (percent-encoding, IDNA) can push the serialized URL past
12908|       |  // max_input_length even when the input fit under it. The check at the end of
12909|       |  // the state machine covers URLs that run to completion, but several states
12910|       |  // return early after appending a query or fragment, so run the same check on
12911|       |  // those exits too. Without this, a query- or fragment-terminated URL such as
12912|       |  // file://x/?<...> or https://user@x/?<...> is accepted while the equivalent
12913|       |  // https://x/?<...> that takes the absolute fast path is rejected.
12914|  2.93k|  const auto enforce_max_input_length = [&]() {
12915|  2.93k|    if constexpr (store_values) {
12916|  2.93k|      if (url.is_valid) {
12917|  2.93k|        if constexpr (result_type_is_ada_url_aggregator) {
12918|  2.93k|          if (url.buffer.size() > max_input_length) [[unlikely]] {
12919|  2.93k|            url.is_valid = false;
12920|  2.93k|          }
12921|  2.93k|        } else {
12922|  2.93k|          if (url.get_href_size() > max_input_length) [[unlikely]] {
12923|  2.93k|            url.is_valid = false;
12924|  2.93k|          }
12925|  2.93k|        }
12926|  2.93k|      }
12927|  2.93k|    }
12928|  2.93k|  };
12929|       |
12930|       |  // We refuse to parse URL strings that exceed the maximum input length.
12931|       |  // By default, this is 4GB but can be configured via
12932|       |  // ada::set_max_input_length().
12933|  2.93k|  if (user_input.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12933:7): [True: 0, False: 2.93k]
  ------------------
12934|      0|    url.is_valid = false;
12935|      0|  }
12936|       |  // Going forward, user_input.size() is in [0,
12937|       |  // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
12938|       |  // base, or the optional_url was invalid, we must return.
12939|  2.93k|  if (base_url != nullptr) {
  ------------------
  |  Branch (12939:7): [True: 0, False: 2.93k]
  ------------------
12940|      0|    url.is_valid &= base_url->is_valid;
12941|      0|  }
12942|  2.93k|  if (!url.is_valid) {
  ------------------
  |  Branch (12942:7): [True: 0, False: 2.93k]
  ------------------
12943|      0|    return url;
12944|      0|  }
12945|       |
12946|       |  // Simple absolute / relative fast paths (before tabs/newline scan).
12947|  2.93k|  if constexpr (store_values) {
12948|  2.93k|    bool hit_fast_path = false;
12949|  2.93k|    if (base_url == nullptr) {
  ------------------
  |  Branch (12949:9): [True: 2.93k, False: 0]
  ------------------
12950|       |      // IPv4/IPv6 and userinfo miss the fast path. Skip the never_inline
12951|       |      // call so those URLs (including SetHref) do not pay for a miss.
12952|  2.93k|      const auto* p = reinterpret_cast<const uint8_t*>(user_input.data());
12953|  2.93k|      const size_t n = user_input.size();
12954|  2.93k|      size_t host_start = 0;
12955|  2.93k|      if (n >= 8 && p[4] == ':' && p[5] == '/' && p[6] == '/') {
  ------------------
  |  Branch (12955:11): [True: 2.93k, False: 0]
  |  Branch (12955:21): [True: 0, False: 2.93k]
  |  Branch (12955:36): [True: 0, False: 0]
  |  Branch (12955:51): [True: 0, False: 0]
  ------------------
12956|      0|        host_start = 7;
12957|  2.93k|      } else if (n >= 9 && p[5] == ':' && p[6] == '/' && p[7] == '/') {
  ------------------
  |  Branch (12957:18): [True: 2.93k, False: 0]
  |  Branch (12957:28): [True: 2.93k, False: 0]
  |  Branch (12957:43): [True: 2.93k, False: 0]
  |  Branch (12957:58): [True: 2.93k, False: 0]
  ------------------
12958|  2.93k|        host_start = 8;
12959|  2.93k|      }
12960|  2.93k|      const uint8_t host_first = host_start != 0 ? p[host_start] : 0;
  ------------------
  |  Branch (12960:34): [True: 2.93k, False: 0]
  ------------------
12961|  2.93k|      const bool skip_ip =
12962|  2.93k|          host_first == '[' || (host_first >= '0' && host_first <= '9');
  ------------------
  |  Branch (12962:11): [True: 0, False: 2.93k]
  |  Branch (12962:33): [True: 2.93k, False: 0]
  |  Branch (12962:54): [True: 0, False: 2.93k]
  ------------------
12963|       |      // Only scan for userinfo when the host is not an IP literal, so
12964|       |      // IPv4/IPv6 inputs skip the SIMD '@' check entirely.
12965|  2.93k|      hit_fast_path =
12966|  2.93k|          !skip_ip &&
  ------------------
  |  Branch (12966:11): [True: 2.93k, False: 0]
  ------------------
12967|  2.93k|          !(host_start != 0 && authority_has_at(p, host_start, n)) &&
  ------------------
  |  Branch (12967:13): [True: 2.93k, False: 0]
  |  Branch (12967:32): [True: 0, False: 2.93k]
  ------------------
12968|  2.93k|          try_parse_simple_absolute(user_input, url);
  ------------------
  |  Branch (12968:11): [True: 2.44k, False: 491]
  ------------------
12969|  2.93k|    } else {
12970|      0|      hit_fast_path = try_parse_simple_relative(user_input, *base_url, url);
12971|      0|    }
12972|  2.93k|    if (hit_fast_path) {
  ------------------
  |  Branch (12972:9): [True: 2.44k, False: 491]
  ------------------
12973|  2.44k|      if constexpr (result_type_is_ada_url_aggregator) {
12974|  2.44k|        if (url.buffer.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12974:13): [True: 0, False: 2.44k]
  ------------------
12975|      0|          url.is_valid = false;
12976|      0|        }
12977|       |      } else {
12978|       |        // For a small absolute input, even worst-case normalization cannot
12979|       |        // exceed the limit: percent encoding expands at most 3x and IDNA at
12980|       |        // most 4.5x. Avoid traversing every stored component on the common
12981|       |        // default-limit path.
12982|       |        if ((base_url != nullptr ||
12983|       |             user_input.size() > static_cast<size_t>(max_input_length) / 5) &&
12984|       |            url.get_href_size() > max_input_length) [[unlikely]] {
12985|       |          url.is_valid = false;
12986|       |        }
12987|       |      }
12988|  2.44k|      return url;
12989|  2.44k|    }
12990|  2.93k|  }
12991|       |
12992|    491|  state state = state::SCHEME_START;
12993|       |
12994|  2.93k|  std::string tmp_buffer;
12995|  2.93k|  std::string_view url_data;
12996|  2.93k|  if (unicode::has_tabs_or_newline(user_input)) [[unlikely]] {
  ------------------
  |  Branch (12996:7): [True: 241, False: 2.69k]
  ------------------
12997|    241|    tmp_buffer = user_input;
12998|       |    // Optimization opportunity: Instead of copying and then pruning, we could
12999|       |    // just directly build the string from user_input.
13000|    241|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
13001|    241|    url_data = tmp_buffer;
13002|  2.69k|  } else [[likely]] {
13003|  2.69k|    url_data = user_input;
13004|  2.69k|  }
13005|       |
13006|       |  // Leading and trailing control characters are uncommon and easy to deal with
13007|       |  // (no performance concern).
13008|  2.93k|  helpers::trim_c0_whitespace(url_data);
13009|       |
13010|  2.93k|  if constexpr (result_type_is_ada_url_aggregator && store_values) {
13011|       |    // Most of the time, we just need user_input.size().
13012|       |    // In some instances, we may need a bit more.
13013|       |    ///////////////////////////
13014|       |    // This is *very* important. This line should *not* be removed
13015|       |    // hastily. There are principled reasons why reserve is important
13016|       |    // for performance. If you have a benchmark with small inputs,
13017|       |    // it may not matter, but in other instances, it could.
13018|       |    ////
13019|       |    // This rounds up to the next power of two.
13020|       |    // We know that user_input.size() is in [0,
13021|       |    // std::numeric_limits<uint32_t>::max).
13022|  2.93k|    uint32_t reserve_capacity =
13023|  2.93k|        (0xFFFFFFFF >>
13024|  2.93k|         helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
13025|  2.93k|        1;
13026|  2.93k|    url.reserve(reserve_capacity);
13027|  2.93k|  }
13028|       |
13029|       |  // Optimization opportunity. Most websites do not have fragment.
13030|  2.93k|  std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
13031|       |  // We add it last so that an implementation like ada::url_aggregator
13032|       |  // can append it last to its internal buffer, thus improving performance.
13033|       |
13034|       |  // Here url_data no longer has its fragment.
13035|       |  // We are going to access the data from url_data (it is immutable).
13036|       |  // At any given time, we are pointing at byte 'input_position' in url_data.
13037|       |  // The input_position variable should range from 0 to input_size.
13038|       |  // It is illegal to access url_data at input_size.
13039|  2.93k|  size_t input_position = 0;
13040|  2.93k|  const size_t input_size = url_data.size();
13041|       |  // Keep running the following state machine by switching on state.
13042|       |  // If after a run pointer points to the EOF code point, go to the next step.
13043|       |  // Otherwise, increase pointer by 1 and continue with the state machine.
13044|       |  // We never decrement input_position.
13045|  6.36k|  while (input_position <= input_size) {
  ------------------
  |  Branch (13045:10): [True: 3.92k, False: 2.44k]
  ------------------
13046|  3.92k|    ada_log("In parsing at ", input_position, " out of ", input_size,
13047|  3.92k|            " in state ", ada::to_string(state));
13048|  3.92k|    switch (state) {
13049|    491|      case state::SCHEME_START: {
  ------------------
  |  Branch (13049:7): [True: 491, False: 3.43k]
  ------------------
13050|    491|        ada_log("SCHEME_START ", helpers::substring(url_data, input_position));
13051|       |        // If c is an ASCII alpha, append c, lowercased, to buffer, and set
13052|       |        // state to scheme state.
13053|    491|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13053:13): [True: 491, False: 0]
  ------------------
13054|    491|            checkers::is_alpha(url_data[input_position])) {
  ------------------
  |  Branch (13054:13): [True: 491, False: 0]
  ------------------
13055|    491|          state = state::SCHEME;
13056|    491|          input_position++;
13057|    491|        } else {
13058|       |          // Otherwise, if state override is not given, set state to no scheme
13059|       |          // state and decrease pointer by 1.
13060|      0|          state = state::NO_SCHEME;
13061|      0|        }
13062|    491|        break;
13063|      0|      }
13064|    491|      case state::SCHEME: {
  ------------------
  |  Branch (13064:7): [True: 491, False: 3.43k]
  ------------------
13065|    491|        ada_log("SCHEME ", helpers::substring(url_data, input_position));
13066|       |        // If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.),
13067|       |        // append c, lowercased, to buffer.
13068|  2.45k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13068:16): [True: 2.45k, False: 0]
  ------------------
13069|  2.45k|               (unicode::is_alnum_plus(url_data[input_position]))) {
  ------------------
  |  Branch (13069:16): [True: 1.96k, False: 491]
  ------------------
13070|  1.96k|          input_position++;
13071|  1.96k|        }
13072|       |        // Otherwise, if c is U+003A (:), then:
13073|    491|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13073:13): [True: 491, False: 0]
  ------------------
13074|    491|            (url_data[input_position] == ':')) {
  ------------------
  |  Branch (13074:13): [True: 491, False: 0]
  ------------------
13075|    491|          ada_log("SCHEME the scheme should be ",
13076|    491|                  url_data.substr(0, input_position));
13077|       |          if constexpr (result_type_is_ada_url) {
13078|       |            if (!url.parse_scheme(url_data.substr(0, input_position))) {
13079|       |              return url;
13080|       |            }
13081|    491|          } else {
13082|       |            // we pass the colon along instead of painfully adding it back.
13083|    491|            if (!url.parse_scheme_with_colon(
  ------------------
  |  Branch (13083:17): [True: 0, False: 491]
  ------------------
13084|    491|                    url_data.substr(0, input_position + 1))) {
13085|      0|              return url;
13086|      0|            }
13087|    491|          }
13088|    491|          ada_log("SCHEME the scheme is ", url.get_protocol());
13089|       |
13090|       |          // If url's scheme is "file", then:
13091|       |          // NOLINTNEXTLINE(bugprone-branch-clone)
13092|    491|          if (url.type == scheme::type::FILE) {
  ------------------
  |  Branch (13092:15): [True: 0, False: 491]
  ------------------
13093|       |            // Set state to file state.
13094|      0|            state = state::FILE;
13095|      0|          }
13096|       |          // Otherwise, if url is special, base is non-null, and base's scheme
13097|       |          // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
13098|       |          // != nullptr is false.
13099|    491|          else if (url.is_special() && base_url != nullptr &&
  ------------------
  |  Branch (13099:20): [True: 491, False: 0]
  |  Branch (13099:40): [True: 0, False: 491]
  ------------------
13100|      0|                   base_url->type == url.type) {
  ------------------
  |  Branch (13100:20): [True: 0, False: 0]
  ------------------
13101|       |            // Set state to special relative or authority state.
13102|      0|            state = state::SPECIAL_RELATIVE_OR_AUTHORITY;
13103|      0|          }
13104|       |          // Otherwise, if url is special, set state to special authority
13105|       |          // slashes state.
13106|    491|          else if (url.is_special()) {
  ------------------
  |  Branch (13106:20): [True: 491, False: 0]
  ------------------
13107|    491|            state = state::SPECIAL_AUTHORITY_SLASHES;
13108|    491|          }
13109|       |          // Otherwise, if remaining starts with an U+002F (/), set state to
13110|       |          // path or authority state and increase pointer by 1.
13111|      0|          else if (input_position + 1 < input_size &&
  ------------------
  |  Branch (13111:20): [True: 0, False: 0]
  ------------------
13112|      0|                   url_data[input_position + 1] == '/') {
  ------------------
  |  Branch (13112:20): [True: 0, False: 0]
  ------------------
13113|      0|            state = state::PATH_OR_AUTHORITY;
13114|      0|            input_position++;
13115|      0|          }
13116|       |          // Otherwise, set url's path to the empty string and set state to
13117|       |          // opaque path state.
13118|      0|          else {
13119|      0|            state = state::OPAQUE_PATH;
13120|      0|          }
13121|    491|        }
13122|       |        // Otherwise, if state override is not given, set buffer to the empty
13123|       |        // string, state to no scheme state, and start over (from the first code
13124|       |        // point in input).
13125|      0|        else {
13126|      0|          state = state::NO_SCHEME;
13127|      0|          input_position = 0;
13128|      0|          break;
13129|      0|        }
13130|    491|        input_position++;
13131|    491|        break;
13132|    491|      }
13133|      0|      case state::NO_SCHEME: {
  ------------------
  |  Branch (13133:7): [True: 0, False: 3.92k]
  ------------------
13134|      0|        ada_log("NO_SCHEME ", helpers::substring(url_data, input_position));
13135|       |        // The fragment was pruned from url_data before the state machine ran,
13136|       |        // so 'c is U+0023 (#)' holds exactly when a fragment was found and
13137|       |        // nothing else remains in front of it.
13138|      0|        const bool c_is_hash =
13139|      0|            fragment.has_value() && input_position == input_size;
  ------------------
  |  Branch (13139:13): [True: 0, False: 0]
  |  Branch (13139:37): [True: 0, False: 0]
  ------------------
13140|       |        // If base is null, or base has an opaque path and c is not U+0023 (#),
13141|       |        // validation error, return failure.
13142|      0|        if (base_url == nullptr || (base_url->has_opaque_path && !c_is_hash)) {
  ------------------
  |  Branch (13142:13): [True: 0, False: 0]
  |  Branch (13142:37): [True: 0, False: 0]
  |  Branch (13142:66): [True: 0, False: 0]
  ------------------
13143|      0|          ada_log("NO_SCHEME validation error");
13144|      0|          url.is_valid = false;
13145|      0|          return url;
13146|      0|        }
13147|       |        // Otherwise, if base has an opaque path and c is U+0023 (#),
13148|       |        // set url's scheme to base's scheme, url's path to base's path, url's
13149|       |        // query to base's query, and set state to fragment state.
13150|      0|        else if (base_url->has_opaque_path && c_is_hash) {
  ------------------
  |  Branch (13150:18): [True: 0, False: 0]
  |  Branch (13150:47): [True: 0, False: 0]
  ------------------
13151|      0|          ada_log("NO_SCHEME opaque base with fragment");
13152|      0|          url.copy_scheme(*base_url);
13153|      0|          url.has_opaque_path = base_url->has_opaque_path;
13154|       |
13155|       |          if constexpr (result_type_is_ada_url) {
13156|       |            url.path = base_url->path;
13157|       |            url.query = base_url->query;
13158|      0|          } else {
13159|      0|            url.update_base_pathname(base_url->get_pathname());
13160|      0|            if (base_url->has_search()) {
  ------------------
  |  Branch (13160:17): [True: 0, False: 0]
  ------------------
13161|       |              // get_search() returns "" for an empty query string (URL ends
13162|       |              // with '?'). update_base_search("") would incorrectly clear the
13163|       |              // query, so pass "?" to preserve the empty query distinction.
13164|      0|              auto s = base_url->get_search();
13165|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13165:38): [True: 0, False: 0]
  ------------------
13166|      0|            }
13167|      0|          }
13168|      0|          url.update_unencoded_base_hash(*fragment);
13169|      0|          enforce_max_input_length();
13170|      0|          return url;
13171|      0|        }
13172|       |        // Otherwise, if base's scheme is not "file", set state to relative
13173|       |        // state and decrease pointer by 1.
13174|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13175|      0|        else if (base_url->type != scheme::type::FILE) {
  ------------------
  |  Branch (13175:18): [True: 0, False: 0]
  ------------------
13176|      0|          ada_log("NO_SCHEME non-file relative path");
13177|      0|          state = state::RELATIVE_SCHEME;
13178|      0|        }
13179|       |        // Otherwise, set state to file state and decrease pointer by 1.
13180|      0|        else {
13181|      0|          ada_log("NO_SCHEME file base type");
13182|      0|          state = state::FILE;
13183|      0|        }
13184|      0|        break;
13185|      0|      }
13186|    491|      case state::AUTHORITY: {
  ------------------
  |  Branch (13186:7): [True: 491, False: 3.43k]
  ------------------
13187|    491|        ada_log("AUTHORITY ", helpers::substring(url_data, input_position));
13188|       |        // most URLs have no @. Having no @ tells us that we don't have to worry
13189|       |        // about AUTHORITY. Of course, we could have @ and still not have to
13190|       |        // worry about AUTHORITY.
13191|       |        // TODO: Instead of just collecting a bool, collect the location of the
13192|       |        // '@' and do something useful with it.
13193|       |        // TODO: We could do various processing early on, using a single pass
13194|       |        // over the string to collect information about it, e.g., telling us
13195|       |        // whether there is a @ and if so, where (or how many).
13196|       |
13197|       |        // Check if url data contains an @.
13198|    491|        if (url_data.find('@', input_position) == std::string_view::npos) {
  ------------------
  |  Branch (13198:13): [True: 430, False: 61]
  ------------------
13199|    430|          state = state::HOST;
13200|    430|          break;
13201|    430|        }
13202|     61|        bool at_sign_seen{false};
13203|     61|        bool password_token_seen{false};
13204|       |        /**
13205|       |         * We expect something of the sort...
13206|       |         * https://user:pass@example.com:1234/foo/bar?baz#quux
13207|       |         * --------^
13208|       |         */
13209|     61|        do {
13210|     61|          std::string_view view = url_data.substr(input_position);
13211|       |          // The delimiters are @, /, ? \\.
13212|     61|          size_t location =
13213|     61|              url.is_special() ? helpers::find_authority_delimiter_special(view)
  ------------------
  |  Branch (13213:15): [True: 61, False: 0]
  ------------------
13214|     61|                               : helpers::find_authority_delimiter(view);
13215|     61|          std::string_view authority_view = view.substr(0, location);
13216|     61|          size_t end_of_authority = input_position + authority_view.size();
13217|       |          // If c is U+0040 (@), then:
13218|     61|          if ((end_of_authority != input_size) &&
  ------------------
  |  Branch (13218:15): [True: 61, False: 0]
  ------------------
13219|     61|              (url_data[end_of_authority] == '@')) {
  ------------------
  |  Branch (13219:15): [True: 0, False: 61]
  ------------------
13220|       |            // If atSignSeen is true, then prepend "%40" to buffer.
13221|      0|            if (at_sign_seen) {
  ------------------
  |  Branch (13221:17): [True: 0, False: 0]
  ------------------
13222|      0|              if (password_token_seen) {
  ------------------
  |  Branch (13222:19): [True: 0, False: 0]
  ------------------
13223|       |                if constexpr (result_type_is_ada_url) {
13224|       |                  url.password += "%40";
13225|      0|                } else {
13226|      0|                  url.append_base_password("%40");
13227|      0|                }
13228|      0|              } else {
13229|       |                if constexpr (result_type_is_ada_url) {
13230|       |                  url.username += "%40";
13231|      0|                } else {
13232|      0|                  url.append_base_username("%40");
13233|      0|                }
13234|      0|              }
13235|      0|            }
13236|       |
13237|      0|            at_sign_seen = true;
13238|       |
13239|      0|            if (!password_token_seen) {
  ------------------
  |  Branch (13239:17): [True: 0, False: 0]
  ------------------
13240|      0|              size_t password_token_location = authority_view.find(':');
13241|      0|              password_token_seen =
13242|      0|                  password_token_location != std::string_view::npos;
13243|       |
13244|      0|              if constexpr (store_values) {
13245|      0|                if (!password_token_seen) {
  ------------------
  |  Branch (13245:21): [True: 0, False: 0]
  ------------------
13246|       |                  if constexpr (result_type_is_ada_url) {
13247|       |                    url.username += unicode::percent_encode(
13248|       |                        authority_view,
13249|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13250|      0|                  } else {
13251|      0|                    url.append_base_username(unicode::percent_encode(
13252|      0|                        authority_view,
13253|      0|                        character_sets::USERINFO_PERCENT_ENCODE));
13254|      0|                  }
13255|      0|                } else {
13256|       |                  if constexpr (result_type_is_ada_url) {
13257|       |                    url.username += unicode::percent_encode(
13258|       |                        authority_view.substr(0, password_token_location),
13259|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13260|       |                    url.password += unicode::percent_encode(
13261|       |                        authority_view.substr(password_token_location + 1),
13262|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13263|      0|                  } else {
13264|      0|                    url.append_base_username(unicode::percent_encode(
13265|      0|                        authority_view.substr(0, password_token_location),
13266|      0|                        character_sets::USERINFO_PERCENT_ENCODE));
13267|      0|                    url.append_base_password(unicode::percent_encode(
13268|      0|                        authority_view.substr(password_token_location + 1),
13269|      0|                        character_sets::USERINFO_PERCENT_ENCODE));
13270|      0|                  }
13271|      0|                }
13272|      0|              }
13273|      0|            } else if constexpr (store_values) {
13274|       |              if constexpr (result_type_is_ada_url) {
13275|       |                url.password += unicode::percent_encode(
13276|       |                    authority_view, character_sets::USERINFO_PERCENT_ENCODE);
13277|      0|              } else {
13278|      0|                url.append_base_password(unicode::percent_encode(
13279|      0|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE));
13280|      0|              }
13281|      0|            }
13282|      0|          }
13283|       |          // Otherwise, if one of the following is true:
13284|       |          // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13285|       |          // - url is special and c is U+005C (\)
13286|     61|          else if (end_of_authority == input_size ||
  ------------------
  |  Branch (13286:20): [True: 0, False: 61]
  ------------------
13287|     61|                   url_data[end_of_authority] == '/' ||
  ------------------
  |  Branch (13287:20): [True: 61, False: 0]
  ------------------
13288|      0|                   url_data[end_of_authority] == '?' ||
  ------------------
  |  Branch (13288:20): [True: 0, False: 0]
  ------------------
13289|     61|                   (url.is_special() && url_data[end_of_authority] == '\\')) {
  ------------------
  |  Branch (13289:21): [True: 0, False: 0]
  |  Branch (13289:41): [True: 0, False: 0]
  ------------------
13290|       |            // If atSignSeen is true and authority_view is the empty string,
13291|       |            // validation error, return failure.
13292|     61|            if (at_sign_seen && authority_view.empty()) {
  ------------------
  |  Branch (13292:17): [True: 0, False: 61]
  |  Branch (13292:33): [True: 0, False: 0]
  ------------------
13293|      0|              url.is_valid = false;
13294|      0|              return url;
13295|      0|            }
13296|     61|            state = state::HOST;
13297|     61|            break;
13298|     61|          }
13299|      0|          if (end_of_authority == input_size) {
  ------------------
  |  Branch (13299:15): [True: 0, False: 0]
  ------------------
13300|      0|            if constexpr (store_values) {
13301|      0|              if (fragment.has_value()) {
  ------------------
  |  Branch (13301:19): [True: 0, False: 0]
  ------------------
13302|      0|                url.update_unencoded_base_hash(*fragment);
13303|      0|              }
13304|      0|            }
13305|      0|            enforce_max_input_length();
13306|      0|            return url;
13307|      0|          }
13308|      0|          input_position = end_of_authority + 1;
13309|      0|        } while (true);
  ------------------
  |  Branch (13309:18): [True: 0, Folded]
  ------------------
13310|       |
13311|     61|        break;
13312|     61|      }
13313|     61|      case state::SPECIAL_RELATIVE_OR_AUTHORITY: {
  ------------------
  |  Branch (13313:7): [True: 0, False: 3.92k]
  ------------------
13314|      0|        ada_log("SPECIAL_RELATIVE_OR_AUTHORITY ",
13315|      0|                helpers::substring(url_data, input_position));
13316|       |
13317|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13318|       |        // then set state to special authority ignore slashes state and increase
13319|       |        // pointer by 1.
13320|      0|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13320:13): [True: 0, False: 0]
  ------------------
13321|      0|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13322|      0|          input_position += 2;
13323|      0|        } else {
13324|       |          // Otherwise, validation error, set state to relative state and
13325|       |          // decrease pointer by 1.
13326|      0|          state = state::RELATIVE_SCHEME;
13327|      0|        }
13328|       |
13329|      0|        break;
13330|     61|      }
13331|      0|      case state::PATH_OR_AUTHORITY: {
  ------------------
  |  Branch (13331:7): [True: 0, False: 3.92k]
  ------------------
13332|      0|        ada_log("PATH_OR_AUTHORITY ",
13333|      0|                helpers::substring(url_data, input_position));
13334|       |
13335|       |        // If c is U+002F (/), then set state to authority state.
13336|      0|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13336:13): [True: 0, False: 0]
  ------------------
13337|      0|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13337:13): [True: 0, False: 0]
  ------------------
13338|      0|          state = state::AUTHORITY;
13339|      0|          input_position++;
13340|      0|        } else {
13341|       |          // Otherwise, set state to path state, and decrease pointer by 1.
13342|      0|          state = state::PATH;
13343|      0|        }
13344|       |
13345|      0|        break;
13346|     61|      }
13347|      0|      case state::RELATIVE_SCHEME: {
  ------------------
  |  Branch (13347:7): [True: 0, False: 3.92k]
  ------------------
13348|      0|        ada_log("RELATIVE_SCHEME ",
13349|      0|                helpers::substring(url_data, input_position));
13350|       |
13351|       |        // Set url's scheme to base's scheme.
13352|      0|        url.copy_scheme(*base_url);
13353|       |
13354|       |        // If c is U+002F (/), then set state to relative slash state.
13355|      0|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13355:13): [True: 0, False: 0]
  ------------------
13356|       |            // NOLINTNEXTLINE(bugprone-branch-clone)
13357|      0|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13357:13): [True: 0, False: 0]
  ------------------
13358|      0|          ada_log(
13359|      0|              "RELATIVE_SCHEME if c is U+002F (/), then set state to relative "
13360|      0|              "slash state");
13361|      0|          state = state::RELATIVE_SLASH;
13362|      0|        } else if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13362:20): [True: 0, False: 0]
  |  Branch (13362:40): [True: 0, False: 0]
  ------------------
13363|      0|                   (url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13363:20): [True: 0, False: 0]
  ------------------
13364|       |          // Otherwise, if url is special and c is U+005C (\), validation error,
13365|       |          // set state to relative slash state.
13366|      0|          ada_log(
13367|      0|              "RELATIVE_SCHEME  if url is special and c is U+005C, validation "
13368|      0|              "error, set state to relative slash state");
13369|      0|          state = state::RELATIVE_SLASH;
13370|      0|        } else {
13371|      0|          ada_log("RELATIVE_SCHEME otherwise");
13372|       |          // Set url's username to base's username, url's password to base's
13373|       |          // password, url's host to base's host, url's port to base's port,
13374|       |          // url's path to a clone of base's path, and url's query to base's
13375|       |          // query.
13376|       |          if constexpr (result_type_is_ada_url) {
13377|       |            url.username = base_url->username;
13378|       |            url.password = base_url->password;
13379|       |            url.host = base_url->host;
13380|       |            url.port = base_url->port;
13381|       |            // cloning the base path includes cloning the has_opaque_path flag
13382|       |            url.has_opaque_path = base_url->has_opaque_path;
13383|       |            url.path = base_url->path;
13384|       |            url.query = base_url->query;
13385|      0|          } else {
13386|      0|            url.update_base_authority(base_url->get_href(),
13387|      0|                                      base_url->get_components());
13388|      0|            url.update_host_to_base_host(base_url->get_hostname());
13389|      0|            url.update_base_port(base_url->retrieve_base_port());
13390|       |            // cloning the base path includes cloning the has_opaque_path flag
13391|      0|            url.has_opaque_path = base_url->has_opaque_path;
13392|      0|            url.update_base_pathname(base_url->get_pathname());
13393|      0|            if (base_url->has_search()) {
  ------------------
  |  Branch (13393:17): [True: 0, False: 0]
  ------------------
13394|       |              // get_search() returns "" for an empty query string (URL ends
13395|       |              // with '?'). update_base_search("") would incorrectly clear the
13396|       |              // query, so pass "?" to preserve the empty query distinction.
13397|      0|              auto s = base_url->get_search();
13398|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13398:38): [True: 0, False: 0]
  ------------------
13399|      0|            }
13400|      0|          }
13401|       |
13402|      0|          url.has_opaque_path = base_url->has_opaque_path;
13403|       |
13404|       |          // If c is U+003F (?), then set url's query to the empty string, and
13405|       |          // state to query state.
13406|      0|          if ((input_position != input_size) &&
  ------------------
  |  Branch (13406:15): [True: 0, False: 0]
  ------------------
13407|      0|              (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13407:15): [True: 0, False: 0]
  ------------------
13408|      0|            state = state::QUERY;
13409|      0|          }
13410|       |          // Otherwise, if c is not the EOF code point:
13411|      0|          else if (input_position != input_size) {
  ------------------
  |  Branch (13411:20): [True: 0, False: 0]
  ------------------
13412|       |            // Set url's query to null.
13413|      0|            url.clear_search();
13414|       |            if constexpr (result_type_is_ada_url) {
13415|       |              // Shorten url's path.
13416|       |              helpers::shorten_path(url.path, url.type);
13417|      0|            } else {
13418|      0|              std::string_view path = url.get_pathname();
13419|      0|              if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13419:19): [True: 0, False: 0]
  ------------------
13420|      0|                url.update_base_pathname(std::move(std::string(path)));
13421|      0|              }
13422|      0|            }
13423|       |            // Set state to path state and decrease pointer by 1.
13424|      0|            state = state::PATH;
13425|      0|            break;
13426|      0|          }
13427|      0|        }
13428|      0|        input_position++;
13429|      0|        break;
13430|      0|      }
13431|      0|      case state::RELATIVE_SLASH: {
  ------------------
  |  Branch (13431:7): [True: 0, False: 3.92k]
  ------------------
13432|      0|        ada_log("RELATIVE_SLASH ",
13433|      0|                helpers::substring(url_data, input_position));
13434|       |
13435|       |        // If url is special and c is U+002F (/) or U+005C (\), then:
13436|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13437|      0|        if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13437:13): [True: 0, False: 0]
  |  Branch (13437:33): [True: 0, False: 0]
  ------------------
13438|      0|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13438:14): [True: 0, False: 0]
  ------------------
13439|      0|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13439:14): [True: 0, False: 0]
  ------------------
13440|       |          // Set state to special authority ignore slashes state.
13441|      0|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13442|      0|        }
13443|       |        // Otherwise, if c is U+002F (/), then set state to authority state.
13444|      0|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13444:18): [True: 0, False: 0]
  ------------------
13445|      0|                 (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13445:18): [True: 0, False: 0]
  ------------------
13446|      0|          state = state::AUTHORITY;
13447|      0|        }
13448|       |        // Otherwise, set
13449|       |        // - url's username to base's username,
13450|       |        // - url's password to base's password,
13451|       |        // - url's host to base's host,
13452|       |        // - url's port to base's port,
13453|       |        // - state to path state, and then, decrease pointer by 1.
13454|      0|        else {
13455|       |          if constexpr (result_type_is_ada_url) {
13456|       |            url.username = base_url->username;
13457|       |            url.password = base_url->password;
13458|       |            url.host = base_url->host;
13459|       |            url.port = base_url->port;
13460|      0|          } else {
13461|      0|            url.update_base_authority(base_url->get_href(),
13462|      0|                                      base_url->get_components());
13463|      0|            url.update_host_to_base_host(base_url->get_hostname());
13464|      0|            url.update_base_port(base_url->retrieve_base_port());
13465|      0|          }
13466|      0|          state = state::PATH;
13467|      0|          break;
13468|      0|        }
13469|       |
13470|      0|        input_position++;
13471|      0|        break;
13472|      0|      }
13473|    491|      case state::SPECIAL_AUTHORITY_SLASHES: {
  ------------------
  |  Branch (13473:7): [True: 491, False: 3.43k]
  ------------------
13474|    491|        ada_log("SPECIAL_AUTHORITY_SLASHES ",
13475|    491|                helpers::substring(url_data, input_position));
13476|       |
13477|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13478|       |        // then set state to special authority ignore slashes state and increase
13479|       |        // pointer by 1.
13480|    491|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13480:13): [True: 491, False: 0]
  ------------------
13481|    491|          input_position += 2;
13482|    491|        }
13483|       |
13484|    491|        [[fallthrough]];
13485|    491|      }
13486|    491|      case state::SPECIAL_AUTHORITY_IGNORE_SLASHES: {
  ------------------
  |  Branch (13486:7): [True: 0, False: 3.92k]
  ------------------
13487|    491|        ada_log("SPECIAL_AUTHORITY_IGNORE_SLASHES ",
13488|    491|                helpers::substring(url_data, input_position));
13489|       |
13490|       |        // If c is neither U+002F (/) nor U+005C (\), then set state to
13491|       |        // authority state and decrease pointer by 1.
13492|    491|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13492:16): [True: 491, False: 0]
  ------------------
13493|    491|               ((url_data[input_position] == '/') ||
  ------------------
  |  Branch (13493:17): [True: 0, False: 491]
  ------------------
13494|    491|                (url_data[input_position] == '\\'))) {
  ------------------
  |  Branch (13494:17): [True: 0, False: 491]
  ------------------
13495|      0|          input_position++;
13496|      0|        }
13497|    491|        state = state::AUTHORITY;
13498|       |
13499|    491|        break;
13500|    491|      }
13501|    491|      case state::QUERY: {
  ------------------
  |  Branch (13501:7): [True: 491, False: 3.43k]
  ------------------
13502|    491|        ada_log("QUERY ", helpers::substring(url_data, input_position));
13503|    491|        if constexpr (store_values) {
13504|       |          // Let queryPercentEncodeSet be the special-query percent-encode set
13505|       |          // if url is special; otherwise the query percent-encode set.
13506|    491|          const uint8_t* query_percent_encode_set =
13507|    491|              url.is_special() ? character_sets::SPECIAL_QUERY_PERCENT_ENCODE
  ------------------
  |  Branch (13507:15): [True: 491, False: 0]
  ------------------
13508|    491|                               : character_sets::QUERY_PERCENT_ENCODE;
13509|       |
13510|       |          // Percent-encode after encoding, with encoding, buffer, and
13511|       |          // queryPercentEncodeSet, and append the result to url's query.
13512|    491|          url.update_base_search(url_data.substr(input_position),
13513|    491|                                 query_percent_encode_set);
13514|    491|          ada_log("QUERY update_base_search completed ");
13515|    491|          if (fragment.has_value()) {
  ------------------
  |  Branch (13515:15): [True: 117, False: 374]
  ------------------
13516|    117|            url.update_unencoded_base_hash(*fragment);
13517|    117|          }
13518|    491|        }
13519|    491|        enforce_max_input_length();
13520|    491|        return url;
13521|    491|      }
13522|    491|      case state::HOST: {
  ------------------
  |  Branch (13522:7): [True: 491, False: 3.43k]
  ------------------
13523|    491|        ada_log("HOST ", helpers::substring(url_data, input_position));
13524|       |
13525|    491|        std::string_view host_view = url_data.substr(input_position);
13526|    491|        auto [location, found_colon] =
13527|    491|            helpers::get_host_delimiter_location(url.is_special(), host_view);
13528|    491|        input_position = (location != std::string_view::npos)
  ------------------
  |  Branch (13528:26): [True: 491, False: 0]
  ------------------
13529|    491|                             ? input_position + location
13530|    491|                             : input_size;
13531|       |        // Otherwise, if c is U+003A (:) and insideBrackets is false, then:
13532|       |        // Note: the 'found_colon' value is true if and only if a colon was
13533|       |        // encountered while not inside brackets.
13534|    491|        if (found_colon) {
  ------------------
  |  Branch (13534:13): [True: 0, False: 491]
  ------------------
13535|       |          // If buffer is the empty string, validation error, return failure.
13536|       |          // Let host be the result of host parsing buffer with url is not
13537|       |          // special.
13538|      0|          ada_log("HOST parsing ", host_view);
13539|      0|          if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13539:15): [True: 0, False: 0]
  ------------------
13540|      0|            return url;
13541|      0|          }
13542|      0|          ada_log("HOST parsing results in ", url.get_hostname());
13543|       |          // Set url's host to host, buffer to the empty string, and state to
13544|       |          // port state.
13545|      0|          state = state::PORT;
13546|      0|          input_position++;
13547|      0|        }
13548|       |        // Otherwise, if one of the following is true:
13549|       |        // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13550|       |        // - url is special and c is U+005C (\)
13551|       |        // The get_host_delimiter_location function either brings us to
13552|       |        // the colon outside of the bracket, or to one of those characters.
13553|    491|        else {
13554|       |          // If url is special and host_view is the empty string, validation
13555|       |          // error, return failure.
13556|    491|          if (host_view.empty() && url.is_special()) {
  ------------------
  |  Branch (13556:15): [True: 0, False: 491]
  |  Branch (13556:36): [True: 0, False: 0]
  ------------------
13557|      0|            url.is_valid = false;
13558|      0|            return url;
13559|      0|          }
13560|    491|          ada_log("HOST parsing ", host_view, " href=", url.get_href());
13561|       |          // Let host be the result of host parsing host_view with url is not
13562|       |          // special.
13563|    491|          if (host_view.empty()) {
  ------------------
  |  Branch (13563:15): [True: 0, False: 491]
  ------------------
13564|      0|            url.update_base_hostname("");
13565|    491|          } else if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13565:22): [True: 0, False: 491]
  ------------------
13566|      0|            return url;
13567|      0|          }
13568|    491|          ada_log("HOST parsing results in ", url.get_hostname(),
13569|    491|                  " href=", url.get_href());
13570|       |
13571|       |          // Set url's host to host, and state to path start state.
13572|    491|          state = state::PATH_START;
13573|    491|        }
13574|       |
13575|    491|        break;
13576|    491|      }
13577|    491|      case state::OPAQUE_PATH: {
  ------------------
  |  Branch (13577:7): [True: 0, False: 3.92k]
  ------------------
13578|      0|        ada_log("OPAQUE_PATH ", helpers::substring(url_data, input_position));
13579|       |        // Opaque path, query, and fragment are structurally always valid:
13580|       |        // the parser would just percent-encode whatever is there. When we
13581|       |        // are not storing values (can_parse), we can return immediately.
13582|       |        // We must set has_opaque_path = true before returning so that when
13583|       |        // this URL is used as an internal base inside can_parse, NO_SCHEME
13584|       |        // correctly rejects relative inputs against an opaque-path base
13585|       |        // (e.g. can_parse("", &"W:") must return false).
13586|       |        if constexpr (!store_values) {
13587|       |          url.has_opaque_path = true;
13588|       |          return url;
13589|       |        }
13590|      0|        std::string_view view = url_data.substr(input_position);
13591|       |        // If c is U+003F (?), then set url's query to the empty string and
13592|       |        // state to query state.
13593|      0|        size_t location = view.find('?');
13594|      0|        if (location != std::string_view::npos) {
  ------------------
  |  Branch (13594:13): [True: 0, False: 0]
  ------------------
13595|      0|          view.remove_suffix(view.size() - location);
13596|      0|          state = state::QUERY;
13597|      0|          input_position += location + 1;
13598|      0|        } else {
13599|      0|          input_position = input_size + 1;
13600|      0|        }
13601|      0|        url.has_opaque_path = true;
13602|       |
13603|       |        // This is a really unlikely scenario in real world. We should not seek
13604|       |        // to optimize it.
13605|      0|        if (view.ends_with(' ')) {
  ------------------
  |  Branch (13605:13): [True: 0, False: 0]
  ------------------
13606|      0|          std::string modified_view =
13607|      0|              std::string(view.substr(0, view.size() - 1)) + "%20";
13608|      0|          url.update_base_pathname(unicode::percent_encode(
13609|      0|              modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13610|      0|        } else {
13611|      0|          url.update_base_pathname(unicode::percent_encode(
13612|      0|              view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13613|      0|        }
13614|      0|        break;
13615|    491|      }
13616|      0|      case state::PORT: {
  ------------------
  |  Branch (13616:7): [True: 0, False: 3.92k]
  ------------------
13617|      0|        ada_log("PORT ", helpers::substring(url_data, input_position));
13618|      0|        std::string_view port_view = url_data.substr(input_position);
13619|      0|        input_position += url.parse_port(port_view, true);
13620|      0|        if (!url.is_valid) {
  ------------------
  |  Branch (13620:13): [True: 0, False: 0]
  ------------------
13621|      0|          return url;
13622|      0|        }
13623|      0|        state = state::PATH_START;
13624|      0|        [[fallthrough]];
13625|      0|      }
13626|    491|      case state::PATH_START: {
  ------------------
  |  Branch (13626:7): [True: 491, False: 3.43k]
  ------------------
13627|    491|        ada_log("PATH_START ", helpers::substring(url_data, input_position));
13628|       |        // Path, query, and fragment are structurally always valid: the
13629|       |        // parser would just percent-encode whatever is there. When we are
13630|       |        // not storing values (can_parse), we can return immediately since
13631|       |        // no subsequent state can invalidate the URL.
13632|       |        if constexpr (!store_values) {
13633|       |          return url;
13634|       |        }
13635|       |
13636|       |        // If url is special, then:
13637|    491|        if (url.is_special()) {
  ------------------
  |  Branch (13637:13): [True: 491, False: 0]
  ------------------
13638|       |          // Set state to path state.
13639|    491|          state = state::PATH;
13640|       |
13641|       |          // Optimization: Avoiding going into PATH state improves the
13642|       |          // performance of urls ending with /.
13643|    491|          if (input_position == input_size) {
  ------------------
  |  Branch (13643:15): [True: 0, False: 491]
  ------------------
13644|      0|            if constexpr (store_values) {
13645|      0|              url.update_base_pathname("/");
13646|      0|              if (fragment.has_value()) {
  ------------------
  |  Branch (13646:19): [True: 0, False: 0]
  ------------------
13647|      0|                url.update_unencoded_base_hash(*fragment);
13648|      0|              }
13649|      0|            }
13650|      0|            enforce_max_input_length();
13651|      0|            return url;
13652|      0|          }
13653|       |          // If c is neither U+002F (/) nor U+005C (\), then decrease pointer
13654|       |          // by 1. We know that (input_position == input_size) is impossible
13655|       |          // here, because of the previous if-check.
13656|    491|          if ((url_data[input_position] != '/') &&
  ------------------
  |  Branch (13656:15): [True: 0, False: 491]
  ------------------
13657|      0|              (url_data[input_position] != '\\')) {
  ------------------
  |  Branch (13657:15): [True: 0, False: 0]
  ------------------
13658|      0|            break;
13659|      0|          }
13660|    491|        }
13661|       |        // Otherwise, if state override is not given and c is U+003F (?),
13662|       |        // set url's query to the empty string and state to query state.
13663|      0|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13663:18): [True: 0, False: 0]
  ------------------
13664|      0|                 (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13664:18): [True: 0, False: 0]
  ------------------
13665|      0|          state = state::QUERY;
13666|      0|        }
13667|       |        // Otherwise, if c is not the EOF code point:
13668|      0|        else if (input_position != input_size) {
  ------------------
  |  Branch (13668:18): [True: 0, False: 0]
  ------------------
13669|       |          // Set state to path state.
13670|      0|          state = state::PATH;
13671|       |
13672|       |          // If c is not U+002F (/), then decrease pointer by 1.
13673|      0|          if (url_data[input_position] != '/') {
  ------------------
  |  Branch (13673:15): [True: 0, False: 0]
  ------------------
13674|      0|            break;
13675|      0|          }
13676|      0|        }
13677|       |
13678|    491|        input_position++;
13679|    491|        break;
13680|    491|      }
13681|    491|      case state::PATH: {
  ------------------
  |  Branch (13681:7): [True: 491, False: 3.43k]
  ------------------
13682|    491|        ada_log("PATH ", helpers::substring(url_data, input_position));
13683|       |        // Path, query, and fragment are structurally always valid: the
13684|       |        // parser would just percent-encode whatever is there. When we are
13685|       |        // not storing values (can_parse), we can return immediately since
13686|       |        // no subsequent state can invalidate the URL.
13687|       |        if constexpr (!store_values) {
13688|       |          return url;
13689|       |        }
13690|    491|        std::string_view view = url_data.substr(input_position);
13691|       |
13692|       |        // Most time, we do not need percent encoding.
13693|       |        // Furthermore, we can immediately locate the '?'.
13694|    491|        size_t locofquestionmark = view.find('?');
13695|    491|        if (locofquestionmark != std::string_view::npos) {
  ------------------
  |  Branch (13695:13): [True: 491, False: 0]
  ------------------
13696|    491|          state = state::QUERY;
13697|    491|          view.remove_suffix(view.size() - locofquestionmark);
13698|    491|          input_position += locofquestionmark + 1;
13699|    491|        } else {
13700|      0|          input_position = input_size + 1;
13701|      0|        }
13702|    491|        if constexpr (store_values) {
13703|       |          if constexpr (result_type_is_ada_url) {
13704|       |            helpers::parse_prepared_path(view, url.type, url.path);
13705|    491|          } else {
13706|    491|            url.consume_prepared_path(view);
13707|    491|            ADA_ASSERT_TRUE(url.validate());
13708|    491|          }
13709|    491|        }
13710|    491|        break;
13711|    491|      }
13712|      0|      case state::FILE_SLASH: {
  ------------------
  |  Branch (13712:7): [True: 0, False: 3.92k]
  ------------------
13713|      0|        ada_log("FILE_SLASH ", helpers::substring(url_data, input_position));
13714|       |
13715|       |        // If c is U+002F (/) or U+005C (\), then:
13716|      0|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13716:13): [True: 0, False: 0]
  ------------------
13717|      0|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13717:14): [True: 0, False: 0]
  ------------------
13718|      0|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13718:14): [True: 0, False: 0]
  ------------------
13719|      0|          ada_log("FILE_SLASH c is U+002F or U+005C");
13720|       |          // Set state to file host state.
13721|      0|          state = state::FILE_HOST;
13722|      0|          input_position++;
13723|      0|        } else {
13724|      0|          ada_log("FILE_SLASH otherwise");
13725|       |          // If base is non-null and base's scheme is "file", then:
13726|       |          // Note: it is unsafe to do base_url->scheme unless you know that
13727|       |          // base_url_has_value() is true.
13728|      0|          if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13728:15): [True: 0, False: 0]
  |  Branch (13728:38): [True: 0, False: 0]
  ------------------
13729|       |            // Set url's host to base's host.
13730|       |            if constexpr (result_type_is_ada_url) {
13731|       |              url.host = base_url->host;
13732|      0|            } else {
13733|      0|              url.update_host_to_base_host(base_url->get_host());
13734|      0|            }
13735|       |            // If the code point substring from pointer to the end of input does
13736|       |            // not start with a Windows drive letter and base's path[0] is a
13737|       |            // normalized Windows drive letter, then append base's path[0] to
13738|       |            // url's path.
13739|      0|            if (!base_url->get_pathname().empty()) {
  ------------------
  |  Branch (13739:17): [True: 0, False: 0]
  ------------------
13740|      0|              if (!checkers::is_windows_drive_letter(
  ------------------
  |  Branch (13740:19): [True: 0, False: 0]
  ------------------
13741|      0|                      url_data.substr(input_position))) {
13742|      0|                std::string_view first_base_url_path =
13743|      0|                    base_url->get_pathname().substr(1);
13744|      0|                size_t loc = first_base_url_path.find('/');
13745|      0|                if (loc != std::string_view::npos) {
  ------------------
  |  Branch (13745:21): [True: 0, False: 0]
  ------------------
13746|      0|                  helpers::resize(first_base_url_path, loc);
13747|      0|                }
13748|      0|                if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (13748:21): [True: 0, False: 0]
  ------------------
13749|      0|                        first_base_url_path)) {
13750|       |                  if constexpr (result_type_is_ada_url) {
13751|       |                    url.path += '/';
13752|       |                    url.path += first_base_url_path;
13753|      0|                  } else {
13754|      0|                    url.append_base_pathname(
13755|      0|                        helpers::concat("/", first_base_url_path));
13756|      0|                  }
13757|      0|                }
13758|      0|              }
13759|      0|            }
13760|      0|          }
13761|       |
13762|       |          // Set state to path state, and decrease pointer by 1.
13763|      0|          state = state::PATH;
13764|      0|        }
13765|       |
13766|      0|        break;
13767|    491|      }
13768|      0|      case state::FILE_HOST: {
  ------------------
  |  Branch (13768:7): [True: 0, False: 3.92k]
  ------------------
13769|      0|        ada_log("FILE_HOST ", helpers::substring(url_data, input_position));
13770|      0|        std::string_view view = url_data.substr(input_position);
13771|       |
13772|      0|        size_t location = view.find_first_of("/\\?");
13773|      0|        std::string_view file_host_buffer = view.substr(
13774|      0|            0, (location != std::string_view::npos) ? location : view.size());
  ------------------
  |  Branch (13774:16): [True: 0, False: 0]
  ------------------
13775|       |
13776|      0|        if (checkers::is_windows_drive_letter(file_host_buffer)) {
  ------------------
  |  Branch (13776:13): [True: 0, False: 0]
  ------------------
13777|      0|          state = state::PATH;
13778|      0|        } else if (file_host_buffer.empty()) {
  ------------------
  |  Branch (13778:20): [True: 0, False: 0]
  ------------------
13779|       |          // Set url's host to the empty string.
13780|       |          if constexpr (result_type_is_ada_url) {
13781|       |            url.host = "";
13782|      0|          } else {
13783|      0|            url.update_base_hostname("");
13784|      0|          }
13785|       |          // Set state to path start state.
13786|      0|          state = state::PATH_START;
13787|      0|        } else {
13788|      0|          size_t consumed_bytes = file_host_buffer.size();
13789|      0|          input_position += consumed_bytes;
13790|       |          // Let host be the result of host parsing buffer with url is not
13791|       |          // special.
13792|      0|          if (!url.parse_host(file_host_buffer)) {
  ------------------
  |  Branch (13792:15): [True: 0, False: 0]
  ------------------
13793|      0|            return url;
13794|      0|          }
13795|       |
13796|       |          if constexpr (result_type_is_ada_url) {
13797|       |            // If host is "localhost", then set host to the empty string.
13798|       |            if (url.host.has_value() && url.host.value() == "localhost") {
13799|       |              url.host = "";
13800|       |            }
13801|      0|          } else {
13802|      0|            if (url.get_hostname() == "localhost") {
  ------------------
  |  Branch (13802:17): [True: 0, False: 0]
  ------------------
13803|      0|              url.update_base_hostname("");
13804|      0|            }
13805|      0|          }
13806|       |
13807|       |          // Set buffer to the empty string and state to path start state.
13808|      0|          state = state::PATH_START;
13809|      0|        }
13810|       |
13811|      0|        break;
13812|      0|      }
13813|      0|      case state::FILE: {
  ------------------
  |  Branch (13813:7): [True: 0, False: 3.92k]
  ------------------
13814|      0|        ada_log("FILE ", helpers::substring(url_data, input_position));
13815|      0|        std::string_view file_view = url_data.substr(input_position);
13816|       |
13817|      0|        url.set_protocol_as_file();
13818|       |        if constexpr (result_type_is_ada_url) {
13819|       |          // Set url's host to the empty string.
13820|       |          url.host = "";
13821|      0|        } else {
13822|      0|          url.update_base_hostname("");
13823|      0|        }
13824|       |        // If c is U+002F (/) or U+005C (\), then:
13825|      0|        if (input_position != input_size &&
  ------------------
  |  Branch (13825:13): [True: 0, False: 0]
  ------------------
13826|      0|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13826:14): [True: 0, False: 0]
  ------------------
13827|      0|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13827:14): [True: 0, False: 0]
  ------------------
13828|      0|          ada_log("FILE c is U+002F or U+005C");
13829|       |          // Set state to file slash state.
13830|      0|          state = state::FILE_SLASH;
13831|      0|        }
13832|       |        // Otherwise, if base is non-null and base's scheme is "file":
13833|      0|        else if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13833:18): [True: 0, False: 0]
  |  Branch (13833:41): [True: 0, False: 0]
  ------------------
13834|       |          // Set url's host to base's host, url's path to a clone of base's
13835|       |          // path, and url's query to base's query.
13836|      0|          ada_log("FILE base non-null");
13837|       |          if constexpr (result_type_is_ada_url) {
13838|       |            url.host = base_url->host;
13839|       |            url.path = base_url->path;
13840|       |            url.query = base_url->query;
13841|      0|          } else {
13842|      0|            url.update_host_to_base_host(base_url->get_hostname());
13843|      0|            url.update_base_pathname(base_url->get_pathname());
13844|      0|            if (base_url->has_search()) {
  ------------------
  |  Branch (13844:17): [True: 0, False: 0]
  ------------------
13845|       |              // get_search() returns "" for an empty query string (URL ends
13846|       |              // with '?'). update_base_search("") would incorrectly clear the
13847|       |              // query, so pass "?" to preserve the empty query distinction.
13848|      0|              auto s = base_url->get_search();
13849|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13849:38): [True: 0, False: 0]
  ------------------
13850|      0|            }
13851|      0|          }
13852|      0|          url.has_opaque_path = base_url->has_opaque_path;
13853|       |
13854|       |          // If c is U+003F (?), then set url's query to the empty string and
13855|       |          // state to query state.
13856|      0|          if (input_position != input_size && url_data[input_position] == '?') {
  ------------------
  |  Branch (13856:15): [True: 0, False: 0]
  |  Branch (13856:47): [True: 0, False: 0]
  ------------------
13857|      0|            state = state::QUERY;
13858|      0|          }
13859|       |          // Otherwise, if c is not the EOF code point:
13860|      0|          else if (input_position != input_size) {
  ------------------
  |  Branch (13860:20): [True: 0, False: 0]
  ------------------
13861|       |            // Set url's query to null.
13862|      0|            url.clear_search();
13863|       |            // If the code point substring from pointer to the end of input does
13864|       |            // not start with a Windows drive letter, then shorten url's path.
13865|      0|            if (!checkers::is_windows_drive_letter(file_view)) {
  ------------------
  |  Branch (13865:17): [True: 0, False: 0]
  ------------------
13866|       |              if constexpr (result_type_is_ada_url) {
13867|       |                helpers::shorten_path(url.path, url.type);
13868|      0|              } else {
13869|      0|                std::string_view path = url.get_pathname();
13870|      0|                if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13870:21): [True: 0, False: 0]
  ------------------
13871|      0|                  url.update_base_pathname(std::move(std::string(path)));
13872|      0|                }
13873|      0|              }
13874|      0|            }
13875|       |            // Otherwise:
13876|      0|            else {
13877|       |              // Set url's path to an empty list.
13878|      0|              url.clear_pathname();
13879|      0|            }
13880|       |
13881|       |            // Set state to path state and decrease pointer by 1.
13882|      0|            state = state::PATH;
13883|      0|            break;
13884|      0|          }
13885|      0|        }
13886|       |        // Otherwise, set state to path state, and decrease pointer by 1.
13887|      0|        else {
13888|      0|          ada_log("FILE go to path");
13889|      0|          state = state::PATH;
13890|      0|          break;
13891|      0|        }
13892|       |
13893|      0|        input_position++;
13894|      0|        break;
13895|      0|      }
13896|      0|      default:
  ------------------
  |  Branch (13896:7): [True: 0, False: 3.92k]
  ------------------
13897|      0|        unreachable();
13898|  3.92k|    }
13899|  3.92k|  }
13900|  2.44k|  if constexpr (store_values) {
13901|  2.44k|    if (fragment.has_value()) {
  ------------------
  |  Branch (13901:9): [True: 0, False: 2.44k]
  ------------------
13902|      0|      url.update_unencoded_base_hash(*fragment);
13903|      0|    }
13904|  2.44k|  }
13905|  2.44k|  enforce_max_input_length();
13906|  2.44k|  return url;
13907|  2.93k|}
_ZNK3ada14url_aggregator23needs_rollback_snapshotEm:
14199|  1.57k|bool url_aggregator::needs_rollback_snapshot(size_t input_len) const noexcept {
14200|       |  // 3x should cover worst-case percent-encoding of every input byte; the
14201|       |  // constant covers the handful of delimiter bytes a setter may add ("/.", "?",
14202|       |  // "#" and so on)
14203|  1.57k|  return buffer.size() + input_len * 3 + 16 > ada::get_max_input_length();
14204|  1.57k|}
_ZN3ada14url_aggregator10set_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14430|  2.93k|void url_aggregator::set_search(const std::string_view input) {
14431|  2.93k|  if (helpers::overlaps(input, buffer)) {
  ------------------
  |  Branch (14431:7): [True: 0, False: 2.93k]
  ------------------
14432|      0|    set_search(std::string(input));
14433|      0|    return;
14434|      0|  }
14435|  2.93k|  ada_log("url_aggregator::set_search ", input);
14436|  2.93k|  ADA_ASSERT_TRUE(validate());
14437|  2.93k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
14438|  2.93k|  if (input.empty()) {
  ------------------
  |  Branch (14438:7): [True: 1.35k, False: 1.57k]
  ------------------
14439|  1.35k|    clear_search();
14440|  1.35k|    helpers::strip_trailing_spaces_from_opaque_path(*this);
14441|  1.35k|    return;
14442|  1.35k|  }
14443|       |
14444|  1.57k|  std::string_view stripped = input[0] == '?' ? input.substr(1) : input;
  ------------------
  |  Branch (14444:31): [True: 0, False: 1.57k]
  ------------------
14445|       |  // Fast path: no tabs/newlines (the common case) avoids the std::string
14446|       |  // allocation entirely by passing the view straight to update_base_search.
14447|  1.57k|  std::string cleaned;
14448|  1.57k|  std::string_view effective = stripped;
14449|  1.57k|  if (unicode::has_tabs_or_newline(stripped)) {
  ------------------
  |  Branch (14449:7): [True: 0, False: 1.57k]
  ------------------
14450|      0|    cleaned = stripped;
14451|      0|    helpers::remove_ascii_tab_or_newline(cleaned);
14452|      0|    effective = cleaned;
14453|      0|  }
14454|       |
14455|  1.57k|  auto query_percent_encode_set =
14456|  1.57k|      is_special() ? ada::character_sets::SPECIAL_QUERY_PERCENT_ENCODE
  ------------------
  |  Branch (14456:7): [True: 1.57k, False: 0]
  ------------------
14457|  1.57k|                   : ada::character_sets::QUERY_PERCENT_ENCODE;
14458|       |
14459|  1.57k|  std::optional<url_aggregator> saved_url;
14460|  1.57k|  if (needs_rollback_snapshot(effective.size())) {
  ------------------
  |  Branch (14460:7): [True: 0, False: 1.57k]
  ------------------
14461|      0|    saved_url = *this;
14462|      0|  }
14463|  1.57k|  update_base_search(effective, query_percent_encode_set);
14464|  1.57k|  if (saved_url && buffer.size() > ada::get_max_input_length()) {
  ------------------
  |  Branch (14464:7): [True: 0, False: 1.57k]
  |  Branch (14464:20): [True: 0, False: 0]
  ------------------
14465|      0|    *this = std::move(*saved_url);
14466|      0|    return;
14467|      0|  }
14468|  1.57k|  ADA_ASSERT_TRUE(validate());
14469|  1.57k|}
_ZNK3ada14url_aggregator10get_searchEv:
14984|  2.93k|    ada_lifetime_bound {
14985|  2.93k|  ada_log("url_aggregator::get_search");
14986|       |  // If this's URL's query is either null or the empty string, then return the
14987|       |  // empty string. Return U+003F (?), followed by this's URL's query.
14988|  2.93k|  if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (14988:7): [True: 0, False: 2.93k]
  ------------------
14989|      0|    return "";
14990|      0|  }
14991|  2.93k|  auto ending_index = uint32_t(buffer.size());
14992|  2.93k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (14992:7): [True: 437, False: 2.49k]
  ------------------
14993|    437|    ending_index = components.hash_start;
14994|    437|  }
14995|  2.93k|  if (ending_index - components.search_start <= 1) {
  ------------------
  |  Branch (14995:7): [True: 1.30k, False: 1.62k]
  ------------------
14996|  1.30k|    return "";
14997|  1.30k|  }
14998|  1.62k|  return helpers::substring(buffer, components.search_start, ending_index);
14999|  2.93k|}
_ZN3ada4idna7deflate22make_fixed_litlen_huffEv:
  481|      2|inline Huff make_fixed_litlen_huff() {
  482|      2|  Huff h;
  483|      2|  uint8_t lens[288];
  484|       |  // Fixed Huffman: 0-143:8, 144-255:9, 256-279:7, 280-287:8
  485|    290|  for (int i = 0; i <= 143; i++) lens[i] = 8;
  ------------------
  |  Branch (485:19): [True: 288, False: 2]
  ------------------
  486|    226|  for (int i = 144; i <= 255; i++) lens[i] = 9;
  ------------------
  |  Branch (486:21): [True: 224, False: 2]
  ------------------
  487|     50|  for (int i = 256; i <= 279; i++) lens[i] = 7;
  ------------------
  |  Branch (487:21): [True: 48, False: 2]
  ------------------
  488|     18|  for (int i = 280; i <= 287; i++) lens[i] = 8;
  ------------------
  |  Branch (488:21): [True: 16, False: 2]
  ------------------
  489|      2|  h.build(lens, 288);
  490|      2|  return h;
  491|      2|}
_ZN3ada4idna7deflate4Huff5buildEPKhi:
  430|      4|  bool build(const uint8_t* lens, int n) {
  431|      4|    std::memset(counts, 0, sizeof(counts));
  432|      4|    std::memset(first_code, 0, sizeof(first_code));
  433|      4|    std::memset(base_idx, 0, sizeof(base_idx));
  434|      4|    nsymbols = n;
  435|      4|    max_bits = 0;
  436|    644|    for (int i = 0; i < n; i++) {
  ------------------
  |  Branch (436:21): [True: 640, False: 4]
  ------------------
  437|    640|      lengths[i] = lens[i];
  438|    640|      if (lens[i]) {
  ------------------
  |  Branch (438:11): [True: 640, False: 0]
  ------------------
  439|    640|        counts[lens[i]]++;
  440|    640|        if (lens[i] > max_bits) max_bits = lens[i];
  ------------------
  |  Branch (440:13): [True: 6, False: 634]
  ------------------
  441|    640|      }
  442|    640|    }
  443|       |    // Canonical first code for each bit length (RFC 1951).
  444|      4|    int code = 0;
  445|     64|    for (int bits = 1; bits <= MAXBITS; bits++) {
  ------------------
  |  Branch (445:24): [True: 60, False: 4]
  ------------------
  446|     60|      code = (code + counts[bits - 1]) << 1;
  447|     60|      first_code[bits] = code;
  448|     60|    }
  449|      4|    int idx = 0;
  450|     32|    for (int bits = 1; bits <= max_bits; bits++) {
  ------------------
  |  Branch (450:24): [True: 28, False: 4]
  ------------------
  451|     28|      base_idx[bits] = idx;
  452|       |      // assign symbols in symbol order for codes of this length
  453|  5.53k|      for (int sym = 0; sym < n; sym++) {
  ------------------
  |  Branch (453:25): [True: 5.50k, False: 28]
  ------------------
  454|  5.50k|        if (lengths[sym] == bits) {
  ------------------
  |  Branch (454:13): [True: 640, False: 4.86k]
  ------------------
  455|    640|          symbols[idx++] = static_cast<int16_t>(sym);
  456|    640|        }
  457|  5.50k|      }
  458|     28|    }
  459|      4|    return true;
  460|      4|  }
_ZN3ada4idna7deflate20make_fixed_dist_huffEv:
  493|      2|inline Huff make_fixed_dist_huff() {
  494|      2|  Huff h;
  495|      2|  uint8_t lens[32];
  496|     66|  for (int i = 0; i < 32; i++) lens[i] = 5;
  ------------------
  |  Branch (496:19): [True: 64, False: 2]
  ------------------
  497|      2|  h.build(lens, 32);
  498|      2|  return h;
  499|      2|}
_ZZN3ada7unicode14percent_encodeILb1EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEEENKUlcE_clEc:
 7682|   117k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7683|   117k|    return character_sets::bit_at(character_set, c);
 7684|   117k|  });
url_search_params.cc:_ZZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKhENK3$_0clEc:
 7650|  87.9k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7651|  87.9k|    return character_sets::bit_at(character_set, c);
 7652|  87.9k|  });
url_search_params.cc:_ZN3ada7unicode12_GLOBAL__N_122percent_encode_to_wideEPKcS3_PKhRNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEE:
 8036|  3.58k|                            const uint8_t character_set[], std::string& out) {
 8037|       |  // Worst case every byte becomes %XX. Avoids realloc while walking windows.
 8038|  3.58k|  out.reserve(out.size() + static_cast<size_t>(end - p) * 3);
 8039|  3.58k|#if ADA_UNICODE_SSSE3
 8040|  3.58k|  const ssse3_percent_tables tables = load_ssse3_percent_tables(character_set);
 8041|  3.58k|  percent_encode_to_ssse3(p, end, character_set, tables, out);
 8042|       |#elif ADA_NEON
 8043|       |  percent_encode_to_neon(p, end, character_set,
 8044|       |                         load_neon_percent_table(character_set), out);
 8045|       |#elif ADA_RVV
 8046|       |  percent_encode_to_rvv(p, end, character_set, out);
 8047|       |#endif
 8048|  3.58k|}
url_search_params.cc:_ZN3ada7unicode12_GLOBAL__N_125load_ssse3_percent_tablesEPKh:
 7863|  3.58k|load_ssse3_percent_tables(const uint8_t character_set[]) noexcept {
 7864|  3.58k|  ssse3_percent_tables t{};
 7865|  3.58k|  t.cs_lo = _mm_loadu_si128(reinterpret_cast<const __m128i*>(character_set));
 7866|  3.58k|  t.cs_hi =
 7867|  3.58k|      _mm_loadu_si128(reinterpret_cast<const __m128i*>(character_set + 16));
 7868|       |  // 1 << (0..7), duplicated so pshufb(index & 7) works for every lane.
 7869|  3.58k|  t.pow2 =
 7870|  3.58k|      _mm_setr_epi8(1, 2, 4, 8, 16, 32, 64, -128, 1, 2, 4, 8, 16, 32, 64, -128);
 7871|  3.58k|  t.mask_0f = _mm_set1_epi8(0x0F);
 7872|  3.58k|  t.mask_07 = _mm_set1_epi8(0x07);
 7873|  3.58k|  t.zero = _mm_setzero_si128();
 7874|  3.58k|  return t;
 7875|  3.58k|}
url_search_params.cc:_ZN3ada7unicode12_GLOBAL__N_123percent_encode_to_ssse3EPKcS3_PKhRKNS1_20ssse3_percent_tablesERNSt3__112basic_stringIcNS9_11char_traitsIcEENS9_9allocatorIcEEEE:
 7894|  3.58k|    const ssse3_percent_tables& tables, std::string& out) {
 7895|       |  // Pair 16-byte windows so a fully clean 32-byte run is one append.
 7896|  14.5k|  while (p + 32 <= end) {
  ------------------
  |  Branch (7896:10): [True: 10.9k, False: 3.58k]
  ------------------
 7897|  10.9k|    const __m128i word0 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(p));
 7898|  10.9k|    const __m128i word1 =
 7899|  10.9k|        _mm_loadu_si128(reinterpret_cast<const __m128i*>(p + 16));
 7900|  10.9k|    const int mask0 = ssse3_percent_mask(word0, tables);
 7901|  10.9k|    const int mask1 = ssse3_percent_mask(word1, tables);
 7902|  10.9k|    if ((mask0 | mask1) == 0) {
  ------------------
  |  Branch (7902:9): [True: 586, False: 10.3k]
  ------------------
 7903|    586|      out.append(p, 32);
 7904|  10.3k|    } else {
 7905|  10.3k|      if (mask0 == 0) {
  ------------------
  |  Branch (7905:11): [True: 282, False: 10.0k]
  ------------------
 7906|    282|        out.append(p, 16);
 7907|  10.0k|      } else {
 7908|  10.0k|        encode_mask_window(p, static_cast<uint32_t>(mask0), 16, out);
 7909|  10.0k|      }
 7910|  10.3k|      if (mask1 == 0) {
  ------------------
  |  Branch (7910:11): [True: 566, False: 9.76k]
  ------------------
 7911|    566|        out.append(p + 16, 16);
 7912|  9.76k|      } else {
 7913|  9.76k|        encode_mask_window(p + 16, static_cast<uint32_t>(mask1), 16, out);
 7914|  9.76k|      }
 7915|  10.3k|    }
 7916|  10.9k|    p += 32;
 7917|  10.9k|  }
 7918|  3.58k|  if (p + 16 <= end) {
  ------------------
  |  Branch (7918:7): [True: 1.85k, False: 1.73k]
  ------------------
 7919|  1.85k|    const __m128i word = _mm_loadu_si128(reinterpret_cast<const __m128i*>(p));
 7920|  1.85k|    const int mask = ssse3_percent_mask(word, tables);
 7921|  1.85k|    if (mask == 0) {
  ------------------
  |  Branch (7921:9): [True: 243, False: 1.61k]
  ------------------
 7922|    243|      out.append(p, 16);
 7923|  1.61k|    } else {
 7924|  1.61k|      encode_mask_window(p, static_cast<uint32_t>(mask), 16, out);
 7925|  1.61k|    }
 7926|  1.85k|    p += 16;
 7927|  1.85k|  }
 7928|  3.58k|  percent_encode_to_scalar(p, end, character_set, out);
 7929|  3.58k|}
url_search_params.cc:_ZN3ada7unicode12_GLOBAL__N_118ssse3_percent_maskEDv2_xRKNS1_20ssse3_percent_tablesE:
 7878|  23.6k|    __m128i word, const ssse3_percent_tables& tables) noexcept {
 7879|  23.6k|  const __m128i idx = _mm_and_si128(_mm_srli_epi16(word, 3), tables.mask_0f);
 7880|  23.6k|  const __m128i lo = _mm_shuffle_epi8(tables.cs_lo, idx);
 7881|  23.6k|  const __m128i hi = _mm_shuffle_epi8(tables.cs_hi, idx);
 7882|       |  // Bytes 0x80-0xFF are signed-negative; select the high half of the bitmap.
 7883|  23.6k|  const __m128i high_byte = _mm_cmpgt_epi8(tables.zero, word);
 7884|  23.6k|  const __m128i cs_byte = _mm_or_si128(_mm_and_si128(hi, high_byte),
 7885|  23.6k|                                       _mm_andnot_si128(high_byte, lo));
 7886|  23.6k|  const __m128i bits =
 7887|  23.6k|      _mm_shuffle_epi8(tables.pow2, _mm_and_si128(word, tables.mask_07));
 7888|  23.6k|  const __m128i hits = _mm_and_si128(cs_byte, bits);
 7889|  23.6k|  return _mm_movemask_epi8(_mm_cmpeq_epi8(hits, tables.zero)) ^ 0xFFFF;
 7890|  23.6k|}
url_search_params.cc:_ZN3ada7unicode12_GLOBAL__N_118encode_mask_windowEPKcjmRNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE:
 7818|  21.4k|                                          size_t width, std::string& out) {
 7819|  21.4k|  uint64_t bits = mask;
 7820|  21.4k|  size_t off = 0;
 7821|   309k|  while (bits != 0) {
  ------------------
  |  Branch (7821:10): [True: 288k, False: 21.4k]
  ------------------
 7822|   288k|    const int zero_run = trailing_zeroes32(static_cast<uint32_t>(bits));
 7823|   288k|    if (zero_run != 0) {
  ------------------
  |  Branch (7823:9): [True: 17.5k, False: 270k]
  ------------------
 7824|  17.5k|      out.append(p + off, static_cast<size_t>(zero_run));
 7825|  17.5k|    }
 7826|   288k|    off += static_cast<size_t>(zero_run);
 7827|   288k|    out.append(character_sets::hex + uint8_t(p[off]) * 4, 3);
 7828|   288k|    ++off;
 7829|   288k|    bits >>= static_cast<unsigned>(zero_run + 1);
 7830|   288k|  }
 7831|  21.4k|  if (off < width) {
  ------------------
  |  Branch (7831:7): [True: 3.72k, False: 17.7k]
  ------------------
 7832|  3.72k|    out.append(p + off, width - off);
 7833|  3.72k|  }
 7834|  21.4k|}
url_search_params.cc:_ZN3ada7unicode12_GLOBAL__N_117trailing_zeroes32Ej:
 7806|   288k|ada_really_inline int trailing_zeroes32(uint32_t input_num) noexcept {
 7807|       |#ifdef ADA_REGULAR_VISUAL_STUDIO
 7808|       |  unsigned long ret;
 7809|       |  _BitScanForward(&ret, input_num);
 7810|       |  return static_cast<int>(ret);
 7811|       |#else
 7812|   288k|  return __builtin_ctz(input_num);
 7813|   288k|#endif
 7814|   288k|}
url_search_params.cc:_ZN3ada7unicode12_GLOBAL__N_124percent_encode_to_scalarEPKcS3_PKhRNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEE:
 7839|  3.58k|                                                std::string& out) {
 7840|  20.1k|  for (; p != end; ++p) {
  ------------------
  |  Branch (7840:10): [True: 16.5k, False: 3.58k]
  ------------------
 7841|  16.5k|    if (character_sets::bit_at(character_set, *p)) {
  ------------------
  |  Branch (7841:9): [True: 12.5k, False: 3.94k]
  ------------------
 7842|  12.5k|      out.append(character_sets::hex + uint8_t(*p) * 4, 3);
 7843|  12.5k|    } else {
 7844|  3.94k|      out += *p;
 7845|  3.94k|    }
 7846|  16.5k|  }
 7847|  3.58k|}
_ZN3ada7unicode19has_tabs_or_newlineENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7192|  4.46k|    std::string_view user_input) noexcept {
 7193|       |  // first check for short strings in which case we do it naively.
 7194|  4.46k|  if (user_input.size() < 16) {  // slow path
  ------------------
  |  Branch (7194:7): [True: 1.72k, False: 2.74k]
  ------------------
 7195|  1.72k|    return std::ranges::any_of(user_input, is_tabs_or_newline);
 7196|  1.72k|  }
 7197|       |  // fast path for long strings (expected to be common)
 7198|  2.74k|  size_t i = 0;
 7199|  2.74k|  const __m128i mask1 = _mm_set1_epi8('\r');
 7200|  2.74k|  const __m128i mask2 = _mm_set1_epi8('\n');
 7201|  2.74k|  const __m128i mask3 = _mm_set1_epi8('\t');
 7202|       |  // If we supported SSSE3, we could use the algorithm that we use for NEON.
 7203|  2.74k|  __m128i running{0};
 7204|  18.2k|  for (; i + 15 < user_input.size(); i += 16) {
  ------------------
  |  Branch (7204:10): [True: 15.4k, False: 2.74k]
  ------------------
 7205|  15.4k|    __m128i word = _mm_loadu_si128((const __m128i*)(user_input.data() + i));
 7206|  15.4k|    running = _mm_or_si128(
 7207|  15.4k|        _mm_or_si128(running, _mm_or_si128(_mm_cmpeq_epi8(word, mask1),
 7208|  15.4k|                                           _mm_cmpeq_epi8(word, mask2))),
 7209|  15.4k|        _mm_cmpeq_epi8(word, mask3));
 7210|  15.4k|  }
 7211|  2.74k|  if (i < user_input.size()) {
  ------------------
  |  Branch (7211:7): [True: 2.57k, False: 165]
  ------------------
 7212|  2.57k|    __m128i word = _mm_loadu_si128(
 7213|  2.57k|        (const __m128i*)(user_input.data() + user_input.length() - 16));
 7214|  2.57k|    running = _mm_or_si128(
 7215|  2.57k|        _mm_or_si128(running, _mm_or_si128(_mm_cmpeq_epi8(word, mask1),
 7216|  2.57k|                                           _mm_cmpeq_epi8(word, mask2))),
 7217|  2.57k|        _mm_cmpeq_epi8(word, mask3));
 7218|  2.57k|  }
 7219|  2.74k|  return _mm_movemask_epi8(running) != 0;
 7220|  4.46k|}
_ZN3ada7unicode18is_tabs_or_newlineEc:
 7078|  5.09k|constexpr bool is_tabs_or_newline(char c) noexcept {
 7079|  5.09k|  return c == '\r' || c == '\n' || c == '\t';
  ------------------
  |  Branch (7079:10): [True: 0, False: 5.09k]
  |  Branch (7079:23): [True: 0, False: 5.09k]
  |  Branch (7079:36): [True: 0, False: 5.09k]
  ------------------
 7080|  5.09k|}
_ZN3ada7helpers27remove_ascii_tab_or_newlineERNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8904|    241|ada_really_inline void remove_ascii_tab_or_newline(std::string& input) {
 8905|       |  // Fast path: inputs with no tab/newline (the common case) avoid the
 8906|       |  // per-character erase_if scan. has_tabs_or_newline uses SIMD for inputs
 8907|       |  // >= 16 bytes, making this check much cheaper than erase_if's scalar
 8908|       |  // predicate walk when there is nothing to remove.
 8909|    241|  if (!ada::unicode::has_tabs_or_newline(input)) {
  ------------------
  |  Branch (8909:7): [True: 0, False: 241]
  ------------------
 8910|      0|    return;
 8911|      0|  }
 8912|    241|  std::erase_if(input, ada::unicode::is_ascii_tab_or_newline);
 8913|    241|}
_ZN3ada7unicode23is_ascii_tab_or_newlineEc:
 7437|  21.7k|    const char c) noexcept {
 7438|  21.7k|  return c == '\t' || c == '\n' || c == '\r';
  ------------------
  |  Branch (7438:10): [True: 540, False: 21.1k]
  |  Branch (7438:23): [True: 980, False: 20.1k]
  |  Branch (7438:36): [True: 288, False: 19.9k]
  ------------------
 7439|  21.7k|}
_ZN3ada7unicode22is_c0_control_or_spaceEc:
 7432|  4.76k|ada_really_inline constexpr bool is_c0_control_or_space(const char c) noexcept {
 7433|  4.76k|  return (unsigned char)c <= ' ';
 7434|  4.76k|}
_ZN3ada8checkers14path_signatureENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
   77|  1.50k|    std::string_view input) noexcept {
   78|       |  // The path percent-encode set is the query percent-encode set and U+003F (?),
   79|       |  // U+0060 (`), U+007B ({), and U+007D (}). The query percent-encode set is the
   80|       |  // C0 control percent-encode set and U+0020 SPACE, U+0022 ("), U+0023 (#),
   81|       |  // U+003C (<), and U+003E (>). The C0 control percent-encode set are the C0
   82|       |  // controls and all code points greater than U+007E (~).
   83|  1.50k|  size_t i = 0;
   84|  1.50k|  uint8_t accumulator{};
   85|  1.50k|  for (; i + 7 < input.size(); i += 8) {
  ------------------
  |  Branch (85:10): [True: 0, False: 1.50k]
  ------------------
   86|      0|    accumulator |= uint8_t(path_signature_table[uint8_t(input[i])] |
   87|      0|                           path_signature_table[uint8_t(input[i + 1])] |
   88|      0|                           path_signature_table[uint8_t(input[i + 2])] |
   89|      0|                           path_signature_table[uint8_t(input[i + 3])] |
   90|      0|                           path_signature_table[uint8_t(input[i + 4])] |
   91|      0|                           path_signature_table[uint8_t(input[i + 5])] |
   92|      0|                           path_signature_table[uint8_t(input[i + 6])] |
   93|      0|                           path_signature_table[uint8_t(input[i + 7])]);
   94|      0|  }
   95|  1.50k|  for (; i < input.size(); i++) {
  ------------------
  |  Branch (95:10): [True: 0, False: 1.50k]
  ------------------
   96|      0|    accumulator |= uint8_t(path_signature_table[uint8_t(input[i])]);
   97|      0|  }
   98|  1.50k|  return accumulator;
   99|  1.50k|}
_ZN3ada7unicode13is_alnum_plusEc:
 7409|  2.45k|ada_really_inline constexpr bool is_alnum_plus(const char c) noexcept {
 7410|  2.45k|  return is_alnum_plus_table[uint8_t(c)];
 7411|       |  // A table is almost surely much faster than the
 7412|       |  // following under most compilers: return
 7413|       |  // return (std::isalnum(c) || c == '+' || c == '-' || c == '.');
 7414|  2.45k|}
_ZZN3ada6parser25try_parse_simple_absoluteINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_ENKUlvE_clEv:
12591|  1.01k|    auto apply_query_and_hash = [&]() {
12592|  1.01k|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12592:11): [True: 1.01k, False: 0]
  ------------------
12593|  1.01k|        const size_t q_end =
12594|  1.01k|            (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12594:13): [True: 236, False: 774]
  ------------------
12595|  1.01k|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12596|  1.01k|                                                q_end - query_start - 1),
12597|  1.01k|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12598|  1.01k|      }
12599|  1.01k|      if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12599:11): [True: 236, False: 774]
  ------------------
12600|    236|        out.update_unencoded_base_hash(std::string_view(
12601|    236|            input.data() + hash_start + 1, len - hash_start - 1));
12602|    236|      }
12603|  1.01k|    };
_ZN3ada7helpers10prune_hashERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8844|    491|    std::string_view& input) noexcept {
 8845|       |  // compiles down to 20--30 instructions including a class to memchr (C
 8846|       |  // function). this function should be quite fast.
 8847|    491|  size_t location_of_first = input.find('#');
 8848|    491|  if (location_of_first == std::string_view::npos) {
  ------------------
  |  Branch (8848:7): [True: 374, False: 117]
  ------------------
 8849|    374|    return std::nullopt;
 8850|    374|  }
 8851|    117|  std::string_view hash = input;
 8852|    117|  hash.remove_prefix(location_of_first + 1);
 8853|    117|  input.remove_suffix(input.size() - location_of_first);
 8854|    117|  return hash;
 8855|    491|}
_ZN3ada7helpers32find_authority_delimiter_specialENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9802|     61|find_authority_delimiter_special(std::string_view view) noexcept {
 9803|       |  // performance note: we might be able to gain further performance
 9804|       |  // with SIMD intrinsics.
 9805|    732|  for (auto pos = view.begin(); pos != view.end(); ++pos) {
  ------------------
  |  Branch (9805:33): [True: 732, False: 0]
  ------------------
 9806|    732|    if (authority_delimiter_special[(uint8_t)*pos]) {
  ------------------
  |  Branch (9806:9): [True: 61, False: 671]
  ------------------
 9807|     61|      return pos - view.begin();
 9808|     61|    }
 9809|    732|  }
 9810|      0|  return size_t(view.size());
 9811|     61|}
_ZN3ada7helpers27get_host_delimiter_locationEbRNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9518|    491|    const bool is_special, std::string_view& view) noexcept {
 9519|       |  /**
 9520|       |   * The spec at https://url.spec.whatwg.org/#hostname-state expects us to
 9521|       |   * compute a variable called insideBrackets but this variable is only used
 9522|       |   * once, to check whether a ':' character was found outside brackets. Exact
 9523|       |   * text: "Otherwise, if c is U+003A (:) and insideBrackets is false, then:".
 9524|       |   * It is conceptually simpler and arguably more efficient to just return a
 9525|       |   * Boolean indicating whether ':' was found outside brackets.
 9526|       |   */
 9527|    491|  const size_t view_size = view.size();
 9528|    491|  size_t location = 0;
 9529|    491|  bool found_colon = false;
 9530|       |  /**
 9531|       |   * Performance analysis:
 9532|       |   *
 9533|       |   * We are basically seeking the end of the hostname which can be indicated
 9534|       |   * by the end of the view, or by one of the characters ':', '/', '?', '\\'
 9535|       |   * (where '\\' is only applicable for special URLs). However, these must
 9536|       |   * appear outside a bracket range. E.g., if you have [something?]fd: then the
 9537|       |   * '?' does not count.
 9538|       |   *
 9539|       |   * So we can skip ahead to the next delimiter, as long as we include '[' in
 9540|       |   * the set of delimiters, and that we handle it first.
 9541|       |   *
 9542|       |   * So the trick is to have a fast function that locates the next delimiter.
 9543|       |   * Unless we find '[', then it only needs to be called once! Ideally, such a
 9544|       |   * function would be provided by the C++ standard library, but it seems that
 9545|       |   * find_first_of is not very fast, so we are forced to roll our own.
 9546|       |   *
 9547|       |   * We do not break into two loops for speed, but for clarity.
 9548|       |   */
 9549|    491|  if (is_special) {
  ------------------
  |  Branch (9549:7): [True: 491, False: 0]
  ------------------
 9550|       |    // We move to the next delimiter.
 9551|    491|    location = find_next_host_delimiter_special(view, location);
 9552|       |    // Unless we find '[' then we are going only going to have to call
 9553|       |    // find_next_host_delimiter_special once.
 9554|    491|    for (; location < view_size;
  ------------------
  |  Branch (9554:12): [True: 491, False: 0]
  ------------------
 9555|    491|         location = find_next_host_delimiter_special(view, location)) {
 9556|    491|      if (view[location] == '[') {
  ------------------
  |  Branch (9556:11): [True: 0, False: 491]
  ------------------
 9557|      0|        location = view.find(']', location);
 9558|      0|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (9558:13): [True: 0, False: 0]
  ------------------
 9559|       |          // performance: view.find might get translated to a memchr, which
 9560|       |          // has no notion of std::string_view::npos, so the code does not
 9561|       |          // reflect the assembly.
 9562|      0|          location = view_size;
 9563|      0|          break;
 9564|      0|        }
 9565|    491|      } else {
 9566|    491|        found_colon = view[location] == ':';
 9567|    491|        break;
 9568|    491|      }
 9569|    491|    }
 9570|    491|  } else {
 9571|       |    // We move to the next delimiter.
 9572|      0|    location = find_next_host_delimiter(view, location);
 9573|       |    // Unless we find '[' then we are going only going to have to call
 9574|       |    // find_next_host_delimiter_special once.
 9575|      0|    for (; location < view_size;
  ------------------
  |  Branch (9575:12): [True: 0, False: 0]
  ------------------
 9576|      0|         location = find_next_host_delimiter(view, location)) {
 9577|      0|      if (view[location] == '[') {
  ------------------
  |  Branch (9577:11): [True: 0, False: 0]
  ------------------
 9578|      0|        location = view.find(']', location);
 9579|      0|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (9579:13): [True: 0, False: 0]
  ------------------
 9580|       |          // performance: view.find might get translated to a memchr, which
 9581|       |          // has no notion of std::string_view::npos, so the code does not
 9582|       |          // reflect the assembly.
 9583|      0|          location = view_size;
 9584|      0|          break;
 9585|      0|        }
 9586|      0|      } else {
 9587|      0|        found_colon = view[location] == ':';
 9588|      0|        break;
 9589|      0|      }
 9590|      0|    }
 9591|      0|  }
 9592|       |  // performance: remove_suffix may translate into a single instruction.
 9593|    491|  view.remove_suffix(view_size - location);
 9594|    491|  return {location, found_colon};
 9595|    491|}
_ZN3ada7helpers32find_next_host_delimiter_specialENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 9108|    491|    std::string_view view, size_t location) noexcept {
 9109|       |  // first check for short strings in which case we do it naively.
 9110|    491|  if (view.size() - location < 16) {  // slow path
  ------------------
  |  Branch (9110:7): [True: 241, False: 250]
  ------------------
 9111|  2.89k|    for (size_t i = location; i < view.size(); i++) {
  ------------------
  |  Branch (9111:31): [True: 2.89k, False: 0]
  ------------------
 9112|  2.89k|      if (view[i] == ':' || view[i] == '/' || view[i] == '\\' ||
  ------------------
  |  Branch (9112:11): [True: 0, False: 2.89k]
  |  Branch (9112:29): [True: 241, False: 2.65k]
  |  Branch (9112:47): [True: 0, False: 2.65k]
  ------------------
 9113|  2.65k|          view[i] == '?' || view[i] == '[') {
  ------------------
  |  Branch (9113:11): [True: 0, False: 2.65k]
  |  Branch (9113:29): [True: 0, False: 2.65k]
  ------------------
 9114|    241|        return i;
 9115|    241|      }
 9116|  2.89k|    }
 9117|      0|    return size_t(view.size());
 9118|    241|  }
 9119|       |  // fast path for long strings (expected to be common)
 9120|    250|  size_t i = location;
 9121|    250|  const __m128i mask1 = _mm_set1_epi8(':');
 9122|    250|  const __m128i mask2 = _mm_set1_epi8('/');
 9123|    250|  const __m128i mask3 = _mm_set1_epi8('\\');
 9124|    250|  const __m128i mask4 = _mm_set1_epi8('?');
 9125|    250|  const __m128i mask5 = _mm_set1_epi8('[');
 9126|       |
 9127|    250|  for (; i + 15 < view.size(); i += 16) {
  ------------------
  |  Branch (9127:10): [True: 250, False: 0]
  ------------------
 9128|    250|    __m128i word = _mm_loadu_si128((const __m128i*)(view.data() + i));
 9129|    250|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 9130|    250|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 9131|    250|    __m128i m3 = _mm_cmpeq_epi8(word, mask3);
 9132|    250|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 9133|    250|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 9134|    250|    __m128i m = _mm_or_si128(
 9135|    250|        _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m3, m4)), m5);
 9136|    250|    int mask = _mm_movemask_epi8(m);
 9137|    250|    if (mask != 0) {
  ------------------
  |  Branch (9137:9): [True: 250, False: 0]
  ------------------
 9138|    250|      return i + trailing_zeroes(mask);
 9139|    250|    }
 9140|    250|  }
 9141|      0|  if (i < view.size()) {
  ------------------
  |  Branch (9141:7): [True: 0, False: 0]
  ------------------
 9142|      0|    __m128i word =
 9143|      0|        _mm_loadu_si128((const __m128i*)(view.data() + view.length() - 16));
 9144|      0|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 9145|      0|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 9146|      0|    __m128i m3 = _mm_cmpeq_epi8(word, mask3);
 9147|      0|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 9148|      0|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 9149|      0|    __m128i m = _mm_or_si128(
 9150|      0|        _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m3, m4)), m5);
 9151|      0|    int mask = _mm_movemask_epi8(m);
 9152|      0|    if (mask != 0) {
  ------------------
  |  Branch (9152:9): [True: 0, False: 0]
  ------------------
 9153|      0|      return view.length() - 16 + trailing_zeroes(mask);
 9154|      0|    }
 9155|      0|  }
 9156|      0|  return size_t(view.length());
 9157|      0|}
_ZN3ada7helpers15trailing_zeroesEj:
 8930|    250|ada_really_inline int trailing_zeroes(uint32_t input_num) noexcept {
 8931|       |#ifdef ADA_REGULAR_VISUAL_STUDIO
 8932|       |  unsigned long ret;
 8933|       |  // Search the mask data from least significant bit (LSB)
 8934|       |  // to the most significant bit (MSB) for a set bit (1).
 8935|       |  _BitScanForward(&ret, input_num);
 8936|       |  return (int)ret;
 8937|       |#else   // ADA_REGULAR_VISUAL_STUDIO
 8938|    250|  return __builtin_ctzl(input_num);
 8939|    250|#endif  // ADA_REGULAR_VISUAL_STUDIO
 8940|    250|}
_ZN3ada7unicode45contains_forbidden_domain_code_point_or_upperEPKcm:
 7379|    491|                                              size_t length) noexcept {
 7380|    491|  size_t i = 0;
 7381|    491|  uint8_t accumulator{};
 7382|  1.47k|  for (; i + 4 <= length; i += 4) {
  ------------------
  |  Branch (7382:10): [True: 982, False: 491]
  ------------------
 7383|    982|    accumulator |=
 7384|    982|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i])];
 7385|    982|    accumulator |=
 7386|    982|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 1])];
 7387|    982|    accumulator |=
 7388|    982|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 2])];
 7389|    982|    accumulator |=
 7390|    982|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 3])];
 7391|    982|  }
 7392|  1.96k|  for (; i < length; i++) {
  ------------------
  |  Branch (7392:10): [True: 1.47k, False: 491]
  ------------------
 7393|  1.47k|    accumulator |=
 7394|  1.47k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i])];
 7395|  1.47k|  }
 7396|    491|  return accumulator;
 7397|    491|}
_ZZN3ada6parser14parse_url_implINS_14url_aggregatorELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_ENKUlvE_clEv:
12914|    491|  const auto enforce_max_input_length = [&]() {
12915|    491|    if constexpr (store_values) {
12916|    491|      if (url.is_valid) {
  ------------------
  |  Branch (12916:11): [True: 491, False: 0]
  ------------------
12917|    491|        if constexpr (result_type_is_ada_url_aggregator) {
12918|    491|          if (url.buffer.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12918:15): [True: 0, False: 491]
  ------------------
12919|      0|            url.is_valid = false;
12920|      0|          }
12921|       |        } else {
12922|       |          if (url.get_href_size() > max_input_length) [[unlikely]] {
12923|       |            url.is_valid = false;
12924|       |          }
12925|       |        }
12926|    491|      }
12927|    491|    }
12928|    491|  };
url_search_params.cc:_ZN3ada6parser12_GLOBAL__N_116authority_has_atEPKhmm:
11412|  2.93k|                                        size_t n) noexcept {
11413|  2.93k|  const size_t rem = n - host_start;
11414|       |#if ADA_NEON
11415|       |  if (rem >= 16) {
11416|       |    const uint8x16_t w = vld1q_u8(p + host_start);
11417|       |    const uint64_t at = neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('@')));
11418|       |    if (at == 0) {
11419|       |      return false;
11420|       |    }
11421|       |    const uint64_t delim = neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('/'))) |
11422|       |                           neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('?'))) |
11423|       |                           neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('#')));
11424|       |    return delim == 0 || std::countr_zero(at) < std::countr_zero(delim);
11425|       |  }
11426|       |#elif ADA_SSE2
11427|  2.93k|  if (rem >= 16) {
  ------------------
  |  Branch (11427:7): [True: 1.40k, False: 1.52k]
  ------------------
11428|  1.40k|    const __m128i w =
11429|  1.40k|        _mm_loadu_si128(reinterpret_cast<const __m128i*>(p + host_start));
11430|  1.40k|    const uint16_t at = static_cast<uint16_t>(
11431|  1.40k|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('@'))));
11432|  1.40k|    if (at == 0) {
  ------------------
  |  Branch (11432:9): [True: 1.36k, False: 33]
  ------------------
11433|  1.36k|      return false;
11434|  1.36k|    }
11435|     33|    const uint16_t delim = static_cast<uint16_t>(
11436|     33|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('/'))) |
11437|     33|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('?'))) |
11438|     33|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('#'))));
11439|     33|    return delim == 0 || std::countr_zero(at) < std::countr_zero(delim);
  ------------------
  |  Branch (11439:12): [True: 0, False: 33]
  |  Branch (11439:26): [True: 0, False: 33]
  ------------------
11440|  1.40k|  }
11441|       |#else
11442|       |  (void)p;
11443|       |  (void)rem;
11444|       |#endif
11445|  1.52k|  return false;
11446|  2.93k|}
url_search_params.cc:_ZN3ada6parser12_GLOBAL__N_115scan_plain_hostEPKhmmRmRbS5_:
11467|  2.93k|                                     bool& has_x) noexcept {
11468|  2.93k|  has_upper = false;
11469|  2.93k|  has_x = false;
11470|  2.93k|  size_t i = start;
11471|  2.93k|#if ADA_PARSER_SSSE3
11472|  2.93k|  if (parser_use_ssse3() && (len - start >= 16)) {
  ------------------
  |  Branch (11472:7): [True: 2.93k, False: 0]
  |  Branch (11472:29): [True: 1.40k, False: 1.52k]
  ------------------
11473|  1.40k|    const __m128i lo_tbl = nibble_load(k_host_nibbles.low);
11474|  1.40k|    const __m128i hi_tbl = nibble_load(k_host_nibbles.high);
11475|  1.40k|    const __m128i x_splat = _mm_set1_epi8('x');
11476|  1.40k|    auto visit = [&](size_t at) noexcept -> bool {
11477|  1.40k|      const __m128i w =
11478|  1.40k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + at));
11479|  1.40k|      const int up = sse2_uppercase(w);
11480|  1.40k|      const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11481|  1.40k|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11482|  1.40k|      if (mask == 0) {
11483|  1.40k|        if (up != 0) {
11484|  1.40k|          has_upper = true;
11485|  1.40k|        }
11486|  1.40k|        if (xs != 0) {
11487|  1.40k|          has_x = true;
11488|  1.40k|        }
11489|  1.40k|        return false;
11490|  1.40k|      }
11491|  1.40k|      const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11492|  1.40k|      const int valid = (1 << hit) - 1;
11493|  1.40k|      if ((up & valid) != 0) {
11494|  1.40k|        has_upper = true;
11495|  1.40k|      }
11496|  1.40k|      if ((xs & valid) != 0) {
11497|  1.40k|        has_x = true;
11498|  1.40k|      }
11499|  1.40k|      end = at + static_cast<size_t>(hit);
11500|  1.40k|      return true;
11501|  1.40k|    };
11502|  1.40k|    for (; i + 32 <= len; i += 32) {
  ------------------
  |  Branch (11502:12): [True: 822, False: 580]
  ------------------
11503|    822|      if (visit(i) || visit(i + 16)) {
  ------------------
  |  Branch (11503:11): [True: 822, False: 0]
  |  Branch (11503:23): [True: 0, False: 0]
  ------------------
11504|    822|        return k_host_class[b[end]] == 1;
11505|    822|      }
11506|    822|    }
11507|    580|    for (; i + 16 <= len; i += 16) {
  ------------------
  |  Branch (11507:12): [True: 580, False: 0]
  ------------------
11508|    580|      if (visit(i)) {
  ------------------
  |  Branch (11508:11): [True: 580, False: 0]
  ------------------
11509|    580|        return k_host_class[b[end]] == 1;
11510|    580|      }
11511|    580|    }
11512|       |    // Overlapping tail only after a full 16-byte step so the window cannot
11513|       |    // start before `start` (a prior '/' would otherwise look like a host stop).
11514|      0|    if (i > start && i < len) {
  ------------------
  |  Branch (11514:9): [True: 0, False: 0]
  |  Branch (11514:22): [True: 0, False: 0]
  ------------------
11515|      0|      if (visit(len - 16) && end >= i) {
  ------------------
  |  Branch (11515:11): [True: 0, False: 0]
  |  Branch (11515:30): [True: 0, False: 0]
  ------------------
11516|      0|        return k_host_class[b[end]] == 1;
11517|      0|      }
11518|      0|      end = len;
11519|      0|      return true;
11520|      0|    }
11521|      0|  }
11522|       |#elif ADA_SSE2
11523|       |  const __m128i x_splat = _mm_set1_epi8('x');
11524|       |  for (; i + 32 <= len; i += 32) {
11525|       |    for (size_t off = 0; off < 32; off += 16) {
11526|       |      const __m128i w =
11527|       |          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + off));
11528|       |      const int up = sse2_uppercase(w);
11529|       |      const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11530|       |      const int mask = sse2_host_stop(w);
11531|       |      if (mask != 0) {
11532|       |        const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11533|       |        const int valid = (1 << hit) - 1;
11534|       |        if ((up & valid) != 0) {
11535|       |          has_upper = true;
11536|       |        }
11537|       |        if ((xs & valid) != 0) {
11538|       |          has_x = true;
11539|       |        }
11540|       |        end = i + off + static_cast<size_t>(hit);
11541|       |        return k_host_class[b[end]] == 1;
11542|       |      }
11543|       |      if (up != 0) {
11544|       |        has_upper = true;
11545|       |      }
11546|       |      if (xs != 0) {
11547|       |        has_x = true;
11548|       |      }
11549|       |    }
11550|       |  }
11551|       |  for (; i + 16 <= len; i += 16) {
11552|       |    const __m128i w = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11553|       |    const int up = sse2_uppercase(w);
11554|       |    const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11555|       |    const int mask = sse2_host_stop(w);
11556|       |    if (mask != 0) {
11557|       |      const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11558|       |      const int valid = (1 << hit) - 1;
11559|       |      if ((up & valid) != 0) {
11560|       |        has_upper = true;
11561|       |      }
11562|       |      if ((xs & valid) != 0) {
11563|       |        has_x = true;
11564|       |      }
11565|       |      end = i + static_cast<size_t>(hit);
11566|       |      return k_host_class[b[end]] == 1;
11567|       |    }
11568|       |    if (up != 0) {
11569|       |      has_upper = true;
11570|       |    }
11571|       |    if (xs != 0) {
11572|       |      has_x = true;
11573|       |    }
11574|       |  }
11575|       |#elif ADA_NEON
11576|       |  if (len - start >= 16) {
11577|       |    const uint8x16_t lo_tbl = vld1q_u8(k_host_nibbles.low);
11578|       |    const uint8x16_t hi_tbl = vld1q_u8(k_host_nibbles.high);
11579|       |    const uint8x16_t x_splat = vdupq_n_u8('x');
11580|       |    auto visit = [&](size_t at) noexcept -> bool {
11581|       |      const uint8x16_t w = vld1q_u8(b + at);
11582|       |      const uint64_t up = neon_uppercase(w);
11583|       |      const uint64_t xs = neon_nibble_bits(vceqq_u8(w, x_splat));
11584|       |      const uint64_t bits = neon_table_stop(w, lo_tbl, hi_tbl);
11585|       |      if (bits == 0) {
11586|       |        if (up != 0) {
11587|       |          has_upper = true;
11588|       |        }
11589|       |        if (xs != 0) {
11590|       |          has_x = true;
11591|       |        }
11592|       |        return false;
11593|       |      }
11594|       |      const size_t hit = static_cast<size_t>(trailing_zeroes64(bits)) >> 2;
11595|       |      const uint64_t valid = (hit == 0) ? 0 : (uint64_t{1} << (hit * 4)) - 1;
11596|       |      if ((up & valid) != 0) {
11597|       |        has_upper = true;
11598|       |      }
11599|       |      if ((xs & valid) != 0) {
11600|       |        has_x = true;
11601|       |      }
11602|       |      end = at + hit;
11603|       |      return true;
11604|       |    };
11605|       |    for (; i + 32 <= len; i += 32) {
11606|       |      if (visit(i) || visit(i + 16)) {
11607|       |        return k_host_class[b[end]] == 1;
11608|       |      }
11609|       |    }
11610|       |    for (; i + 16 <= len; i += 16) {
11611|       |      if (visit(i)) {
11612|       |        return k_host_class[b[end]] == 1;
11613|       |      }
11614|       |    }
11615|       |    if (i > start && i < len) {
11616|       |      if (visit(len - 16) && end >= i) {
11617|       |        return k_host_class[b[end]] == 1;
11618|       |      }
11619|       |      end = len;
11620|       |      return true;
11621|       |    }
11622|       |  }
11623|       |#endif
11624|  18.3k|  for (; i < len; ++i) {
  ------------------
  |  Branch (11624:10): [True: 18.3k, False: 0]
  ------------------
11625|  18.3k|    const uint8_t c = b[i];
11626|  18.3k|    const uint8_t cls = k_host_class[c];
11627|  18.3k|    if (cls == 1) {
  ------------------
  |  Branch (11627:9): [True: 1.52k, False: 16.8k]
  ------------------
11628|  1.52k|      end = i;
11629|  1.52k|      return true;
11630|  1.52k|    }
11631|  16.8k|    if (cls == 2) {
  ------------------
  |  Branch (11631:9): [True: 0, False: 16.8k]
  ------------------
11632|      0|      return false;
11633|      0|    }
11634|  16.8k|    if (c >= 'A' && c <= 'Z') {
  ------------------
  |  Branch (11634:9): [True: 15.2k, False: 1.52k]
  |  Branch (11634:21): [True: 0, False: 15.2k]
  ------------------
11635|      0|      has_upper = true;
11636|  16.8k|    } else if (c == 'x') {
  ------------------
  |  Branch (11636:16): [True: 1.52k, False: 15.2k]
  ------------------
11637|  1.52k|      has_x = true;
11638|  1.52k|    }
11639|  16.8k|  }
11640|      0|  end = len;
11641|      0|  return true;
11642|  1.52k|}
url_search_params.cc:_ZN3ada6parser12_GLOBAL__N_116parser_use_ssse3Ev:
11452|  9.03k|ada_really_inline bool parser_use_ssse3() noexcept {
11453|  9.03k|#ifdef ADA_PARSER_NEED_SSSE3_TARGET
11454|  9.03k|  static const bool supported = __builtin_cpu_supports("ssse3") != 0;
11455|  9.03k|  return supported;
11456|       |#else
11457|       |  return true;
11458|       |#endif
11459|  9.03k|}
url_search_params.cc:_ZN3ada6parser12_GLOBAL__N_111nibble_loadEPKh:
11291|  6.79k|ADA_PARSER_SIMD __m128i nibble_load(const uint8_t* t) noexcept {
11292|  6.79k|  return _mm_load_si128(reinterpret_cast<const __m128i*>(t));
11293|  6.79k|}
url_search_params.cc:_ZZN3ada6parser12_GLOBAL__N_115scan_plain_hostEPKhmmRmRbS5_ENKUlmE_clEm:
11476|  1.40k|    auto visit = [&](size_t at) noexcept -> bool {
11477|  1.40k|      const __m128i w =
11478|  1.40k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + at));
11479|  1.40k|      const int up = sse2_uppercase(w);
11480|  1.40k|      const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11481|  1.40k|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11482|  1.40k|      if (mask == 0) {
  ------------------
  |  Branch (11482:11): [True: 0, False: 1.40k]
  ------------------
11483|      0|        if (up != 0) {
  ------------------
  |  Branch (11483:13): [True: 0, False: 0]
  ------------------
11484|      0|          has_upper = true;
11485|      0|        }
11486|      0|        if (xs != 0) {
  ------------------
  |  Branch (11486:13): [True: 0, False: 0]
  ------------------
11487|      0|          has_x = true;
11488|      0|        }
11489|      0|        return false;
11490|      0|      }
11491|  1.40k|      const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11492|  1.40k|      const int valid = (1 << hit) - 1;
11493|  1.40k|      if ((up & valid) != 0) {
  ------------------
  |  Branch (11493:11): [True: 0, False: 1.40k]
  ------------------
11494|      0|        has_upper = true;
11495|      0|      }
11496|  1.40k|      if ((xs & valid) != 0) {
  ------------------
  |  Branch (11496:11): [True: 1.40k, False: 0]
  ------------------
11497|  1.40k|        has_x = true;
11498|  1.40k|      }
11499|  1.40k|      end = at + static_cast<size_t>(hit);
11500|  1.40k|      return true;
11501|  1.40k|    };
url_search_params.cc:_ZN3ada6parser12_GLOBAL__N_114sse2_uppercaseEDv2_x:
11378|  1.40k|ada_really_inline int sse2_uppercase(__m128i w) noexcept {
11379|  1.40k|  return _mm_movemask_epi8(_mm_and_si128(
11380|  1.40k|      _mm_cmpgt_epi8(w, _mm_set1_epi8(static_cast<char>('A' - 1))),
11381|  1.40k|      _mm_cmplt_epi8(w, _mm_set1_epi8(static_cast<char>('Z' + 1)))));
11382|  1.40k|}
url_search_params.cc:_ZN3ada6parser12_GLOBAL__N_117ssse3_nibble_maskEDv2_xS2_S2_:
11298|  4.35k|                                          __m128i hi_tbl) noexcept {
11299|  4.35k|  const __m128i nibble = _mm_set1_epi8(0x0F);
11300|  4.35k|  const __m128i lo = _mm_and_si128(w, nibble);
11301|  4.35k|  const __m128i hi = _mm_and_si128(_mm_srli_epi16(w, 4), nibble);
11302|  4.35k|  const __m128i hit =
11303|  4.35k|      _mm_and_si128(_mm_shuffle_epi8(lo_tbl, lo), _mm_shuffle_epi8(hi_tbl, hi));
11304|  4.35k|  return _mm_movemask_epi8(_mm_cmpeq_epi8(hit, _mm_setzero_si128())) ^ 0xFFFF;
11305|  4.35k|}
url_search_params.cc:_ZN3ada6parser12_GLOBAL__N_117trailing_zeroes32Ej:
11270|  3.29k|ada_really_inline int trailing_zeroes32(uint32_t input_num) noexcept {
11271|       |#ifdef ADA_REGULAR_VISUAL_STUDIO
11272|       |  unsigned long ret;
11273|       |  _BitScanForward(&ret, input_num);
11274|       |  return static_cast<int>(ret);
11275|       |#else
11276|  3.29k|  return __builtin_ctz(input_num);
11277|  3.29k|#endif
11278|  3.29k|}
url_search_params.cc:_ZN3ada6parser12_GLOBAL__N_113scan_path_runEPKhRmmRb:
11702|  2.93k|                                   bool& maybe_dot_segment) noexcept {
11703|  2.93k|  const size_t run_start = i;
11704|  2.93k|#if ADA_PARSER_SSSE3
11705|  2.93k|  if (parser_use_ssse3() && (i + 16 <= len)) {
  ------------------
  |  Branch (11705:7): [True: 2.93k, False: 0]
  |  Branch (11705:29): [True: 945, False: 1.98k]
  ------------------
11706|    945|    const __m128i lo_tbl = nibble_load(k_path_nibbles.low);
11707|    945|    const __m128i hi_tbl = nibble_load(k_path_nibbles.high);
11708|    945|    for (; i + 32 <= len; i += 32) {
  ------------------
  |  Branch (11708:12): [True: 669, False: 276]
  ------------------
11709|    669|      const __m128i w0 =
11710|    669|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11711|    669|      const int m0 = ssse3_nibble_mask(w0, lo_tbl, hi_tbl);
11712|    669|      if (m0 != 0) {
  ------------------
  |  Branch (11712:11): [True: 669, False: 0]
  ------------------
11713|    669|        const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(m0));
11714|    669|        note_dots_in_window(b, i, run_start, w0, (1 << hit_bit) - 1,
11715|    669|                            maybe_dot_segment);
11716|    669|        i += static_cast<size_t>(hit_bit);
11717|    669|        return;
11718|    669|      }
11719|      0|      note_dots_in_window(b, i, run_start, w0, 0xFFFF, maybe_dot_segment);
11720|      0|      const __m128i w1 =
11721|      0|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + 16));
11722|      0|      const int m1 = ssse3_nibble_mask(w1, lo_tbl, hi_tbl);
11723|      0|      if (m1 != 0) {
  ------------------
  |  Branch (11723:11): [True: 0, False: 0]
  ------------------
11724|      0|        const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(m1));
11725|      0|        note_dots_in_window(b, i + 16, run_start, w1, (1 << hit_bit) - 1,
11726|      0|                            maybe_dot_segment);
11727|      0|        i += 16 + static_cast<size_t>(hit_bit);
11728|      0|        return;
11729|      0|      }
11730|      0|      note_dots_in_window(b, i + 16, run_start, w1, 0xFFFF, maybe_dot_segment);
11731|      0|    }
11732|    276|    for (; i + 16 <= len; i += 16) {
  ------------------
  |  Branch (11732:12): [True: 276, False: 0]
  ------------------
11733|    276|      const __m128i w =
11734|    276|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11735|    276|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11736|    276|      if (mask != 0) {
  ------------------
  |  Branch (11736:11): [True: 276, False: 0]
  ------------------
11737|    276|        const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(mask));
11738|    276|        note_dots_in_window(b, i, run_start, w, (1 << hit_bit) - 1,
11739|    276|                            maybe_dot_segment);
11740|    276|        i += static_cast<size_t>(hit_bit);
11741|    276|        return;
11742|    276|      }
11743|      0|      note_dots_in_window(b, i, run_start, w, 0xFFFF, maybe_dot_segment);
11744|      0|    }
11745|      0|    if (i > run_start && i < len) {
  ------------------
  |  Branch (11745:9): [True: 0, False: 0]
  |  Branch (11745:26): [True: 0, False: 0]
  ------------------
11746|      0|      const __m128i w =
11747|      0|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + len - 16));
11748|      0|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11749|      0|      if (mask != 0) {
  ------------------
  |  Branch (11749:11): [True: 0, False: 0]
  ------------------
11750|      0|        const size_t hit =
11751|      0|            len - 16 +
11752|      0|            static_cast<size_t>(trailing_zeroes32(static_cast<uint32_t>(mask)));
11753|      0|        if (hit >= i) {
  ------------------
  |  Branch (11753:13): [True: 0, False: 0]
  ------------------
11754|      0|          for (size_t j = i; j < hit; ++j) {
  ------------------
  |  Branch (11754:30): [True: 0, False: 0]
  ------------------
11755|      0|            if (b[j] == '.') {
  ------------------
  |  Branch (11755:17): [True: 0, False: 0]
  ------------------
11756|      0|              note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11757|      0|            }
11758|      0|          }
11759|      0|          i = hit;
11760|      0|          return;
11761|      0|        }
11762|      0|      }
11763|      0|      for (size_t j = i; j < len; ++j) {
  ------------------
  |  Branch (11763:26): [True: 0, False: 0]
  ------------------
11764|      0|        if (b[j] == '.') {
  ------------------
  |  Branch (11764:13): [True: 0, False: 0]
  ------------------
11765|      0|          note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11766|      0|        }
11767|      0|      }
11768|      0|      i = len;
11769|      0|      return;
11770|      0|    }
11771|      0|  }
11772|       |#elif ADA_SSE2
11773|       |  for (; i + 16 <= len; i += 16) {
11774|       |    const __m128i w = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11775|       |    const int mask = sse2_path_stop(w);
11776|       |    if (mask != 0) {
11777|       |      const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(mask));
11778|       |      note_dots_in_window(b, i, run_start, w, (1 << hit_bit) - 1,
11779|       |                          maybe_dot_segment);
11780|       |      i += static_cast<size_t>(hit_bit);
11781|       |      return;
11782|       |    }
11783|       |    note_dots_in_window(b, i, run_start, w, 0xFFFF, maybe_dot_segment);
11784|       |  }
11785|       |#elif ADA_NEON
11786|       |  if (i + 16 <= len) {
11787|       |    const uint8x16_t lo_tbl = vld1q_u8(k_path_nibbles.low);
11788|       |    const uint8x16_t hi_tbl = vld1q_u8(k_path_nibbles.high);
11789|       |    for (; i + 32 <= len; i += 32) {
11790|       |      const uint8x16_t w0 = vld1q_u8(b + i);
11791|       |      const uint64_t bits0 = neon_table_stop(w0, lo_tbl, hi_tbl);
11792|       |      if (bits0 != 0) {
11793|       |        const size_t hit_off =
11794|       |            static_cast<size_t>(trailing_zeroes64(bits0)) >> 2;
11795|       |        const uint64_t valid =
11796|       |            (hit_off == 0) ? 0 : (uint64_t{1} << (hit_off * 4)) - 1;
11797|       |        note_dots_in_window_neon(b, i, run_start, w0, valid, maybe_dot_segment);
11798|       |        i += hit_off;
11799|       |        return;
11800|       |      }
11801|       |      note_dots_in_window_neon(b, i, run_start, w0, ~uint64_t{0},
11802|       |                               maybe_dot_segment);
11803|       |      const uint8x16_t w1 = vld1q_u8(b + i + 16);
11804|       |      const uint64_t bits1 = neon_table_stop(w1, lo_tbl, hi_tbl);
11805|       |      if (bits1 != 0) {
11806|       |        const size_t hit_off =
11807|       |            static_cast<size_t>(trailing_zeroes64(bits1)) >> 2;
11808|       |        const uint64_t valid =
11809|       |            (hit_off == 0) ? 0 : (uint64_t{1} << (hit_off * 4)) - 1;
11810|       |        note_dots_in_window_neon(b, i + 16, run_start, w1, valid,
11811|       |                                 maybe_dot_segment);
11812|       |        i += 16 + hit_off;
11813|       |        return;
11814|       |      }
11815|       |      note_dots_in_window_neon(b, i + 16, run_start, w1, ~uint64_t{0},
11816|       |                               maybe_dot_segment);
11817|       |    }
11818|       |    for (; i + 16 <= len; i += 16) {
11819|       |      const uint8x16_t w = vld1q_u8(b + i);
11820|       |      const uint64_t bits = neon_table_stop(w, lo_tbl, hi_tbl);
11821|       |      if (bits != 0) {
11822|       |        const size_t hit_off =
11823|       |            static_cast<size_t>(trailing_zeroes64(bits)) >> 2;
11824|       |        const uint64_t valid =
11825|       |            (hit_off == 0) ? 0 : (uint64_t{1} << (hit_off * 4)) - 1;
11826|       |        note_dots_in_window_neon(b, i, run_start, w, valid, maybe_dot_segment);
11827|       |        i += hit_off;
11828|       |        return;
11829|       |      }
11830|       |      note_dots_in_window_neon(b, i, run_start, w, ~uint64_t{0},
11831|       |                               maybe_dot_segment);
11832|       |    }
11833|       |    if (i > run_start && i < len) {
11834|       |      const uint8x16_t w = vld1q_u8(b + len - 16);
11835|       |      const uint64_t bits = neon_table_stop(w, lo_tbl, hi_tbl);
11836|       |      if (bits != 0) {
11837|       |        const size_t hit =
11838|       |            len - 16 + (static_cast<size_t>(trailing_zeroes64(bits)) >> 2);
11839|       |        if (hit >= i) {
11840|       |          for (size_t j = i; j < hit; ++j) {
11841|       |            if (b[j] == '.') {
11842|       |              note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11843|       |            }
11844|       |          }
11845|       |          i = hit;
11846|       |          return;
11847|       |        }
11848|       |      }
11849|       |      for (size_t j = i; j < len; ++j) {
11850|       |        if (b[j] == '.') {
11851|       |          note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11852|       |        }
11853|       |      }
11854|       |      i = len;
11855|       |      return;
11856|       |    }
11857|       |  }
11858|       |#endif
11859|  1.98k|  for (; i < len; ++i) {
  ------------------
  |  Branch (11859:10): [True: 1.98k, False: 0]
  ------------------
11860|  1.98k|    const uint8_t c = b[i];
11861|  1.98k|    const uint8_t cls = k_path[c];
11862|  1.98k|    if (cls != 0) {
  ------------------
  |  Branch (11862:9): [True: 1.98k, False: 0]
  ------------------
11863|  1.98k|      return;
11864|  1.98k|    }
11865|      0|    if (c == '.') {
  ------------------
  |  Branch (11865:9): [True: 0, False: 0]
  ------------------
11866|      0|      note_possible_dot_segment(b, i, run_start, maybe_dot_segment);
11867|      0|    }
11868|      0|  }
11869|  1.98k|}
url_search_params.cc:_ZN3ada6parser12_GLOBAL__N_119note_dots_in_windowEPKhmmDv2_xiRb:
11659|    945|                                           bool& maybe_dot_segment) noexcept {
11660|    945|  if (maybe_dot_segment || valid_mask == 0) {
  ------------------
  |  Branch (11660:7): [True: 0, False: 945]
  |  Branch (11660:28): [True: 945, False: 0]
  ------------------
11661|    945|    return;
11662|    945|  }
11663|      0|  const int dots =
11664|      0|      _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('.'))) & valid_mask;
11665|      0|  if (dots == 0) {
  ------------------
  |  Branch (11665:7): [True: 0, False: 0]
  ------------------
11666|      0|    return;
11667|      0|  }
11668|      0|  const int slashes =
11669|      0|      _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('/'))) & valid_mask;
11670|      0|  if (((dots & 1) != 0 && (i == run_start || b[i - 1] == '/')) ||
  ------------------
  |  Branch (11670:8): [True: 0, False: 0]
  |  Branch (11670:28): [True: 0, False: 0]
  |  Branch (11670:46): [True: 0, False: 0]
  ------------------
11671|      0|      (dots & (slashes << 1)) != 0) {
  ------------------
  |  Branch (11671:7): [True: 0, False: 0]
  ------------------
11672|      0|    maybe_dot_segment = true;
11673|      0|  }
11674|      0|}
url_search_params.cc:_ZN3ada6parser12_GLOBAL__N_114scan_query_runEPKhRmm:
12012|  2.93k|                                    size_t len) noexcept {
12013|  2.93k|  ADA_SCAN_STOP_RUN(k_query_nibbles, k_query, sse2_query_stop);
  ------------------
  |  |11875|  2.93k|  do {                                                                       \
  |  |11876|  2.93k|    const size_t scan_start = i;                                             \
  |  |11877|  2.93k|    if (parser_use_ssse3() && (i + 16 <= len)) {                             \
  |  |  ------------------
  |  |  |  Branch (11877:9): [True: 2.93k, False: 0]
  |  |  |  Branch (11877:31): [True: 910, False: 2.02k]
  |  |  ------------------
  |  |11878|    910|      const __m128i lo_tbl = nibble_load((nibbles).low);                     \
  |  |11879|    910|      const __m128i hi_tbl = nibble_load((nibbles).high);                    \
  |  |11880|  1.24k|      for (; i + 32 <= len; i += 32) {                                       \
  |  |  ------------------
  |  |  |  Branch (11880:14): [True: 894, False: 349]
  |  |  ------------------
  |  |11881|    894|        const __m128i w0 =                                                   \
  |  |11882|    894|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11883|    894|        const int m0 = ssse3_nibble_mask(w0, lo_tbl, hi_tbl);                \
  |  |11884|    894|        if (m0 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11884:13): [True: 509, False: 385]
  |  |  ------------------
  |  |11885|    509|          i += static_cast<size_t>(                                          \
  |  |11886|    509|              trailing_zeroes32(static_cast<uint32_t>(m0)));                 \
  |  |11887|    509|          return;                                                            \
  |  |11888|    509|        }                                                                    \
  |  |11889|    894|        const __m128i w1 =                                                   \
  |  |11890|    385|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + 16));   \
  |  |11891|    385|        const int m1 = ssse3_nibble_mask(w1, lo_tbl, hi_tbl);                \
  |  |11892|    385|        if (m1 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11892:13): [True: 52, False: 333]
  |  |  ------------------
  |  |11893|     52|          i += 16 + static_cast<size_t>(                                     \
  |  |11894|     52|                        trailing_zeroes32(static_cast<uint32_t>(m1)));       \
  |  |11895|     52|          return;                                                            \
  |  |11896|     52|        }                                                                    \
  |  |11897|    385|      }                                                                      \
  |  |11898|    910|      for (; i + 16 <= len; i += 16) {                                       \
  |  |  ------------------
  |  |  |  Branch (11898:14): [True: 291, False: 140]
  |  |  ------------------
  |  |11899|    291|        const __m128i w =                                                    \
  |  |11900|    291|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11901|    291|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11902|    291|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11902:13): [True: 209, False: 82]
  |  |  ------------------
  |  |11903|    209|          i += static_cast<size_t>(                                          \
  |  |11904|    209|              trailing_zeroes32(static_cast<uint32_t>(mask)));               \
  |  |11905|    209|          return;                                                            \
  |  |11906|    209|        }                                                                    \
  |  |11907|    291|      }                                                                      \
  |  |11908|    349|      if (i > scan_start && i < len) {                                       \
  |  |  ------------------
  |  |  |  Branch (11908:11): [True: 140, False: 0]
  |  |  |  Branch (11908:29): [True: 113, False: 27]
  |  |  ------------------
  |  |11909|    113|        const __m128i w =                                                    \
  |  |11910|    113|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + len - 16)); \
  |  |11911|    113|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11912|    113|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11912:13): [True: 54, False: 59]
  |  |  ------------------
  |  |11913|     54|          const size_t hit = len - 16 +                                      \
  |  |11914|     54|                             static_cast<size_t>(trailing_zeroes32(          \
  |  |11915|     54|                                 static_cast<uint32_t>(mask)));              \
  |  |11916|     54|          if (hit >= i) {                                                    \
  |  |  ------------------
  |  |  |  Branch (11916:15): [True: 54, False: 0]
  |  |  ------------------
  |  |11917|     54|            i = hit;                                                         \
  |  |11918|     54|            return;                                                          \
  |  |11919|     54|          }                                                                  \
  |  |11920|     54|        }                                                                    \
  |  |11921|    113|        i = len;                                                             \
  |  |11922|     59|        return;                                                              \
  |  |11923|    113|      }                                                                      \
  |  |11924|    140|    }                                                                        \
  |  |11925|  2.95k|    for (; i < len; ++i) {                                                   \
  |  |  ------------------
  |  |  |  Branch (11925:12): [True: 1.67k, False: 1.28k]
  |  |  ------------------
  |  |11926|  1.67k|      if ((cls)[b[i]] != 0) {                                                \
  |  |  ------------------
  |  |  |  Branch (11926:11): [True: 761, False: 911]
  |  |  ------------------
  |  |11927|    761|        return;                                                              \
  |  |11928|    761|      }                                                                      \
  |  |11929|  1.67k|    }                                                                        \
  |  |11930|  2.04k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (11930:12): [Folded, False: 1.28k]
  |  |  ------------------
  ------------------
12014|  2.93k|}
url_search_params.cc:_ZN3ada6parser12_GLOBAL__N_113scan_hash_runEPKhRmm:
12017|    238|                                   size_t len) noexcept {
12018|    238|  ADA_SCAN_STOP_RUN(k_hash_nibbles, k_hash, sse2_hash_stop);
  ------------------
  |  |11875|    238|  do {                                                                       \
  |  |11876|    238|    const size_t scan_start = i;                                             \
  |  |11877|    238|    if (parser_use_ssse3() && (i + 16 <= len)) {                             \
  |  |  ------------------
  |  |  |  Branch (11877:9): [True: 238, False: 0]
  |  |  |  Branch (11877:31): [True: 141, False: 97]
  |  |  ------------------
  |  |11878|    141|      const __m128i lo_tbl = nibble_load((nibbles).low);                     \
  |  |11879|    141|      const __m128i hi_tbl = nibble_load((nibbles).high);                    \
  |  |11880|    206|      for (; i + 32 <= len; i += 32) {                                       \
  |  |  ------------------
  |  |  |  Branch (11880:14): [True: 122, False: 84]
  |  |  ------------------
  |  |11881|    122|        const __m128i w0 =                                                   \
  |  |11882|    122|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11883|    122|        const int m0 = ssse3_nibble_mask(w0, lo_tbl, hi_tbl);                \
  |  |11884|    122|        if (m0 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11884:13): [True: 37, False: 85]
  |  |  ------------------
  |  |11885|     37|          i += static_cast<size_t>(                                          \
  |  |11886|     37|              trailing_zeroes32(static_cast<uint32_t>(m0)));                 \
  |  |11887|     37|          return;                                                            \
  |  |11888|     37|        }                                                                    \
  |  |11889|    122|        const __m128i w1 =                                                   \
  |  |11890|     85|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + 16));   \
  |  |11891|     85|        const int m1 = ssse3_nibble_mask(w1, lo_tbl, hi_tbl);                \
  |  |11892|     85|        if (m1 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11892:13): [True: 20, False: 65]
  |  |  ------------------
  |  |11893|     20|          i += 16 + static_cast<size_t>(                                     \
  |  |11894|     20|                        trailing_zeroes32(static_cast<uint32_t>(m1)));       \
  |  |11895|     20|          return;                                                            \
  |  |11896|     20|        }                                                                    \
  |  |11897|     85|      }                                                                      \
  |  |11898|    141|      for (; i + 16 <= len; i += 16) {                                       \
  |  |  ------------------
  |  |  |  Branch (11898:14): [True: 63, False: 58]
  |  |  ------------------
  |  |11899|     63|        const __m128i w =                                                    \
  |  |11900|     63|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11901|     63|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11902|     63|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11902:13): [True: 26, False: 37]
  |  |  ------------------
  |  |11903|     26|          i += static_cast<size_t>(                                          \
  |  |11904|     26|              trailing_zeroes32(static_cast<uint32_t>(mask)));               \
  |  |11905|     26|          return;                                                            \
  |  |11906|     26|        }                                                                    \
  |  |11907|     63|      }                                                                      \
  |  |11908|     84|      if (i > scan_start && i < len) {                                       \
  |  |  ------------------
  |  |  |  Branch (11908:11): [True: 58, False: 0]
  |  |  |  Branch (11908:29): [True: 53, False: 5]
  |  |  ------------------
  |  |11909|     53|        const __m128i w =                                                    \
  |  |11910|     53|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + len - 16)); \
  |  |11911|     53|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11912|     53|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11912:13): [True: 42, False: 11]
  |  |  ------------------
  |  |11913|     42|          const size_t hit = len - 16 +                                      \
  |  |11914|     42|                             static_cast<size_t>(trailing_zeroes32(          \
  |  |11915|     42|                                 static_cast<uint32_t>(mask)));              \
  |  |11916|     42|          if (hit >= i) {                                                    \
  |  |  ------------------
  |  |  |  Branch (11916:15): [True: 42, False: 0]
  |  |  ------------------
  |  |11917|     42|            i = hit;                                                         \
  |  |11918|     42|            return;                                                          \
  |  |11919|     42|          }                                                                  \
  |  |11920|     42|        }                                                                    \
  |  |11921|     53|        i = len;                                                             \
  |  |11922|     11|        return;                                                              \
  |  |11923|     53|      }                                                                      \
  |  |11924|     58|    }                                                                        \
  |  |11925|    238|    for (; i < len; ++i) {                                                   \
  |  |  ------------------
  |  |  |  Branch (11925:12): [True: 150, False: 73]
  |  |  ------------------
  |  |11926|    150|      if ((cls)[b[i]] != 0) {                                                \
  |  |  ------------------
  |  |  |  Branch (11926:11): [True: 29, False: 121]
  |  |  ------------------
  |  |11927|     29|        return;                                                              \
  |  |11928|     29|      }                                                                      \
  |  |11929|    150|    }                                                                        \
  |  |11930|    102|  } while (0)
  |  |  ------------------
  |  |  |  Branch (11930:12): [Folded, False: 73]
  |  |  ------------------
  ------------------
12019|    238|}
url_search_params.cc:_ZN12_GLOBAL__N_132apply_shifted_non_scheme_offsetsERN3ada14url_componentsEj:
14010|    491|    ada::url_components& components, uint32_t new_difference) {
14011|    491|  components.username_end += new_difference;
14012|    491|  components.host_start += new_difference;
14013|    491|  components.host_end += new_difference;
14014|    491|  components.pathname_start += new_difference;
14015|    491|  if (components.search_start != ada::url_components::omitted) {
  ------------------
  |  Branch (14015:7): [True: 0, False: 491]
  ------------------
14016|      0|    components.search_start += new_difference;
14017|      0|  }
14018|    491|  if (components.hash_start != ada::url_components::omitted) {
  ------------------
  |  Branch (14018:7): [True: 0, False: 491]
  ------------------
14019|      0|    components.hash_start += new_difference;
14020|      0|  }
14021|    491|}
_ZN3ada14url_aggregator10parse_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14389|  1.01k|ada_really_inline void url_aggregator::parse_path(std::string_view input) {
14390|  1.01k|  ada_log("url_aggregator::parse_path ", input);
14391|  1.01k|  ADA_ASSERT_TRUE(validate());
14392|  1.01k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
14393|  1.01k|  std::string tmp_buffer;
14394|  1.01k|  std::string_view internal_input;
14395|  1.01k|  if (unicode::has_tabs_or_newline(input)) {
  ------------------
  |  Branch (14395:7): [True: 0, False: 1.01k]
  ------------------
14396|      0|    tmp_buffer = input;
14397|       |    // Optimization opportunity: Instead of copying and then pruning, we could
14398|       |    // just directly build the string from user_input.
14399|      0|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
14400|      0|    internal_input = tmp_buffer;
14401|  1.01k|  } else {
14402|  1.01k|    internal_input = input;
14403|  1.01k|  }
14404|       |
14405|       |  // If url is special, then:
14406|  1.01k|  if (is_special()) {
  ------------------
  |  Branch (14406:7): [True: 1.01k, False: 0]
  ------------------
14407|  1.01k|    if (internal_input.empty()) {
  ------------------
  |  Branch (14407:9): [True: 0, False: 1.01k]
  ------------------
14408|      0|      update_base_pathname("/");
14409|  1.01k|    } else if ((internal_input[0] == '/') || (internal_input[0] == '\\')) {
  ------------------
  |  Branch (14409:16): [True: 1.01k, False: 0]
  |  Branch (14409:46): [True: 0, False: 0]
  ------------------
14410|  1.01k|      consume_prepared_path(internal_input.substr(1));
14411|  1.01k|    } else {
14412|      0|      consume_prepared_path(internal_input);
14413|      0|    }
14414|  1.01k|  } else if (!internal_input.empty()) {
  ------------------
  |  Branch (14414:14): [True: 0, False: 0]
  ------------------
14415|      0|    if (internal_input[0] == '/') {
  ------------------
  |  Branch (14415:9): [True: 0, False: 0]
  ------------------
14416|      0|      consume_prepared_path(internal_input.substr(1));
14417|      0|    } else {
14418|      0|      consume_prepared_path(internal_input);
14419|      0|    }
14420|      0|  } else {
14421|       |    // Non-special URLs with an empty host can have their paths erased
14422|       |    // Path-only URLs cannot have their paths erased
14423|      0|    if (components.host_start == components.host_end && !has_authority()) {
  ------------------
  |  Branch (14423:9): [True: 0, False: 0]
  |  Branch (14423:57): [True: 0, False: 0]
  ------------------
14424|      0|      update_base_pathname("/");
14425|      0|    }
14426|      0|  }
14427|  1.01k|  ADA_ASSERT_TRUE(validate());
14428|  1.01k|}
_ZN3ada14url_aggregator10parse_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14530|    491|ada_really_inline bool url_aggregator::parse_host(std::string_view input) {
14531|    491|  ada_log("url_aggregator:parse_host \"", input, "\" [", input.size(),
14532|    491|          " bytes]");
14533|    491|  ADA_ASSERT_TRUE(validate());
14534|    491|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
14535|    491|  if (input.empty()) {
  ------------------
  |  Branch (14535:7): [True: 0, False: 491]
  ------------------
14536|      0|    return is_valid = false;
14537|      0|  }  // technically unnecessary.
14538|       |  // If input starts with U+005B ([), then:
14539|    491|  if (input[0] == '[') {
  ------------------
  |  Branch (14539:7): [True: 0, False: 491]
  ------------------
14540|       |    // If input does not end with U+005D (]), validation error, return failure.
14541|      0|    if (input.back() != ']') {
  ------------------
  |  Branch (14541:9): [True: 0, False: 0]
  ------------------
14542|      0|      return is_valid = false;
14543|      0|    }
14544|      0|    ada_log("parse_host ipv6");
14545|       |
14546|       |    // Return the result of IPv6 parsing input with its leading U+005B ([) and
14547|       |    // trailing U+005D (]) removed.
14548|      0|    input.remove_prefix(1);
14549|      0|    input.remove_suffix(1);
14550|      0|    return parse_ipv6(input);
14551|      0|  }
14552|       |
14553|       |  // If isNotSpecial is true, then return the result of opaque-host parsing
14554|       |  // input.
14555|    491|  if (!is_special()) {
  ------------------
  |  Branch (14555:7): [True: 0, False: 491]
  ------------------
14556|      0|    return parse_opaque_host(input);
14557|      0|  }
14558|       |  // Let domain be the result of running UTF-8 decode without BOM on the
14559|       |  // percent-decoding of input. Let asciiDomain be the result of running domain
14560|       |  // to ASCII with domain and false. The most common case is an ASCII input, in
14561|       |  // which case we do not need to call the expensive 'to_ascii' if a few
14562|       |  // conditions are met: no '%' and no 'xn-' subsequence.
14563|       |
14564|       |  // Often, the input does not contain any forbidden code points, and no upper
14565|       |  // case ASCII letter, then we can just copy it to the buffer. We want to
14566|       |  // optimize for such a common case.
14567|       |
14568|       |  // Fast path: try to parse as pure decimal IPv4 first.
14569|    491|  const uint64_t fast_result = checkers::try_parse_ipv4_fast(input);
14570|    491|  if (fast_result < checkers::ipv4_fast_fail) {
  ------------------
  |  Branch (14570:7): [True: 0, False: 491]
  ------------------
14571|      0|    if (!input.empty() && input.back() == '.') {
  ------------------
  |  Branch (14571:9): [True: 0, False: 0]
  |  Branch (14571:27): [True: 0, False: 0]
  ------------------
14572|      0|      update_base_hostname(input.substr(0, input.size() - 1));
14573|      0|    } else {
14574|      0|      update_base_hostname(input);
14575|      0|    }
14576|      0|    host_type = IPV4;
14577|      0|    is_valid = true;
14578|      0|    ada_log("parse_host fast path decimal ipv4");
14579|      0|    ADA_ASSERT_TRUE(validate());
14580|      0|    return true;
14581|      0|  }
14582|    491|  uint8_t is_forbidden_or_upper =
14583|    491|      unicode::contains_forbidden_domain_code_point_or_upper(input.data(),
14584|    491|                                                             input.size());
14585|    491|  static constexpr std::string_view xn_dash{"xn-", 3};
14586|    491|  if ((is_forbidden_or_upper & 1) == 0) {
  ------------------
  |  Branch (14586:7): [True: 491, False: 0]
  ------------------
14587|    491|    if ((is_forbidden_or_upper & 2) != 0) {
  ------------------
  |  Branch (14587:9): [True: 0, False: 491]
  ------------------
14588|      0|      std::string lowered(input);
14589|      0|      unicode::to_lower_ascii(lowered.data(), lowered.size());
14590|      0|      if (lowered.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (14590:11): [True: 0, False: 0]
  ------------------
14591|      0|          lowered.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (14591:11): [True: 0, False: 0]
  ------------------
14592|       |        // Check IPv4 before mutating so failures leave the buffer untouched.
14593|       |        // This also avoids a double buffer rewrite for hex/octal IPv4.
14594|      0|        if (checkers::is_ipv4(lowered)) {
  ------------------
  |  Branch (14594:13): [True: 0, False: 0]
  ------------------
14595|      0|          ada_log("parse_host fast path ipv4");
14596|      0|          return parse_ipv4(lowered, false);
14597|      0|        }
14598|      0|        update_base_hostname(lowered);
14599|      0|        ada_log("parse_host fast path ", get_hostname());
14600|      0|        is_valid = true;
14601|      0|        return true;
14602|      0|      }
14603|    491|    } else if (input.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (14603:16): [True: 491, False: 0]
  ------------------
14604|    491|               input.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (14604:16): [True: 0, False: 0]
  ------------------
14605|       |      // Check IPv4 before mutating so failures leave the buffer untouched.
14606|    491|      if (checkers::is_ipv4(input)) {
  ------------------
  |  Branch (14606:11): [True: 0, False: 491]
  ------------------
14607|      0|        ada_log("parse_host fast path ipv4");
14608|      0|        return parse_ipv4(input, false);
14609|      0|      }
14610|    491|      update_base_hostname(input);
14611|    491|      ada_log("parse_host fast path ", get_hostname());
14612|    491|      is_valid = true;
14613|    491|      return true;
14614|    491|    }
14615|    491|  } else if (const size_t first_percent = input.find('%');
14616|      0|             first_percent != std::string_view::npos) {
  ------------------
  |  Branch (14616:14): [True: 0, False: 0]
  ------------------
14617|      0|    std::string decoded = unicode::percent_decode(input, first_percent);
14618|      0|    const uint8_t decoded_flags =
14619|      0|        unicode::contains_forbidden_domain_code_point_or_upper(decoded.data(),
14620|      0|                                                               decoded.size());
14621|      0|    if ((decoded_flags & 1) == 0) {
  ------------------
  |  Branch (14621:9): [True: 0, False: 0]
  ------------------
14622|      0|      if ((decoded_flags & 2) != 0) {
  ------------------
  |  Branch (14622:11): [True: 0, False: 0]
  ------------------
14623|      0|        unicode::to_lower_ascii(decoded.data(), decoded.size());
14624|      0|      }
14625|      0|      if (decoded.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (14625:11): [True: 0, False: 0]
  ------------------
14626|      0|          decoded.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (14626:11): [True: 0, False: 0]
  ------------------
14627|       |        // Check IPv4 before mutating so failures leave the buffer untouched.
14628|      0|        if (checkers::is_ipv4(decoded)) {
  ------------------
  |  Branch (14628:13): [True: 0, False: 0]
  ------------------
14629|      0|          return parse_ipv4(decoded, false);
14630|      0|        }
14631|      0|        update_base_hostname(decoded);
14632|      0|        is_valid = true;
14633|      0|        return true;
14634|      0|      }
14635|      0|    }
14636|      0|  }
14637|       |  // We have encountered at least one forbidden code point or the input contains
14638|       |  // 'xn-' (case insensitive), so we need to call 'to_ascii' to perform the full
14639|       |  // conversion.
14640|       |
14641|      0|  ada_log("parse_host calling to_ascii");
14642|      0|  std::optional<std::string> host = std::string(get_hostname());
14643|      0|  is_valid = ada::unicode::to_ascii(host, input, input.find('%'));
14644|      0|  if (!is_valid) {
  ------------------
  |  Branch (14644:7): [True: 0, False: 0]
  ------------------
14645|      0|    ada_log("parse_host to_ascii returns false");
14646|      0|    return is_valid = false;
14647|      0|  }
14648|      0|  ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(),
14649|      0|          " bytes]");
14650|       |
14651|      0|  if (std::ranges::any_of(host.value(),
  ------------------
  |  Branch (14651:7): [True: 0, False: 0]
  ------------------
14652|      0|                          ada::unicode::is_forbidden_domain_code_point)) {
14653|      0|    return is_valid = false;
14654|      0|  }
14655|       |
14656|       |  // If asciiDomain ends in a number, then return the result of IPv4 parsing
14657|       |  // asciiDomain.
14658|      0|  if (checkers::is_ipv4(host.value())) {
  ------------------
  |  Branch (14658:7): [True: 0, False: 0]
  ------------------
14659|      0|    ada_log("parse_host got ipv4 ", *host);
14660|      0|    return parse_ipv4(host.value(), false);
14661|      0|  }
14662|       |
14663|      0|  update_base_hostname(host.value());
14664|      0|  ADA_ASSERT_TRUE(validate());
14665|      0|  return true;
14666|      0|}
_ZN3ada14url_aggregator21consume_prepared_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
15541|  1.50k|inline void url_aggregator::consume_prepared_path(std::string_view input) {
15542|  1.50k|  ada_log("url_aggregator::consume_prepared_path ", input);
15543|       |  /***
15544|       |   * This is largely duplicated code from helpers::parse_prepared_path, which is
15545|       |   * unfortunate. This particular function is nearly identical, except that it
15546|       |   * is a method on url_aggregator. The idea is that the trivial path (which is
15547|       |   * very common) merely appends to the buffer. This is the same trivial path as
15548|       |   * with helpers::parse_prepared_path, except that we have the additional check
15549|       |   * for is_at_path(). Otherwise, we grab a copy of the current path and we
15550|       |   * modify it, and then insert it back into the buffer.
15551|       |   */
15552|  1.50k|  uint8_t accumulator = checkers::path_signature(input);
15553|       |  // Let us first detect a trivial case.
15554|       |  // If it is special, we check that we have no dot, no %,  no \ and no
15555|       |  // character needing percent encoding. Otherwise, we check that we have no %,
15556|       |  // no dot, and no character needing percent encoding.
15557|  1.50k|  constexpr uint8_t need_encoding = 1;
15558|  1.50k|  constexpr uint8_t backslash_char = 2;
15559|  1.50k|  constexpr uint8_t dot_char = 4;
15560|  1.50k|  constexpr uint8_t percent_char = 8;
15561|  1.50k|  bool special = type != ada::scheme::NOT_SPECIAL;
15562|  1.50k|  bool may_need_slow_file_handling = (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (15562:39): [True: 0, False: 1.50k]
  ------------------
15563|      0|                                      checkers::is_windows_drive_letter(input));
  ------------------
  |  Branch (15563:39): [True: 0, False: 0]
  ------------------
15564|  1.50k|  bool trivial_path =
15565|  1.50k|      (special ? (accumulator == 0)
  ------------------
  |  Branch (15565:7): [True: 1.50k, False: 0]
  |  Branch (15565:8): [True: 1.50k, False: 0]
  ------------------
15566|  1.50k|               : ((accumulator & (need_encoding | dot_char | percent_char)) ==
15567|      0|                  0)) &&
15568|  1.50k|      (!may_need_slow_file_handling);
  ------------------
  |  Branch (15568:7): [True: 1.50k, False: 0]
  ------------------
15569|  1.50k|  if (accumulator == dot_char && !may_need_slow_file_handling) {
  ------------------
  |  Branch (15569:7): [True: 0, False: 1.50k]
  |  Branch (15569:34): [True: 0, False: 0]
  ------------------
15570|       |    // '4' means that we have at least one dot, but nothing that requires
15571|       |    // percent encoding or decoding. The only part that is not trivial is
15572|       |    // that we may have single dots and double dots path segments.
15573|       |    // If we have such segments, then we either have a path that begins
15574|       |    // with '.' (easy to check), or we have the sequence './'.
15575|       |    // Note: input cannot be empty, it must at least contain one character ('.')
15576|       |    // Note: we know that '\' is not present.
15577|      0|    if (input[0] != '.') {
  ------------------
  |  Branch (15577:9): [True: 0, False: 0]
  ------------------
15578|      0|      size_t slashdot = 0;
15579|      0|      bool dot_is_file = true;
15580|      0|      for (;;) {
15581|      0|        slashdot = input.find("/.", slashdot);
15582|      0|        if (slashdot == std::string_view::npos) {  // common case
  ------------------
  |  Branch (15582:13): [True: 0, False: 0]
  ------------------
15583|      0|          break;
15584|      0|        } else {  // uncommon
15585|       |          // only three cases matter: /./, /.. or a final /
15586|      0|          slashdot += 2;
15587|      0|          dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' ||
  ------------------
  |  Branch (15587:28): [True: 0, False: 0]
  |  Branch (15587:56): [True: 0, False: 0]
  ------------------
15588|      0|                           input[slashdot] == '/');
  ------------------
  |  Branch (15588:28): [True: 0, False: 0]
  ------------------
15589|      0|        }
15590|      0|      }
15591|      0|      trivial_path = dot_is_file;
15592|      0|    }
15593|      0|  }
15594|  1.50k|  if (trivial_path && is_at_path()) {
  ------------------
  |  Branch (15594:7): [True: 1.50k, False: 0]
  |  Branch (15594:23): [True: 1.50k, False: 0]
  ------------------
15595|  1.50k|    ada_log("parse_path trivial");
15596|  1.50k|    buffer += '/';
15597|  1.50k|    buffer += input;
15598|  1.50k|    return;
15599|  1.50k|  }
15600|      0|  std::string path = std::string(get_pathname());
15601|       |  // We are going to need to look a bit at the path, but let us see if we can
15602|       |  // ignore percent encoding *and* backslashes *and* percent characters.
15603|       |  // Except for the trivial case, this is likely to capture 99% of paths out
15604|       |  // there.
15605|      0|  bool fast_path =
15606|      0|      (special &&
  ------------------
  |  Branch (15606:8): [True: 0, False: 0]
  ------------------
15607|      0|       (accumulator & (need_encoding | backslash_char | percent_char)) == 0) &&
  ------------------
  |  Branch (15607:8): [True: 0, False: 0]
  ------------------
15608|      0|      (type != ada::scheme::type::FILE);
  ------------------
  |  Branch (15608:7): [True: 0, False: 0]
  ------------------
15609|      0|  if (fast_path) {
  ------------------
  |  Branch (15609:7): [True: 0, False: 0]
  ------------------
15610|      0|    ada_log("parse_prepared_path fast");
15611|       |    // Here we don't need to worry about \ or percent encoding.
15612|       |    // We also do not have a file protocol. We might have dots, however,
15613|       |    // but dots must as appear as '.', and they cannot be encoded because
15614|       |    // the symbol '%' is not present.
15615|      0|    size_t previous_location = 0;  // We start at 0.
15616|      0|    do {
15617|      0|      size_t new_location = input.find('/', previous_location);
15618|       |      // std::string_view path_view = input;
15619|       |      //  We process the last segment separately:
15620|      0|      if (new_location == std::string_view::npos) {
  ------------------
  |  Branch (15620:11): [True: 0, False: 0]
  ------------------
15621|      0|        std::string_view path_view = input.substr(previous_location);
15622|      0|        if (path_view == "..") {  // The path ends with ..
  ------------------
  |  Branch (15622:13): [True: 0, False: 0]
  ------------------
15623|       |          // e.g., if you receive ".." with an empty path, you go to "/".
15624|      0|          if (path.empty()) {
  ------------------
  |  Branch (15624:15): [True: 0, False: 0]
  ------------------
15625|      0|            path = '/';
15626|      0|            update_base_pathname(path);
15627|      0|            return;
15628|      0|          }
15629|       |          // Fast case where we have nothing to do:
15630|      0|          if (path.back() == '/') {
  ------------------
  |  Branch (15630:15): [True: 0, False: 0]
  ------------------
15631|      0|            update_base_pathname(path);
15632|      0|            return;
15633|      0|          }
15634|       |          // If you have the path "/joe/myfriend",
15635|       |          // then you delete 'myfriend'.
15636|      0|          path.resize(path.rfind('/') + 1);
15637|      0|          update_base_pathname(path);
15638|      0|          return;
15639|      0|        }
15640|      0|        path += '/';
15641|      0|        if (path_view != ".") {
  ------------------
  |  Branch (15641:13): [True: 0, False: 0]
  ------------------
15642|      0|          path.append(path_view);
15643|      0|        }
15644|      0|        update_base_pathname(path);
15645|      0|        return;
15646|      0|      } else {
15647|       |        // This is a non-final segment.
15648|      0|        std::string_view path_view =
15649|      0|            input.substr(previous_location, new_location - previous_location);
15650|      0|        previous_location = new_location + 1;
15651|      0|        if (path_view == "..") {
  ------------------
  |  Branch (15651:13): [True: 0, False: 0]
  ------------------
15652|      0|          size_t last_delimiter = path.rfind('/');
15653|      0|          if (last_delimiter != std::string::npos) {
  ------------------
  |  Branch (15653:15): [True: 0, False: 0]
  ------------------
15654|      0|            path.erase(last_delimiter);
15655|      0|          }
15656|      0|        } else if (path_view != ".") {
  ------------------
  |  Branch (15656:20): [True: 0, False: 0]
  ------------------
15657|      0|          path += '/';
15658|      0|          path.append(path_view);
15659|      0|        }
15660|      0|      }
15661|      0|    } while (true);
  ------------------
  |  Branch (15661:14): [True: 0, Folded]
  ------------------
15662|      0|  } else {
15663|      0|    ada_log("parse_path slow");
15664|       |    // we have reached the general case
15665|      0|    bool needs_percent_encoding = (accumulator & 1);
15666|      0|    do {
15667|      0|      size_t location = (special && (accumulator & 2))
  ------------------
  |  Branch (15667:26): [True: 0, False: 0]
  |  Branch (15667:37): [True: 0, False: 0]
  ------------------
15668|      0|                            ? input.find_first_of("/\\")
15669|      0|                            : input.find('/');
15670|      0|      std::string_view path_view = input;
15671|      0|      if (location != std::string_view::npos) {
  ------------------
  |  Branch (15671:11): [True: 0, False: 0]
  ------------------
15672|      0|        path_view.remove_suffix(path_view.size() - location);
15673|      0|        input.remove_prefix(location + 1);
15674|      0|      }
15675|       |      // Path encoding preserves dots and percent signs, so normalize first.
15676|      0|      if (unicode::is_double_dot_path_segment(path_view)) {
  ------------------
  |  Branch (15676:11): [True: 0, False: 0]
  ------------------
15677|      0|        helpers::shorten_path(path, type);
15678|      0|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (15678:13): [True: 0, False: 0]
  ------------------
15679|      0|          path += '/';
15680|      0|        }
15681|      0|      } else if (unicode::is_single_dot_path_segment(path_view) &&
  ------------------
  |  Branch (15681:18): [True: 0, False: 0]
  ------------------
15682|      0|                 (location == std::string_view::npos)) {
  ------------------
  |  Branch (15682:18): [True: 0, False: 0]
  ------------------
15683|      0|        path += '/';
15684|      0|      }
15685|       |      // Otherwise, if path_view is not a single-dot path segment, then:
15686|      0|      else if (!unicode::is_single_dot_path_segment(path_view)) {
  ------------------
  |  Branch (15686:16): [True: 0, False: 0]
  ------------------
15687|       |        // If url's scheme is "file", url's path is empty, and path_view is a
15688|       |        // Windows drive letter, then replace the second code point in
15689|       |        // path_view with U+003A (:).
15690|      0|        if (type == ada::scheme::type::FILE && path.empty() &&
  ------------------
  |  Branch (15690:13): [True: 0, False: 0]
  |  Branch (15690:48): [True: 0, False: 0]
  ------------------
15691|      0|            path_view.size() == 2 &&
  ------------------
  |  Branch (15691:13): [True: 0, False: 0]
  ------------------
15692|      0|            checkers::is_windows_drive_letter(path_view)) {
  ------------------
  |  Branch (15692:13): [True: 0, False: 0]
  ------------------
15693|      0|          path += '/';
15694|      0|          path += path_view[0];
15695|      0|          path += ':';
15696|      0|          path_view.remove_prefix(2);
15697|      0|          path.append(path_view);
15698|      0|        } else {
15699|       |          // Append encoded bytes directly to the pathname.
15700|      0|          path += '/';
15701|      0|          if (!needs_percent_encoding ||
  ------------------
  |  Branch (15701:15): [True: 0, False: 0]
  ------------------
15702|      0|              !ada::unicode::percent_encode<true>(
  ------------------
  |  Branch (15702:15): [True: 0, False: 0]
  ------------------
15703|      0|                  path_view, character_sets::PATH_PERCENT_ENCODE, path)) {
15704|      0|            path.append(path_view);
15705|      0|          }
15706|      0|        }
15707|      0|      }
15708|      0|      if (location == std::string_view::npos) {
  ------------------
  |  Branch (15708:11): [True: 0, False: 0]
  ------------------
15709|      0|        update_base_pathname(path);
15710|      0|        return;
15711|      0|      }
15712|      0|    } while (true);
  ------------------
  |  Branch (15712:14): [True: 0, Folded]
  ------------------
15713|      0|  }
15714|      0|}
_ZN3ada8checkers7is_ipv4ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
   14|    491|ada_really_inline constexpr bool is_ipv4(std::string_view view) noexcept {
   15|       |  // The string is not empty and does not contain upper case ASCII characters.
   16|    491|  if (!last_label_may_be_a_number(view)) {
  ------------------
  |  Branch (16:7): [True: 491, False: 0]
  ------------------
   17|    491|    return false;
   18|    491|  }
   19|       |  // If the address ends with a dot, we need to prune it (special case).
   20|      0|  if (view.ends_with('.')) {
  ------------------
  |  Branch (20:7): [True: 0, False: 0]
  ------------------
   21|      0|    view.remove_suffix(1);
   22|      0|  }
   23|       |  // From the last character, find the last dot.
   24|      0|  size_t last_dot = view.rfind('.');
   25|      0|  if (last_dot != std::string_view::npos) {
  ------------------
  |  Branch (25:7): [True: 0, False: 0]
  ------------------
   26|       |    // We have at least one dot.
   27|      0|    view.remove_prefix(last_dot + 1);
   28|      0|  }
   29|       |  /** Optimization opportunity: we have basically identified the last number of
   30|       |     the ipv4 if we return true here. We might as well parse it and have at
   31|       |     least one number parsed when we get to parse_ipv4. */
   32|      0|  if (std::ranges::all_of(view, ada::checkers::is_digit)) {
  ------------------
  |  Branch (32:7): [True: 0, False: 0]
  ------------------
   33|      0|    return true;
   34|      0|  }
   35|       |  // It could be hex (0x), but not if there is a single character.
   36|      0|  if (view.size() == 1) {
  ------------------
  |  Branch (36:7): [True: 0, False: 0]
  ------------------
   37|      0|    return false;
   38|      0|  }
   39|       |  // It must start with 0x.
   40|      0|  if (!view.starts_with("0x")) {
  ------------------
  |  Branch (40:7): [True: 0, False: 0]
  ------------------
   41|      0|    return false;
   42|      0|  }
   43|       |  // We must allow "0x".
   44|      0|  if (view.size() == 2) {
  ------------------
  |  Branch (44:7): [True: 0, False: 0]
  ------------------
   45|      0|    return true;
   46|      0|  }
   47|       |  // We have 0x followed by some characters, we need to check that they are
   48|       |  // hexadecimals.
   49|      0|  view.remove_prefix(2);
   50|      0|  return std::ranges::all_of(view, ada::unicode::is_lowercase_hex);
   51|      0|}
_ZN3ada14url_aggregator23parse_scheme_with_colonILb0EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE:
14028|    491|    const std::string_view input_with_colon) {
14029|    491|  ada_log("url_aggregator::parse_scheme_with_colon ", input_with_colon);
14030|    491|  ADA_ASSERT_TRUE(validate());
14031|    491|  ADA_ASSERT_TRUE(!helpers::overlaps(input_with_colon, buffer));
14032|    491|  std::string_view input{input_with_colon};
14033|    491|  input.remove_suffix(1);
14034|    491|  auto parsed_type = ada::scheme::get_scheme_type(input);
14035|    491|  const bool is_input_special = (parsed_type != ada::scheme::NOT_SPECIAL);
14036|       |  /**
14037|       |   * In the common case, we will immediately recognize a special scheme (e.g.,
14038|       |   *http, https), in which case, we can go really fast.
14039|       |   **/
14040|    491|  if (is_input_special) {  // fast path!!!
  ------------------
  |  Branch (14040:7): [True: 491, False: 0]
  ------------------
14041|       |    if constexpr (has_state_override) {
14042|       |      // If url's scheme is not a special scheme and buffer is a special scheme,
14043|       |      // then return.
14044|       |      if (is_special() != is_input_special) {
14045|       |        return false;
14046|       |      }
14047|       |
14048|       |      // If url includes credentials or has a non-null port, and buffer is
14049|       |      // "file", then return.
14050|       |      if ((has_credentials() || components.port != url_components::omitted) &&
14051|       |          parsed_type == ada::scheme::type::FILE) {
14052|       |        return false;
14053|       |      }
14054|       |
14055|       |      // If url's scheme is "file" and its host is an empty host, then return.
14056|       |      // An empty host is the empty string.
14057|       |      if (type == ada::scheme::type::FILE &&
14058|       |          components.host_start == components.host_end) {
14059|       |        return false;
14060|       |      }
14061|       |    }
14062|       |
14063|    491|    type = parsed_type;
14064|    491|    set_scheme_from_view_with_colon(input_with_colon);
14065|       |
14066|       |    if constexpr (has_state_override) {
14067|       |      // This is uncommon.
14068|       |      uint16_t urls_scheme_port = get_special_port();
14069|       |
14070|       |      if (urls_scheme_port) {
14071|       |        // If url's port is url's scheme's default port, then set url's port to
14072|       |        // null.
14073|       |        if (components.port == urls_scheme_port) {
14074|       |          clear_port();
14075|       |        }
14076|       |      }
14077|       |    }
14078|    491|  } else {  // slow path
14079|      0|    std::string _buffer(input);
14080|       |    // Next function is only valid if the input is ASCII and returns false
14081|       |    // otherwise, but it seems that we always have ascii content so we do not
14082|       |    // need to check the return value.
14083|      0|    unicode::to_lower_ascii(_buffer.data(), _buffer.size());
14084|       |
14085|       |    if constexpr (has_state_override) {
14086|       |      // The state-override validation errors below ("return" in the WHATWG URL
14087|       |      // parser) leave the URL unchanged. The setter contract is
14088|       |      // "true on success, false if the scheme is invalid" -- the fast path
14089|       |      // above already returns false here, so the slow path must agree.
14090|       |
14091|       |      // If url's scheme is a special scheme and buffer is not a special scheme,
14092|       |      // then return. If url's scheme is not a special scheme and buffer is a
14093|       |      // special scheme, then return.
14094|       |      if (is_special() != ada::scheme::is_special(_buffer)) {
14095|       |        return false;
14096|       |      }
14097|       |
14098|       |      // If url includes credentials or has a non-null port, and buffer is
14099|       |      // "file", then return.
14100|       |      if ((has_credentials() || components.port != url_components::omitted) &&
14101|       |          _buffer == "file") {
14102|       |        return false;
14103|       |      }
14104|       |
14105|       |      // If url's scheme is "file" and its host is an empty host, then return.
14106|       |      // An empty host is the empty string.
14107|       |      if (type == ada::scheme::type::FILE &&
14108|       |          components.host_start == components.host_end) {
14109|       |        return false;
14110|       |      }
14111|       |    }
14112|       |
14113|      0|    set_scheme(_buffer);
14114|       |
14115|       |    if constexpr (has_state_override) {
14116|       |      // This is uncommon.
14117|       |      uint16_t urls_scheme_port = get_special_port();
14118|       |
14119|       |      if (urls_scheme_port) {
14120|       |        // If url's port is url's scheme's default port, then set url's port to
14121|       |        // null.
14122|       |        if (components.port == urls_scheme_port) {
14123|       |          clear_port();
14124|       |        }
14125|       |      }
14126|       |    }
14127|      0|  }
14128|    491|  ADA_ASSERT_TRUE(validate());
14129|    491|  return true;
14130|    491|}
_ZN3ada14url_aggregator31set_scheme_from_view_with_colonENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14154|    491|    std::string_view new_scheme_with_colon) {
14155|    491|  ada_log("url_aggregator::set_scheme_from_view_with_colon ",
14156|    491|          new_scheme_with_colon);
14157|    491|  ADA_ASSERT_TRUE(validate());
14158|    491|  ADA_ASSERT_TRUE(!new_scheme_with_colon.empty() &&
14159|    491|                  new_scheme_with_colon.back() == ':');
14160|       |  // next line could overflow but unsigned arithmetic has well-defined
14161|       |  // overflows.
14162|    491|  uint32_t new_difference =
14163|    491|      uint32_t(new_scheme_with_colon.size()) - components.protocol_end;
14164|       |
14165|    491|  if (buffer.empty()) {
  ------------------
  |  Branch (14165:7): [True: 491, False: 0]
  ------------------
14166|    491|    buffer.append(new_scheme_with_colon);
14167|    491|  } else {
14168|      0|    buffer.erase(0, components.protocol_end);
14169|      0|    buffer.insert(0, new_scheme_with_colon);
14170|      0|  }
14171|    491|  components.protocol_end += new_difference;
14172|       |
14173|    491|  apply_shifted_non_scheme_offsets(components, new_difference);
14174|    491|  ADA_ASSERT_TRUE(validate());
14175|    491|}
_ZN3ada7helpers38strip_trailing_spaces_from_opaque_pathINS_14url_aggregatorEEEvRT_:
 9778|  1.35k|ada_really_inline void strip_trailing_spaces_from_opaque_path(url_type& url) {
 9779|  1.35k|  ada_log("helpers::strip_trailing_spaces_from_opaque_path");
 9780|  1.35k|  if (!url.has_opaque_path) return;
  ------------------
  |  Branch (9780:7): [True: 1.35k, False: 0]
  ------------------
 9781|      0|  if (url.has_hash()) return;
  ------------------
  |  Branch (9781:7): [True: 0, False: 0]
  ------------------
 9782|      0|  if (url.has_search()) return;
  ------------------
  |  Branch (9782:7): [True: 0, False: 0]
  ------------------
 9783|       |
 9784|      0|  auto path = std::string(url.get_pathname());
 9785|      0|  while (!path.empty() && path.back() == ' ') {
  ------------------
  |  Branch (9785:10): [True: 0, False: 0]
  |  Branch (9785:27): [True: 0, False: 0]
  ------------------
 9786|      0|    path.resize(path.size() - 1);
 9787|      0|  }
 9788|      0|  url.update_base_pathname(path);
 9789|      0|}

_ZN3ada37url_pattern_compile_component_optionsC2ENSt3__18optionalIcEES3_:
 6341|      6|      : delimiter(new_delimiter), prefix(new_prefix) {}
_ZN3ada14character_sets6bit_atEPKhh:
 1086|   480k|ada_really_inline constexpr bool bit_at(const uint8_t a[], const uint8_t i) {
 1087|   480k|  return !!(a[i >> 3] & (1 << (i & 7)));
 1088|   480k|}
_ZN3ada8url_baseD2Ev:
 2184|  5.86k|  virtual ~url_base() = default;
_ZN2tl6detail26expected_default_ctor_baseIN3ada14url_aggregatorENS2_6errorsELb1EEC2ENS0_23default_constructor_tagE:
 3778|  2.93k|  constexpr explicit expected_default_ctor_base(default_constructor_tag) {}
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEC2IS2_TnPNSt3__19enable_ifIXsr3std14is_convertibleIOT_S2_EE5valueEvE4typeELPv0ETnPNS7_IXaaaaaasr3std16is_constructibleIS2_S9_EE5valuentsr3std7is_sameINS6_5decayIS8_E4typeENS_10in_place_tEEE5valuentsr3std7is_sameIS4_SG_EE5valuentsr3std7is_sameINS_10unexpectedIS3_EESG_EE5valueEvE4typeELSD_0EEES9_:
 4260|  2.93k|      : expected(in_place, std::forward<U>(v)) {}
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEC2IJS2_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS2_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESA_:
 4133|  2.93k|      : impl_base(in_place, std::forward<Args>(args)...),
 4134|  2.93k|        ctor_base(detail::default_constructor_tag{}) {}
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EEC2IJS3_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESB_:
 3148|  2.93k|      : m_val(std::forward<Args>(args)...), m_has_val(true) {}
_ZN3ada14url_aggregatorC2EOS0_:
 8424|  2.93k|  url_aggregator(url_aggregator&& u) noexcept = default;
_ZN3ada14url_aggregatorD2Ev:
 8427|  5.86k|  ~url_aggregator() override = default;
_ZN3ada6scheme15get_scheme_typeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7425|    491|constexpr ada::scheme::type get_scheme_type(std::string_view scheme) noexcept {
 7426|    491|  if (scheme.empty()) {
  ------------------
  |  Branch (7426:7): [True: 0, False: 491]
  ------------------
 7427|      0|    return ada::scheme::NOT_SPECIAL;
 7428|      0|  }
 7429|    491|  int hash_value = (2 * scheme.size() + (unsigned)(scheme[0])) & 7;
 7430|    491|  const std::string_view target = details::is_special_list[hash_value];
 7431|    491|  if (scheme.size() == target.size() &&
  ------------------
  |  Branch (7431:7): [True: 491, False: 0]
  ------------------
 7432|    491|      details::branchless_load5(scheme.data(), scheme.size()) ==
  ------------------
  |  Branch (7432:7): [True: 491, False: 0]
  ------------------
 7433|    491|          details::scheme_keys[hash_value]) {
 7434|    491|    return ada::scheme::type(hash_value);
 7435|    491|  } else {
 7436|      0|    return ada::scheme::NOT_SPECIAL;
 7437|      0|  }
 7438|    491|}
_ZN3ada6scheme7details16branchless_load5EPKcm:
 7366|    491|inline uint64_t branchless_load5(const char* p, size_t n) {
 7367|    491|  uint64_t input = (uint8_t)p[0];
 7368|    491|  input |= ((uint64_t)(uint8_t)p[n > 1] << 8) & (0 - (uint64_t)(n > 1));
 7369|    491|  input |= ((uint64_t)(uint8_t)p[(n > 2) * 2] << 16) & (0 - (uint64_t)(n > 2));
 7370|    491|  input |= ((uint64_t)(uint8_t)p[(n > 3) * 3] << 24) & (0 - (uint64_t)(n > 3));
 7371|    491|  input |= ((uint64_t)(uint8_t)p[(n > 4) * 4] << 32) & (0 - (uint64_t)(n > 4));
 7372|    491|  return input;
 7373|    491|}
_ZN3ada14url_aggregatorC2Ev:
 8422|  2.93k|  url_aggregator() = default;
_ZN3ada14url_componentsC2Ev:
 5489|  2.93k|  url_components() = default;
_ZN3ada8checkers19try_parse_ipv4_fastENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1930|    491|try_parse_ipv4_fast(std::string_view input) noexcept {
 1931|    491|  const size_t len = input.size();
 1932|       |  // Shortest pure decimal: "0.0.0.0" (7). Longest + trailing dot: 16.
 1933|    491|  if (len < 7 || len > 16) [[unlikely]] {
  ------------------
  |  Branch (1933:7): [True: 0, False: 491]
  |  Branch (1933:18): [True: 0, False: 491]
  ------------------
 1934|      0|    return ipv4_fast_fail;
 1935|      0|  }
 1936|    491|  const char* data = input.data();
 1937|       |
 1938|       |#if defined(ADA_AVX512_IPV4)
 1939|       |  return detail::try_parse_ipv4_avx512(data, len);
 1940|       |#elif defined(ADA_HYBRID_IPV4)
 1941|       |  return detail::try_parse_ipv4_hybrid(data, len);
 1942|       |#else
 1943|    491|  return detail::parse_ipv4_decimal_scalar(data, data + len);
 1944|    491|#endif
 1945|    491|}
_ZN3ada8checkers6detail25parse_ipv4_decimal_scalarEPKcS3_:
 1579|    491|parse_ipv4_decimal_scalar(const char* p, const char* pend) noexcept {
 1580|    491|  uint32_t ipv4 = 0;
 1581|    491|  for (int i = 0; i < 4; ++i) {
  ------------------
  |  Branch (1581:19): [True: 491, False: 0]
  ------------------
 1582|    491|    if (p == pend) [[unlikely]] {
  ------------------
  |  Branch (1582:9): [True: 0, False: 491]
  ------------------
 1583|      0|      return ipv4_fast_fail;
 1584|      0|    }
 1585|    491|    uint32_t val;
 1586|    491|    char c = *p;
 1587|    491|    if (c >= '0' && c <= '9') [[likely]] {
  ------------------
  |  Branch (1587:9): [True: 491, False: 0]
  |  Branch (1587:21): [True: 0, False: 491]
  ------------------
 1588|      0|      val = static_cast<uint32_t>(c - '0');
 1589|      0|      ++p;
 1590|    491|    } else {
 1591|    491|      return ipv4_fast_fail;
 1592|    491|    }
 1593|      0|    if (p < pend) {
  ------------------
  |  Branch (1593:9): [True: 0, False: 0]
  ------------------
 1594|      0|      c = *p;
 1595|      0|      if (c >= '0' && c <= '9') {
  ------------------
  |  Branch (1595:11): [True: 0, False: 0]
  |  Branch (1595:23): [True: 0, False: 0]
  ------------------
 1596|      0|        if (val == 0) [[unlikely]] {
  ------------------
  |  Branch (1596:13): [True: 0, False: 0]
  ------------------
 1597|      0|          return ipv4_fast_fail;
 1598|      0|        }
 1599|      0|        val = val * 10u + static_cast<uint32_t>(c - '0');
 1600|      0|        ++p;
 1601|      0|        if (p < pend) {
  ------------------
  |  Branch (1601:13): [True: 0, False: 0]
  ------------------
 1602|      0|          c = *p;
 1603|      0|          if (c >= '0' && c <= '9') {
  ------------------
  |  Branch (1603:15): [True: 0, False: 0]
  |  Branch (1603:27): [True: 0, False: 0]
  ------------------
 1604|      0|            val = val * 10u + static_cast<uint32_t>(c - '0');
 1605|      0|            ++p;
 1606|      0|            if (val > 255u) [[unlikely]] {
  ------------------
  |  Branch (1606:17): [True: 0, False: 0]
  ------------------
 1607|      0|              return ipv4_fast_fail;
 1608|      0|            }
 1609|      0|          }
 1610|      0|        }
 1611|      0|      }
 1612|      0|    }
 1613|      0|    ipv4 = (ipv4 << 8) | val;
 1614|      0|    if (i < 3) {
  ------------------
  |  Branch (1614:9): [True: 0, False: 0]
  ------------------
 1615|      0|      if (p == pend || *p != '.') [[unlikely]] {
  ------------------
  |  Branch (1615:11): [True: 0, False: 0]
  |  Branch (1615:24): [True: 0, False: 0]
  ------------------
 1616|      0|        return ipv4_fast_fail;
 1617|      0|      }
 1618|      0|      ++p;
 1619|      0|    }
 1620|      0|  }
 1621|      0|  if (p != pend) {
  ------------------
  |  Branch (1621:7): [True: 0, False: 0]
  ------------------
 1622|      0|    if (p == pend - 1 && *p == '.') {
  ------------------
  |  Branch (1622:9): [True: 0, False: 0]
  |  Branch (1622:26): [True: 0, False: 0]
  ------------------
 1623|      0|      return ipv4;
 1624|      0|    }
 1625|      0|    return ipv4_fast_fail;
 1626|      0|  }
 1627|      0|  return ipv4;
 1628|      0|}
_ZNK3ada8url_base10is_specialEv:
 7913|  5.59k|    const noexcept {
 7914|  5.59k|  return type != ada::scheme::NOT_SPECIAL;
 7915|  5.59k|}
_ZN3ada8checkers8is_alphaEc:
 1559|    491|constexpr bool is_alpha(char x) noexcept {
 1560|    491|  return (to_lower(x) >= 'a') && (to_lower(x) <= 'z');
  ------------------
  |  Branch (1560:10): [True: 491, False: 0]
  |  Branch (1560:34): [True: 491, False: 0]
  ------------------
 1561|    491|}
_ZN3ada8checkers8to_lowerEc:
 1557|    982|constexpr char to_lower(char x) noexcept { return (x | 0x20); }
_ZN3ada8checkers26last_label_may_be_a_numberENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1532|  3.42k|constexpr bool last_label_may_be_a_number(std::string_view view) noexcept {
 1533|  3.42k|  if (view.empty()) {
  ------------------
  |  Branch (1533:7): [True: 0, False: 3.42k]
  ------------------
 1534|      0|    return false;
 1535|      0|  }
 1536|  3.42k|  const char* start = view.data();
 1537|  3.42k|  const char* end = start + view.size();
 1538|  3.42k|  if (end[-1] == '.') {
  ------------------
  |  Branch (1538:7): [True: 0, False: 3.42k]
  ------------------
 1539|      0|    --end;
 1540|      0|    if (end == start) {
  ------------------
  |  Branch (1540:9): [True: 0, False: 0]
  ------------------
 1541|      0|      return false;
 1542|      0|    }
 1543|      0|  }
 1544|  3.42k|  if (!is_ipv4_number_char(end[-1])) {
  ------------------
  |  Branch (1544:7): [True: 3.42k, False: 0]
  ------------------
 1545|  3.42k|    return false;
 1546|  3.42k|  }
 1547|      0|  const char* label = end;
 1548|      0|  while (label != start && is_ipv4_number_char(label[-1])) {
  ------------------
  |  Branch (1548:10): [True: 0, False: 0]
  |  Branch (1548:28): [True: 0, False: 0]
  ------------------
 1549|      0|    --label;
 1550|      0|  }
 1551|      0|  if (label != start && label[-1] != '.') {
  ------------------
  |  Branch (1551:7): [True: 0, False: 0]
  |  Branch (1551:25): [True: 0, False: 0]
  ------------------
 1552|      0|    return false;
 1553|      0|  }
 1554|      0|  return label != end && is_digit(*label);
  ------------------
  |  Branch (1554:10): [True: 0, False: 0]
  |  Branch (1554:26): [True: 0, False: 0]
  ------------------
 1555|      0|}
_ZN3ada8checkers19is_ipv4_number_charEc:
 1526|  3.42k|constexpr bool is_ipv4_number_char(char x) noexcept {
 1527|  3.42k|  const unsigned char c = static_cast<unsigned char>(x);
 1528|  3.42k|  return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
  ------------------
  |  Branch (1528:11): [True: 3.42k, False: 0]
  |  Branch (1528:23): [True: 0, False: 3.42k]
  |  Branch (1528:37): [True: 3.42k, False: 0]
  |  Branch (1528:49): [True: 0, False: 3.42k]
  ------------------
 1529|  3.42k|         (c >= 'A' && c <= 'F') || c == 'x' || c == 'X';
  ------------------
  |  Branch (1529:11): [True: 3.42k, False: 0]
  |  Branch (1529:23): [True: 0, False: 3.42k]
  |  Branch (1529:36): [True: 0, False: 3.42k]
  |  Branch (1529:48): [True: 0, False: 3.42k]
  ------------------
 1530|  3.42k|}
_ZN3ada14url_aggregator18replace_and_resizeEjjNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8997|    743|    uint32_t start, uint32_t end, std::string_view input) {
 8998|    743|  uint32_t current_length = end - start;
 8999|    743|  uint32_t input_size = uint32_t(input.size());
 9000|    743|  uint32_t new_difference = input_size - current_length;
 9001|       |
 9002|    743|  if (current_length == 0) {
  ------------------
  |  Branch (9002:7): [True: 491, False: 252]
  ------------------
 9003|    491|    buffer.insert(start, input);
 9004|    491|  } else if (input_size == current_length) {
  ------------------
  |  Branch (9004:14): [True: 4, False: 248]
  ------------------
 9005|      4|    if (input_size != 0) {
  ------------------
  |  Branch (9005:9): [True: 4, False: 0]
  ------------------
 9006|      4|      std::memmove(buffer.data() + start, input.data(), input_size);
 9007|      4|    }
 9008|    248|  } else if (input_size < current_length) {
  ------------------
  |  Branch (9008:14): [True: 71, False: 177]
  ------------------
 9009|     71|    buffer.erase(start, current_length - input_size);
 9010|     71|    buffer.replace(start, input_size, input);
 9011|    177|  } else {
 9012|    177|    buffer.replace(start, current_length, input.substr(0, current_length));
 9013|    177|    buffer.insert(start + current_length, input.substr(current_length));
 9014|    177|  }
 9015|       |
 9016|    743|  return new_difference;
 9017|    743|}
_ZN3ada14url_aggregator26update_unencoded_base_hashENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8973|    353|inline void url_aggregator::update_unencoded_base_hash(std::string_view input) {
 8974|    353|  ada_log("url_aggregator::update_unencoded_base_hash ", input, " [",
 8975|    353|          input.size(), " bytes], buffer is '", buffer, "' [", buffer.size(),
 8976|    353|          " bytes] components.hash_start = ", components.hash_start);
 8977|    353|  ADA_ASSERT_TRUE(validate());
 8978|    353|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8979|    353|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8979:7): [True: 0, False: 353]
  ------------------
 8980|      0|    buffer.resize(components.hash_start);
 8981|      0|  }
 8982|    353|  components.hash_start = uint32_t(buffer.size());
 8983|    353|  buffer += "#";
 8984|    353|  bool encoding_required = unicode::percent_encode<true>(
 8985|    353|      input, ada::character_sets::FRAGMENT_PERCENT_ENCODE, buffer);
 8986|       |  // When encoding_required is false, then buffer is left unchanged, and percent
 8987|       |  // encoding was not deemed required.
 8988|    353|  if (!encoding_required) {
  ------------------
  |  Branch (8988:7): [True: 165, False: 188]
  ------------------
 8989|    165|    buffer.append(input);
 8990|    165|  }
 8991|    353|  ada_log("url_aggregator::update_unencoded_base_hash final buffer is '",
 8992|    353|          buffer, "' [", buffer.size(), " bytes]");
 8993|    353|  ADA_ASSERT_TRUE(validate());
 8994|    353|}
_ZN3ada7helpers14leading_zeroesEj:
 2473|    491|inline int leading_zeroes(uint32_t input_num) noexcept {
 2474|       |#if ADA_REGULAR_VISUAL_STUDIO
 2475|       |  unsigned long leading_zero(0);
 2476|       |  unsigned long in(input_num);
 2477|       |  return _BitScanReverse(&leading_zero, in) ? int(31 - leading_zero) : 32;
 2478|       |#else
 2479|    491|  return __builtin_clz(input_num);
 2480|    491|#endif  // ADA_REGULAR_VISUAL_STUDIO
 2481|    491|}
_ZN3ada14url_aggregator7reserveEj:
 9663|    491|constexpr void ada::url_aggregator::reserve(uint32_t capacity) {
 9664|    491|  buffer.reserve(capacity);
 9665|    491|}
_ZN3ada14url_aggregator31add_authority_slashes_if_neededEv:
 9637|    491|inline void ada::url_aggregator::add_authority_slashes_if_needed() {
 9638|    491|  ada_log("url_aggregator::add_authority_slashes_if_needed");
 9639|    491|  ADA_ASSERT_TRUE(validate());
 9640|       |  // Protocol setter will insert `http:` to the URL. It is up to hostname setter
 9641|       |  // to insert
 9642|       |  // `//` initially to the buffer, since it depends on the hostname existence.
 9643|    491|  if (has_authority()) {
  ------------------
  |  Branch (9643:7): [True: 0, False: 491]
  ------------------
 9644|      0|    return;
 9645|      0|  }
 9646|       |  // Performance: the common case is components.protocol_end == buffer.size()
 9647|       |  // Optimization opportunity: in many cases, the "//" is part of the input and
 9648|       |  // the insert could be fused with another insert.
 9649|    491|  buffer.insert(components.protocol_end, "//");
 9650|    491|  components.username_end += 2;
 9651|    491|  components.host_start += 2;
 9652|    491|  components.host_end += 2;
 9653|    491|  components.pathname_start += 2;
 9654|    491|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9654:7): [True: 0, False: 491]
  ------------------
 9655|      0|    components.search_start += 2;
 9656|      0|  }
 9657|    491|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9657:7): [True: 0, False: 491]
  ------------------
 9658|      0|    components.hash_start += 2;
 9659|      0|  }
 9660|    491|  ADA_ASSERT_TRUE(validate());
 9661|    491|}
_ZN3ada14url_aggregator12clear_searchEv:
 9487|  1.35k|inline void url_aggregator::clear_search() {
 9488|  1.35k|  ada_log("url_aggregator::clear_search");
 9489|  1.35k|  ADA_ASSERT_TRUE(validate());
 9490|  1.35k|  if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (9490:7): [True: 0, False: 1.35k]
  ------------------
 9491|      0|    return;
 9492|      0|  }
 9493|       |
 9494|  1.35k|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (9494:7): [True: 1.17k, False: 185]
  ------------------
 9495|  1.17k|    buffer.resize(components.search_start);
 9496|  1.17k|  } else {
 9497|    185|    buffer.erase(components.search_start,
 9498|    185|                 components.hash_start - components.search_start);
 9499|    185|    components.hash_start = components.search_start;
 9500|    185|  }
 9501|       |
 9502|  1.35k|  components.search_start = url_components::omitted;
 9503|       |
 9504|       |#if ADA_DEVELOPMENT_CHECKS
 9505|       |  ADA_ASSERT_EQUAL(get_search(), "",
 9506|       |                   "search should have been cleared on buffer=" + buffer +
 9507|       |                       " with " + components.to_string() + "\n" + to_diagram());
 9508|       |#endif
 9509|  1.35k|  ADA_ASSERT_TRUE(validate());
 9510|  1.35k|}
_ZN3ada14url_aggregator18update_base_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 9104|  3.07k|    std::string_view input, const uint8_t query_percent_encode_set[]) {
 9105|  3.07k|  ada_log("url_aggregator::update_base_search ", input,
 9106|  3.07k|          " with encoding parameter ", to_string(), "\n", to_diagram());
 9107|  3.07k|  ADA_ASSERT_TRUE(validate());
 9108|  3.07k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 9109|       |
 9110|  3.07k|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (9110:7): [True: 2.82k, False: 252]
  ------------------
 9111|  2.82k|    if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (9111:9): [True: 1.50k, False: 1.32k]
  ------------------
 9112|  1.50k|      components.search_start = uint32_t(buffer.size());
 9113|  1.50k|      buffer += "?";
 9114|  1.50k|    } else {
 9115|  1.32k|      buffer.resize(components.search_start + 1);
 9116|  1.32k|    }
 9117|       |
 9118|  2.82k|    bool encoding_required =
 9119|  2.82k|        unicode::percent_encode<true>(input, query_percent_encode_set, buffer);
 9120|       |    // When encoding_required is false, then buffer is left unchanged, and
 9121|       |    // percent encoding was not deemed required.
 9122|  2.82k|    if (!encoding_required) {
  ------------------
  |  Branch (9122:9): [True: 1.63k, False: 1.18k]
  ------------------
 9123|  1.63k|      buffer.append(input);
 9124|  1.63k|    }
 9125|  2.82k|  } else {
 9126|    252|    const size_t idx =
 9127|    252|        ada::unicode::percent_encode_index(input, query_percent_encode_set);
 9128|    252|    std::string encoded;
 9129|    252|    std::string_view replacement = input;
 9130|    252|    if (idx != input.size()) {
  ------------------
  |  Branch (9130:9): [True: 0, False: 252]
  ------------------
 9131|      0|      encoded =
 9132|      0|          ada::unicode::percent_encode(input, query_percent_encode_set, idx);
 9133|      0|      replacement = encoded;
 9134|      0|    }
 9135|       |
 9136|    252|    if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9136:9): [True: 252, False: 0]
  ------------------
 9137|    252|      const uint32_t difference = replace_and_resize(
 9138|    252|          components.search_start + 1, components.hash_start, replacement);
 9139|    252|      components.hash_start += difference;
 9140|    252|    } else {
 9141|      0|      components.search_start = components.hash_start;
 9142|      0|      buffer.insert(components.search_start, replacement.size() + 1, '?');
 9143|      0|      if (!replacement.empty()) {
  ------------------
  |  Branch (9143:11): [True: 0, False: 0]
  ------------------
 9144|      0|        std::memmove(buffer.data() + components.search_start + 1,
 9145|      0|                     replacement.data(), replacement.size());
 9146|      0|      }
 9147|      0|      components.hash_start +=
 9148|      0|          uint32_t(replacement.size() + 1);  // Do not forget `?`
 9149|      0|    }
 9150|    252|  }
 9151|       |
 9152|  3.07k|  ADA_ASSERT_TRUE(validate());
 9153|  3.07k|}
_ZN3ada14url_aggregator20update_base_hostnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9019|    491|inline void url_aggregator::update_base_hostname(const std::string_view input) {
 9020|    491|  ada_log("url_aggregator::update_base_hostname ", input, " [", input.size(),
 9021|    491|          " bytes], buffer is '", buffer, "' [", buffer.size(), " bytes]");
 9022|    491|  ADA_ASSERT_TRUE(validate());
 9023|    491|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 9024|       |
 9025|       |  // This next line is required for when parsing a URL like `foo://`
 9026|    491|  add_authority_slashes_if_needed();
 9027|       |
 9028|    491|  bool has_credentials = components.protocol_end + 2 < components.host_start;
 9029|    491|  uint32_t new_difference =
 9030|    491|      replace_and_resize(components.host_start, components.host_end, input);
 9031|       |
 9032|    491|  if (has_credentials) {
  ------------------
  |  Branch (9032:7): [True: 0, False: 491]
  ------------------
 9033|      0|    buffer.insert(components.host_start, "@");
 9034|      0|    new_difference++;
 9035|      0|  }
 9036|    491|  components.host_end += new_difference;
 9037|    491|  components.pathname_start += new_difference;
 9038|    491|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9038:7): [True: 0, False: 491]
  ------------------
 9039|      0|    components.search_start += new_difference;
 9040|      0|  }
 9041|    491|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9041:7): [True: 0, False: 491]
  ------------------
 9042|      0|    components.hash_start += new_difference;
 9043|      0|  }
 9044|    491|  ADA_ASSERT_TRUE(validate());
 9045|    491|}
_ZN3ada7unicode20percent_encode_indexENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 8871|    252|                                              const uint8_t character_set[]) {
 8872|    252|  const char* data = input.data();
 8873|    252|  const size_t size = input.size();
 8874|       |
 8875|       |  // Process 8 bytes at a time using unrolled loop
 8876|    252|  size_t i = 0;
 8877|  3.71k|  for (; i + 8 <= size; i += 8) {
  ------------------
  |  Branch (8877:10): [True: 3.46k, False: 252]
  ------------------
 8878|  3.46k|    unsigned char chunk[8];
 8879|  3.46k|    std::memcpy(&chunk, data + i,
 8880|  3.46k|                8);  // entices compiler to unconditionally process 8 characters
 8881|       |
 8882|       |    // Check 8 characters at once
 8883|  31.1k|    for (size_t j = 0; j < 8; j++) {
  ------------------
  |  Branch (8883:24): [True: 27.7k, False: 3.46k]
  ------------------
 8884|  27.7k|      if (character_sets::bit_at(character_set, chunk[j])) {
  ------------------
  |  Branch (8884:11): [True: 0, False: 27.7k]
  ------------------
 8885|      0|        return i + j;
 8886|      0|      }
 8887|  27.7k|    }
 8888|  3.46k|  }
 8889|       |
 8890|       |  // Handle remaining bytes
 8891|  1.15k|  for (; i < size; i++) {
  ------------------
  |  Branch (8891:10): [True: 899, False: 252]
  ------------------
 8892|    899|    if (character_sets::bit_at(character_set, data[i])) {
  ------------------
  |  Branch (8892:9): [True: 0, False: 899]
  ------------------
 8893|      0|      return i;
 8894|      0|    }
 8895|    899|  }
 8896|       |
 8897|    252|  return size;
 8898|    252|}
_ZNK3ada14url_aggregator13has_authorityEv:
 9628|    491|    const noexcept {
 9629|    491|  ada_log("url_aggregator::has_authority");
 9630|       |  // Performance: instead of doing this potentially expensive check, we could
 9631|       |  // have a boolean in the struct.
 9632|    491|  return components.protocol_end + 2 <= components.host_start &&
  ------------------
  |  Branch (9632:10): [True: 0, False: 491]
  ------------------
 9633|      0|         buffer[components.protocol_end] == '/' &&
  ------------------
  |  Branch (9633:10): [True: 0, False: 0]
  ------------------
 9634|      0|         buffer[components.protocol_end + 1] == '/';
  ------------------
  |  Branch (9634:10): [True: 0, False: 0]
  ------------------
 9635|    491|}
_ZNK2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEcvbEv:
 4573|  2.93k|  constexpr explicit operator bool() const noexcept { return this->m_has_val; }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEptEv:
 4542|  8.79k|  TL_EXPECTED_11_CONSTEXPR T* operator->() {
 4543|  8.79k|    TL_ASSERT(has_value());
  ------------------
  |  | 2595|  8.79k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4543:5): [True: 8.79k, False: 0]
  ------------------
 4544|  8.79k|    return valptr();
 4545|  8.79k|  }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE6valptrEv:
 3838|  8.79k|  T* valptr() { return std::addressof(this->m_val); }
_ZNK2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE9has_valueEv:
 4572|  8.79k|  constexpr bool has_value() const noexcept { return this->m_has_val; }
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EED2Ev:
 3170|  2.93k|  ~expected_storage_base() {
 3171|  2.93k|    if (m_has_val) {
  ------------------
  |  Branch (3171:9): [True: 2.93k, False: 0]
  ------------------
 3172|  2.93k|      m_val.~T();
 3173|  2.93k|    }
 3174|  2.93k|  }
_ZN3ada7helpers9substringENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEmm:
 2385|  1.62k|                                                       size_t pos2) {
 2386|       |#if ADA_DEVELOPMENT_CHECKS
 2387|       |  if (pos2 < pos1) {
 2388|       |    std::cerr << "Negative-length substring: [" << pos1 << " to " << pos2 << ")"
 2389|       |              << std::endl;
 2390|       |    abort();
 2391|       |  }
 2392|       |#endif
 2393|  1.62k|  return input.substr(pos1, pos2 - pos1);
 2394|  1.62k|}
_ZNK3ada14url_aggregator10is_at_pathEv:
 9060|  1.50k|    const noexcept {
 9061|  1.50k|  return buffer.size() == components.pathname_start;
 9062|  1.50k|}
_ZN3ada17url_search_paramsC2ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10107|  14.6k|  explicit url_search_params(const std::string_view input) {
10108|  14.6k|    initialize(input);
10109|  14.6k|  }
_ZN3ada17url_search_params10initializeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10334|  17.5k|inline void url_search_params::initialize(std::string_view input) {
10335|  17.5k|  if (!input.empty() && input.front() == '?') {
  ------------------
  |  Branch (10335:7): [True: 6.35k, False: 11.2k]
  |  Branch (10335:25): [True: 17, False: 6.33k]
  ------------------
10336|     17|    input.remove_prefix(1);
10337|     17|  }
10338|  17.5k|  if (input.empty()) {
  ------------------
  |  Branch (10338:7): [True: 11.2k, False: 6.34k]
  ------------------
10339|  11.2k|    return;
10340|  11.2k|  }
10341|       |  // Refuse overlong query strings (same process-wide cap as URL parsing).
10342|  6.34k|  if (input.size() > get_max_input_length()) {
  ------------------
  |  Branch (10342:7): [True: 0, False: 6.34k]
  ------------------
10343|      0|    return;
10344|      0|  }
10345|       |
10346|       |  // count('&')+1 is an upper bound on the pairs the loop below keeps
10347|       |  // (empty segments are skipped). It is one character count, which is
10348|       |  // the reserve the parse path already paid for. An input of only '&'
10349|       |  // would reserve N+1 pairs and store nothing; skip that.
10350|  6.34k|  const size_t ampersands = size_t(std::count(input.begin(), input.end(), '&'));
10351|  6.34k|  if (ampersands == input.size()) {
  ------------------
  |  Branch (10351:7): [True: 68, False: 6.28k]
  ------------------
10352|     68|    return;
10353|     68|  }
10354|  6.28k|  params.reserve(ampersands + 1);
10355|       |
10356|  6.28k|  auto process_key_value = [&](const std::string_view current) {
10357|  6.28k|    const auto equal = current.find('=');
10358|  6.28k|    if (equal == std::string_view::npos) {
10359|  6.28k|      params.emplace_back(unicode::form_urlencoded_decode(current), "");
10360|  6.28k|    } else {
10361|  6.28k|      params.emplace_back(
10362|  6.28k|          unicode::form_urlencoded_decode(current.substr(0, equal)),
10363|  6.28k|          unicode::form_urlencoded_decode(current.substr(equal + 1)));
10364|  6.28k|    }
10365|  6.28k|  };
10366|       |
10367|  47.6k|  while (!input.empty()) {
  ------------------
  |  Branch (10367:10): [True: 47.4k, False: 200]
  ------------------
10368|  47.4k|    const auto ampersand_index = input.find('&');
10369|       |
10370|  47.4k|    if (ampersand_index == std::string_view::npos) {
  ------------------
  |  Branch (10370:9): [True: 6.08k, False: 41.3k]
  ------------------
10371|  6.08k|      if (!input.empty()) {
  ------------------
  |  Branch (10371:11): [True: 6.08k, False: 0]
  ------------------
10372|  6.08k|        process_key_value(input);
10373|  6.08k|      }
10374|  6.08k|      break;
10375|  41.3k|    } else if (ampersand_index != 0) {
  ------------------
  |  Branch (10375:16): [True: 29.6k, False: 11.6k]
  ------------------
10376|  29.6k|      process_key_value(input.substr(0, ampersand_index));
10377|  29.6k|    }
10378|       |
10379|  41.3k|    input.remove_prefix(ampersand_index + 1);
10380|  41.3k|  }
10381|  6.28k|}
_ZZN3ada17url_search_params10initializeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEENKUlS5_E_clES5_:
10356|  35.7k|  auto process_key_value = [&](const std::string_view current) {
10357|  35.7k|    const auto equal = current.find('=');
10358|  35.7k|    if (equal == std::string_view::npos) {
  ------------------
  |  Branch (10358:9): [True: 13.0k, False: 22.7k]
  ------------------
10359|  13.0k|      params.emplace_back(unicode::form_urlencoded_decode(current), "");
10360|  22.7k|    } else {
10361|  22.7k|      params.emplace_back(
10362|  22.7k|          unicode::form_urlencoded_decode(current.substr(0, equal)),
10363|  22.7k|          unicode::form_urlencoded_decode(current.substr(equal + 1)));
10364|  22.7k|    }
10365|  35.7k|  };
_ZN3ada17url_search_paramsD2Ev:
10115|  29.3k|  ~url_search_params() = default;
_ZNK3ada17url_search_params9to_stringEv:
10429|  26.3k|inline std::string url_search_params::to_string() const {
10430|  26.3k|  auto character_set = ada::character_sets::WWW_FORM_URLENCODED_PERCENT_ENCODE;
10431|  26.3k|  std::string out{};
10432|  87.6k|  for (size_t i = 0; i < params.size(); i++) {
  ------------------
  |  Branch (10432:22): [True: 61.2k, False: 26.3k]
  ------------------
10433|  61.2k|    auto key = ada::unicode::percent_encode(params[i].first, character_set);
10434|  61.2k|    auto value = ada::unicode::percent_encode(params[i].second, character_set);
10435|       |
10436|       |    // Performance optimization: Move this inside percent_encode.
10437|  61.2k|    std::ranges::replace(key, ' ', '+');
10438|  61.2k|    std::ranges::replace(value, ' ', '+');
10439|       |
10440|  61.2k|    if (i != 0) {
  ------------------
  |  Branch (10440:9): [True: 47.9k, False: 13.2k]
  ------------------
10441|  47.9k|      out += "&";
10442|  47.9k|    }
10443|  61.2k|    out.append(key);
10444|  61.2k|    out += "=";
10445|  61.2k|    out.append(value);
10446|  61.2k|  }
10447|  26.3k|  return out;
10448|  26.3k|}
_ZNK3ada17url_search_params4sizeEv:
10388|  26.3k|inline size_t url_search_params::size() const noexcept { return params.size(); }
_ZN3ada17url_search_params4sortEv:
10477|  5.86k|inline void url_search_params::sort() {
10478|       |  // Keys are expected to be valid UTF-8, but percent_decode can produce
10479|       |  // arbitrary byte sequences. Handle truncated/invalid sequences gracefully.
10480|  5.86k|  std::ranges::stable_sort(params, [](const key_value_pair& lhs,
10481|  5.86k|                                      const key_value_pair& rhs) {
10482|  5.86k|    size_t i = 0, j = 0;
10483|  5.86k|    uint32_t low_surrogate1 = 0, low_surrogate2 = 0;
10484|  5.86k|    while ((i < lhs.first.size() || low_surrogate1 != 0) &&
10485|  5.86k|           (j < rhs.first.size() || low_surrogate2 != 0)) {
10486|  5.86k|      uint32_t codePoint1 = 0, codePoint2 = 0;
10487|       |
10488|  5.86k|      if (low_surrogate1 != 0) {
10489|  5.86k|        codePoint1 = low_surrogate1;
10490|  5.86k|        low_surrogate1 = 0;
10491|  5.86k|      } else {
10492|  5.86k|        uint8_t c1 = uint8_t(lhs.first[i]);
10493|  5.86k|        if (c1 > 0x7F && c1 <= 0xDF && i + 1 < lhs.first.size()) {
10494|  5.86k|          codePoint1 = ((c1 & 0x1F) << 6) | (uint8_t(lhs.first[i + 1]) & 0x3F);
10495|  5.86k|          i += 2;
10496|  5.86k|        } else if (c1 > 0xDF && c1 <= 0xEF && i + 2 < lhs.first.size()) {
10497|  5.86k|          codePoint1 = ((c1 & 0x0F) << 12) |
10498|  5.86k|                       ((uint8_t(lhs.first[i + 1]) & 0x3F) << 6) |
10499|  5.86k|                       (uint8_t(lhs.first[i + 2]) & 0x3F);
10500|  5.86k|          i += 3;
10501|  5.86k|        } else if (c1 > 0xEF && c1 <= 0xF7 && i + 3 < lhs.first.size()) {
10502|  5.86k|          codePoint1 = ((c1 & 0x07) << 18) |
10503|  5.86k|                       ((uint8_t(lhs.first[i + 1]) & 0x3F) << 12) |
10504|  5.86k|                       ((uint8_t(lhs.first[i + 2]) & 0x3F) << 6) |
10505|  5.86k|                       (uint8_t(lhs.first[i + 3]) & 0x3F);
10506|  5.86k|          i += 4;
10507|       |
10508|  5.86k|          codePoint1 -= 0x10000;
10509|  5.86k|          uint16_t high_surrogate = uint16_t(0xD800 + (codePoint1 >> 10));
10510|  5.86k|          low_surrogate1 = uint16_t(0xDC00 + (codePoint1 & 0x3FF));
10511|  5.86k|          codePoint1 = high_surrogate;
10512|  5.86k|        } else {
10513|       |          // ASCII (c1 <= 0x7F) or truncated/invalid UTF-8: treat as raw byte
10514|  5.86k|          codePoint1 = c1;
10515|  5.86k|          i++;
10516|  5.86k|        }
10517|  5.86k|      }
10518|       |
10519|  5.86k|      if (low_surrogate2 != 0) {
10520|  5.86k|        codePoint2 = low_surrogate2;
10521|  5.86k|        low_surrogate2 = 0;
10522|  5.86k|      } else {
10523|  5.86k|        uint8_t c2 = uint8_t(rhs.first[j]);
10524|  5.86k|        if (c2 > 0x7F && c2 <= 0xDF && j + 1 < rhs.first.size()) {
10525|  5.86k|          codePoint2 = ((c2 & 0x1F) << 6) | (uint8_t(rhs.first[j + 1]) & 0x3F);
10526|  5.86k|          j += 2;
10527|  5.86k|        } else if (c2 > 0xDF && c2 <= 0xEF && j + 2 < rhs.first.size()) {
10528|  5.86k|          codePoint2 = ((c2 & 0x0F) << 12) |
10529|  5.86k|                       ((uint8_t(rhs.first[j + 1]) & 0x3F) << 6) |
10530|  5.86k|                       (uint8_t(rhs.first[j + 2]) & 0x3F);
10531|  5.86k|          j += 3;
10532|  5.86k|        } else if (c2 > 0xEF && c2 <= 0xF7 && j + 3 < rhs.first.size()) {
10533|  5.86k|          codePoint2 = ((c2 & 0x07) << 18) |
10534|  5.86k|                       ((uint8_t(rhs.first[j + 1]) & 0x3F) << 12) |
10535|  5.86k|                       ((uint8_t(rhs.first[j + 2]) & 0x3F) << 6) |
10536|  5.86k|                       (uint8_t(rhs.first[j + 3]) & 0x3F);
10537|  5.86k|          j += 4;
10538|  5.86k|          codePoint2 -= 0x10000;
10539|  5.86k|          uint16_t high_surrogate = uint16_t(0xD800 + (codePoint2 >> 10));
10540|  5.86k|          low_surrogate2 = uint16_t(0xDC00 + (codePoint2 & 0x3FF));
10541|  5.86k|          codePoint2 = high_surrogate;
10542|  5.86k|        } else {
10543|       |          // ASCII (c2 <= 0x7F) or truncated/invalid UTF-8: treat as raw byte
10544|  5.86k|          codePoint2 = c2;
10545|  5.86k|          j++;
10546|  5.86k|        }
10547|  5.86k|      }
10548|       |
10549|  5.86k|      if (codePoint1 != codePoint2) {
10550|  5.86k|        return (codePoint1 < codePoint2);
10551|  5.86k|      }
10552|  5.86k|    }
10553|  5.86k|    return (j < rhs.first.size() || low_surrogate2 != 0);
10554|  5.86k|  });
10555|  5.86k|}
_ZZN3ada17url_search_params4sortEvENKUlRKNSt3__14pairINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES8_EESB_E_clESB_SB_:
10481|  42.9k|                                      const key_value_pair& rhs) {
10482|  42.9k|    size_t i = 0, j = 0;
10483|  42.9k|    uint32_t low_surrogate1 = 0, low_surrogate2 = 0;
10484|  69.3k|    while ((i < lhs.first.size() || low_surrogate1 != 0) &&
  ------------------
  |  Branch (10484:13): [True: 45.8k, False: 23.4k]
  |  Branch (10484:37): [True: 380, False: 23.0k]
  ------------------
10485|  46.2k|           (j < rhs.first.size() || low_surrogate2 != 0)) {
  ------------------
  |  Branch (10485:13): [True: 44.0k, False: 2.18k]
  |  Branch (10485:37): [True: 375, False: 1.81k]
  ------------------
10486|  44.4k|      uint32_t codePoint1 = 0, codePoint2 = 0;
10487|       |
10488|  44.4k|      if (low_surrogate1 != 0) {
  ------------------
  |  Branch (10488:11): [True: 1.13k, False: 43.3k]
  ------------------
10489|  1.13k|        codePoint1 = low_surrogate1;
10490|  1.13k|        low_surrogate1 = 0;
10491|  43.3k|      } else {
10492|  43.3k|        uint8_t c1 = uint8_t(lhs.first[i]);
10493|  43.3k|        if (c1 > 0x7F && c1 <= 0xDF && i + 1 < lhs.first.size()) {
  ------------------
  |  Branch (10493:13): [True: 15.4k, False: 27.8k]
  |  Branch (10493:26): [True: 6.99k, False: 8.46k]
  |  Branch (10493:40): [True: 2.40k, False: 4.58k]
  ------------------
10494|  2.40k|          codePoint1 = ((c1 & 0x1F) << 6) | (uint8_t(lhs.first[i + 1]) & 0x3F);
10495|  2.40k|          i += 2;
10496|  40.9k|        } else if (c1 > 0xDF && c1 <= 0xEF && i + 2 < lhs.first.size()) {
  ------------------
  |  Branch (10496:20): [True: 8.46k, False: 32.4k]
  |  Branch (10496:33): [True: 2.37k, False: 6.08k]
  |  Branch (10496:47): [True: 1.39k, False: 980]
  ------------------
10497|  1.39k|          codePoint1 = ((c1 & 0x0F) << 12) |
10498|  1.39k|                       ((uint8_t(lhs.first[i + 1]) & 0x3F) << 6) |
10499|  1.39k|                       (uint8_t(lhs.first[i + 2]) & 0x3F);
10500|  1.39k|          i += 3;
10501|  39.5k|        } else if (c1 > 0xEF && c1 <= 0xF7 && i + 3 < lhs.first.size()) {
  ------------------
  |  Branch (10501:20): [True: 6.08k, False: 33.4k]
  |  Branch (10501:33): [True: 3.40k, False: 2.68k]
  |  Branch (10501:47): [True: 1.46k, False: 1.93k]
  ------------------
10502|  1.46k|          codePoint1 = ((c1 & 0x07) << 18) |
10503|  1.46k|                       ((uint8_t(lhs.first[i + 1]) & 0x3F) << 12) |
10504|  1.46k|                       ((uint8_t(lhs.first[i + 2]) & 0x3F) << 6) |
10505|  1.46k|                       (uint8_t(lhs.first[i + 3]) & 0x3F);
10506|  1.46k|          i += 4;
10507|       |
10508|  1.46k|          codePoint1 -= 0x10000;
10509|  1.46k|          uint16_t high_surrogate = uint16_t(0xD800 + (codePoint1 >> 10));
10510|  1.46k|          low_surrogate1 = uint16_t(0xDC00 + (codePoint1 & 0x3FF));
10511|  1.46k|          codePoint1 = high_surrogate;
10512|  38.0k|        } else {
10513|       |          // ASCII (c1 <= 0x7F) or truncated/invalid UTF-8: treat as raw byte
10514|  38.0k|          codePoint1 = c1;
10515|  38.0k|          i++;
10516|  38.0k|        }
10517|  43.3k|      }
10518|       |
10519|  44.4k|      if (low_surrogate2 != 0) {
  ------------------
  |  Branch (10519:11): [True: 1.13k, False: 43.3k]
  ------------------
10520|  1.13k|        codePoint2 = low_surrogate2;
10521|  1.13k|        low_surrogate2 = 0;
10522|  43.3k|      } else {
10523|  43.3k|        uint8_t c2 = uint8_t(rhs.first[j]);
10524|  43.3k|        if (c2 > 0x7F && c2 <= 0xDF && j + 1 < rhs.first.size()) {
  ------------------
  |  Branch (10524:13): [True: 17.7k, False: 25.5k]
  |  Branch (10524:26): [True: 8.57k, False: 9.22k]
  |  Branch (10524:40): [True: 3.37k, False: 5.19k]
  ------------------
10525|  3.37k|          codePoint2 = ((c2 & 0x1F) << 6) | (uint8_t(rhs.first[j + 1]) & 0x3F);
10526|  3.37k|          j += 2;
10527|  39.9k|        } else if (c2 > 0xDF && c2 <= 0xEF && j + 2 < rhs.first.size()) {
  ------------------
  |  Branch (10527:20): [True: 9.22k, False: 30.7k]
  |  Branch (10527:33): [True: 2.63k, False: 6.58k]
  |  Branch (10527:47): [True: 1.40k, False: 1.23k]
  ------------------
10528|  1.40k|          codePoint2 = ((c2 & 0x0F) << 12) |
10529|  1.40k|                       ((uint8_t(rhs.first[j + 1]) & 0x3F) << 6) |
10530|  1.40k|                       (uint8_t(rhs.first[j + 2]) & 0x3F);
10531|  1.40k|          j += 3;
10532|  38.5k|        } else if (c2 > 0xEF && c2 <= 0xF7 && j + 3 < rhs.first.size()) {
  ------------------
  |  Branch (10532:20): [True: 6.58k, False: 31.9k]
  |  Branch (10532:33): [True: 3.43k, False: 3.14k]
  |  Branch (10532:47): [True: 1.62k, False: 1.81k]
  ------------------
10533|  1.62k|          codePoint2 = ((c2 & 0x07) << 18) |
10534|  1.62k|                       ((uint8_t(rhs.first[j + 1]) & 0x3F) << 12) |
10535|  1.62k|                       ((uint8_t(rhs.first[j + 2]) & 0x3F) << 6) |
10536|  1.62k|                       (uint8_t(rhs.first[j + 3]) & 0x3F);
10537|  1.62k|          j += 4;
10538|  1.62k|          codePoint2 -= 0x10000;
10539|  1.62k|          uint16_t high_surrogate = uint16_t(0xD800 + (codePoint2 >> 10));
10540|  1.62k|          low_surrogate2 = uint16_t(0xDC00 + (codePoint2 & 0x3FF));
10541|  1.62k|          codePoint2 = high_surrogate;
10542|  36.9k|        } else {
10543|       |          // ASCII (c2 <= 0x7F) or truncated/invalid UTF-8: treat as raw byte
10544|  36.9k|          codePoint2 = c2;
10545|  36.9k|          j++;
10546|  36.9k|        }
10547|  43.3k|      }
10548|       |
10549|  44.4k|      if (codePoint1 != codePoint2) {
  ------------------
  |  Branch (10549:11): [True: 18.0k, False: 26.3k]
  ------------------
10550|  18.0k|        return (codePoint1 < codePoint2);
10551|  18.0k|      }
10552|  44.4k|    }
10553|  24.9k|    return (j < rhs.first.size() || low_surrogate2 != 0);
  ------------------
  |  Branch (10553:13): [True: 4.80k, False: 20.1k]
  |  Branch (10553:37): [True: 14, False: 20.0k]
  ------------------
10554|  42.9k|  });
_ZN3ada17url_search_params5resetENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10327|  2.93k|inline void url_search_params::reset(std::string_view input) {
10328|       |  // input may point into params.
10329|  2.93k|  const std::string copy(input);
10330|  2.93k|  params.clear();
10331|  2.93k|  initialize(copy);
10332|  2.93k|}
_ZN3ada17url_search_params6appendENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEES5_:
10384|  16.4k|                                      const std::string_view value) {
10385|  16.4k|  params.emplace_back(key, value);
10386|  16.4k|}
_ZN3ada17url_search_params3setENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEES5_:
10451|  2.93k|                                   const std::string_view value) {
10452|  2.93k|  const auto find = [&key](const auto& param) { return param.first == key; };
10453|       |
10454|  2.93k|  auto it = std::ranges::find_if(params, find);
10455|       |
10456|  2.93k|  if (it == params.end()) {
  ------------------
  |  Branch (10456:7): [True: 0, False: 2.93k]
  ------------------
10457|      0|    params.emplace_back(key, value);
10458|  2.93k|  } else {
10459|  2.93k|    it->second = value;
10460|  2.93k|    params.erase(std::remove_if(std::next(it), params.end(), find),
10461|  2.93k|                 params.end());
10462|  2.93k|  }
10463|  2.93k|}
_ZZN3ada17url_search_params3setENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEES5_ENKUlRKT_E_clINS1_4pairINS1_12basic_stringIcS4_NS1_9allocatorIcEEEESF_EEEEDaS8_:
10452|  5.86k|  const auto find = [&key](const auto& param) { return param.first == key; };
_ZN3ada17url_search_params6removeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10465|  4.19k|inline void url_search_params::remove(const std::string_view key) {
10466|  4.19k|  std::erase_if(params,
10467|  4.19k|                [&key](const auto& param) { return param.first == key; });
10468|  4.19k|}
_ZZN3ada17url_search_params6removeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEENKUlRKT_E_clINS1_4pairINS1_12basic_stringIcS4_NS1_9allocatorIcEEEESF_EEEEDaS8_:
10467|  9.32k|                [&key](const auto& param) { return param.first == key; });
_ZN3ada17url_search_params6removeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEES5_:
10471|  4.19k|                                      const std::string_view value) {
10472|  4.19k|  std::erase_if(params, [&key, &value](const auto& param) {
10473|  4.19k|    return param.first == key && param.second == value;
10474|  4.19k|  });
10475|  4.19k|}
_ZZN3ada17url_search_params6removeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEES5_ENKUlRKT_E_clINS1_4pairINS1_12basic_stringIcS4_NS1_9allocatorIcEEEESF_EEEEDaS8_:
10472|  3.37k|  std::erase_if(params, [&key, &value](const auto& param) {
10473|  3.37k|    return param.first == key && param.second == value;
  ------------------
  |  Branch (10473:12): [True: 0, False: 3.37k]
  |  Branch (10473:34): [True: 0, False: 0]
  ------------------
10474|  3.37k|  });
_ZN3ada17url_search_params3hasENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10415|  24.4k|inline bool url_search_params::has(const std::string_view key) noexcept {
10416|  24.4k|  auto entry = std::ranges::find_if(
10417|  24.4k|      params, [&key](const auto& param) { return param.first == key; });
10418|  24.4k|  return entry != params.end();
10419|  24.4k|}
_ZZN3ada17url_search_params3hasENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEENKUlRKT_E_clINS1_4pairINS1_12basic_stringIcS4_NS1_9allocatorIcEEEESF_EEEEDaS8_:
10417|   286k|      params, [&key](const auto& param) { return param.first == key; });
_ZN3ada17url_search_params3hasENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEES5_:
10422|  13.7k|                                   std::string_view value) noexcept {
10423|  13.7k|  auto entry = std::ranges::find_if(params, [&key, &value](const auto& param) {
10424|  13.7k|    return param.first == key && param.second == value;
10425|  13.7k|  });
10426|  13.7k|  return entry != params.end();
10427|  13.7k|}
_ZZN3ada17url_search_params3hasENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEES5_ENKUlRKT_E_clINS1_4pairINS1_12basic_stringIcS4_NS1_9allocatorIcEEEESF_EEEEDaS8_:
10423|   149k|  auto entry = std::ranges::find_if(params, [&key, &value](const auto& param) {
10424|   149k|    return param.first == key && param.second == value;
  ------------------
  |  Branch (10424:12): [True: 18.1k, False: 130k]
  |  Branch (10424:34): [True: 12.0k, False: 6.09k]
  ------------------
10425|   149k|  });
_ZN3ada17url_search_params3getENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10391|  19.5k|    const std::string_view key) {
10392|  19.5k|  auto entry = std::ranges::find_if(
10393|  19.5k|      params, [&key](const auto& param) { return param.first == key; });
10394|       |
10395|  19.5k|  if (entry == params.end()) {
  ------------------
  |  Branch (10395:7): [True: 5.55k, False: 14.0k]
  ------------------
10396|  5.55k|    return std::nullopt;
10397|  5.55k|  }
10398|       |
10399|  14.0k|  return entry->second;
10400|  19.5k|}
_ZZN3ada17url_search_params3getENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEENKUlRKT_E_clINS1_4pairINS1_12basic_stringIcS4_NS1_9allocatorIcEEEESF_EEEEDaS8_:
10393|   153k|      params, [&key](const auto& param) { return param.first == key; });
_ZN3ada17url_search_params7get_allENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10403|  5.86k|    const std::string_view key) {
10404|  5.86k|  std::vector<std::string> out{};
10405|       |
10406|  17.5k|  for (auto& param : params) {
  ------------------
  |  Branch (10406:20): [True: 17.5k, False: 5.86k]
  ------------------
10407|  17.5k|    if (param.first == key) {
  ------------------
  |  Branch (10407:9): [True: 6.21k, False: 11.3k]
  ------------------
10408|  6.21k|      out.emplace_back(param.second);
10409|  6.21k|    }
10410|  17.5k|  }
10411|       |
10412|  5.86k|  return out;
10413|  5.86k|}
_ZN3ada17url_search_paramsC2Ev:
10100|  8.79k|  url_search_params() = default;
_ZN3ada17url_search_params8get_keysEv:
10557|  2.93k|inline url_search_params_keys_iter url_search_params::get_keys() {
10558|  2.93k|  return url_search_params_keys_iter(*this);
10559|  2.93k|}
_ZN3ada22url_search_params_iterINSt3__117basic_string_viewIcNS1_11char_traitsIcEEEELNS_27url_search_params_iter_typeE0EEC2ERNS_17url_search_paramsE:
10287|  2.93k|  inline url_search_params_iter(url_search_params& params_) : params(params_) {}
_ZN3ada17url_search_paramsC2ERKS0_:
10111|  2.93k|  url_search_params(const url_search_params& u) = default;
_ZN3ada17url_search_params10get_valuesEv:
10564|  2.93k|inline url_search_params_values_iter url_search_params::get_values() {
10565|  2.93k|  return url_search_params_values_iter(*this);
10566|  2.93k|}
_ZN3ada22url_search_params_iterINSt3__117basic_string_viewIcNS1_11char_traitsIcEEEELNS_27url_search_params_iter_typeE1EEC2ERNS_17url_search_paramsE:
10287|  2.93k|  inline url_search_params_iter(url_search_params& params_) : params(params_) {}
_ZN3ada17url_search_params11get_entriesEv:
10571|  2.93k|inline url_search_params_entries_iter url_search_params::get_entries() {
10572|  2.93k|  return url_search_params_entries_iter(*this);
10573|  2.93k|}
_ZN3ada22url_search_params_iterINSt3__14pairINS1_17basic_string_viewIcNS1_11char_traitsIcEEEES6_EELNS_27url_search_params_iter_typeE2EEC2ERNS_17url_search_paramsE:
10287|  2.93k|  inline url_search_params_iter(url_search_params& params_) : params(params_) {}
_ZN3ada22url_search_params_iterINSt3__117basic_string_viewIcNS1_11char_traitsIcEEEELNS_27url_search_params_iter_typeE0EE4nextEv:
10581|  9.64k|inline std::optional<std::string_view> url_search_params_keys_iter::next() {
10582|  9.64k|  if (!has_next()) {
  ------------------
  |  Branch (10582:7): [True: 0, False: 9.64k]
  ------------------
10583|      0|    return std::nullopt;
10584|      0|  }
10585|  9.64k|  return params.params[pos++].first;
10586|  9.64k|}
_ZN3ada22url_search_params_iterINSt3__117basic_string_viewIcNS1_11char_traitsIcEEEELNS_27url_search_params_iter_typeE1EE4nextEv:
10589|  9.64k|inline std::optional<std::string_view> url_search_params_values_iter::next() {
10590|  9.64k|  if (!has_next()) {
  ------------------
  |  Branch (10590:7): [True: 0, False: 9.64k]
  ------------------
10591|      0|    return std::nullopt;
10592|      0|  }
10593|  9.64k|  return params.params[pos++].second;
10594|  9.64k|}
_ZN3ada22url_search_params_iterINSt3__14pairINS1_17basic_string_viewIcNS1_11char_traitsIcEEEES6_EELNS_27url_search_params_iter_typeE2EE4nextEv:
10598|  9.64k|url_search_params_entries_iter::next() {
10599|  9.64k|  if (!has_next()) {
  ------------------
  |  Branch (10599:7): [True: 0, False: 9.64k]
  ------------------
10600|      0|    return std::nullopt;
10601|      0|  }
10602|  9.64k|  return params.params[pos++];
10603|  9.64k|}
_ZNK3ada17url_search_params5beginEv:
10224|  11.7k|  inline auto begin() const { return params.begin(); }
_ZNK3ada17url_search_params3endEv:
10225|  11.7k|  inline auto end() const { return params.end(); }
_ZNK3ada17url_search_params5frontEv:
10226|  1.15k|  inline auto front() const { return params.front(); }
_ZNK3ada17url_search_params4backEv:
10227|  1.15k|  inline auto back() const { return params.back(); }
_ZNK3ada17url_search_paramsixEm:
10228|  1.15k|  inline auto operator[](size_t index) const { return params[index]; }
_ZN3ada17url_search_paramsaSERKS0_:
10114|  2.93k|  url_search_params& operator=(const url_search_params& u) = default;
_ZN3ada17url_search_paramsC2EOS0_:
10112|  2.93k|  url_search_params(url_search_params&& u) noexcept = default;
_ZN3ada17url_search_paramsaSEOS0_:
10113|  2.93k|  url_search_params& operator=(url_search_params&& u) noexcept = default;
_ZNK3ada14url_aggregator8validateEv:
 9819|  2.93k|[[nodiscard]] constexpr bool url_aggregator::validate() const noexcept {
 9820|  2.93k|  if (!is_valid) {
  ------------------
  |  Branch (9820:7): [True: 0, False: 2.93k]
  ------------------
 9821|      0|    return true;
 9822|      0|  }
 9823|  2.93k|  if (!components.check_offset_consistency()) {
  ------------------
  |  Branch (9823:7): [True: 0, False: 2.93k]
  ------------------
 9824|      0|    ada_log("url_aggregator::validate inconsistent components \n",
 9825|      0|            to_diagram());
 9826|      0|    return false;
 9827|      0|  }
 9828|       |  // We have a credible components struct, but let us investivate more
 9829|       |  // carefully:
 9830|       |  /**
 9831|       |   * https://user:pass@example.com:1234/foo/bar?baz#quux
 9832|       |   *       |     |    |          | ^^^^|       |   |
 9833|       |   *       |     |    |          | |   |       |   `----- hash_start
 9834|       |   *       |     |    |          | |   |       `--------- search_start
 9835|       |   *       |     |    |          | |   `----------------- pathname_start
 9836|       |   *       |     |    |          | `--------------------- port
 9837|       |   *       |     |    |          `----------------------- host_end
 9838|       |   *       |     |    `---------------------------------- host_start
 9839|       |   *       |     `--------------------------------------- username_end
 9840|       |   *       `--------------------------------------------- protocol_end
 9841|       |   */
 9842|  2.93k|  if (components.protocol_end == url_components::omitted) {
  ------------------
  |  Branch (9842:7): [True: 0, False: 2.93k]
  ------------------
 9843|      0|    ada_log("url_aggregator::validate omitted protocol_end \n", to_diagram());
 9844|      0|    return false;
 9845|      0|  }
 9846|  2.93k|  if (components.username_end == url_components::omitted) {
  ------------------
  |  Branch (9846:7): [True: 0, False: 2.93k]
  ------------------
 9847|      0|    ada_log("url_aggregator::validate omitted username_end \n", to_diagram());
 9848|      0|    return false;
 9849|      0|  }
 9850|  2.93k|  if (components.host_start == url_components::omitted) {
  ------------------
  |  Branch (9850:7): [True: 0, False: 2.93k]
  ------------------
 9851|      0|    ada_log("url_aggregator::validate omitted host_start \n", to_diagram());
 9852|      0|    return false;
 9853|      0|  }
 9854|  2.93k|  if (components.host_end == url_components::omitted) {
  ------------------
  |  Branch (9854:7): [True: 0, False: 2.93k]
  ------------------
 9855|      0|    ada_log("url_aggregator::validate omitted host_end \n", to_diagram());
 9856|      0|    return false;
 9857|      0|  }
 9858|  2.93k|  if (components.pathname_start == url_components::omitted) {
  ------------------
  |  Branch (9858:7): [True: 0, False: 2.93k]
  ------------------
 9859|      0|    ada_log("url_aggregator::validate omitted pathname_start \n", to_diagram());
 9860|      0|    return false;
 9861|      0|  }
 9862|       |
 9863|  2.93k|  if (components.protocol_end > buffer.size()) {
  ------------------
  |  Branch (9863:7): [True: 0, False: 2.93k]
  ------------------
 9864|      0|    ada_log("url_aggregator::validate protocol_end overflow \n", to_diagram());
 9865|      0|    return false;
 9866|      0|  }
 9867|  2.93k|  if (components.username_end > buffer.size()) {
  ------------------
  |  Branch (9867:7): [True: 0, False: 2.93k]
  ------------------
 9868|      0|    ada_log("url_aggregator::validate username_end overflow \n", to_diagram());
 9869|      0|    return false;
 9870|      0|  }
 9871|  2.93k|  if (components.host_start > buffer.size()) {
  ------------------
  |  Branch (9871:7): [True: 0, False: 2.93k]
  ------------------
 9872|      0|    ada_log("url_aggregator::validate host_start overflow \n", to_diagram());
 9873|      0|    return false;
 9874|      0|  }
 9875|  2.93k|  if (components.host_end > buffer.size()) {
  ------------------
  |  Branch (9875:7): [True: 0, False: 2.93k]
  ------------------
 9876|      0|    ada_log("url_aggregator::validate host_end overflow \n", to_diagram());
 9877|      0|    return false;
 9878|      0|  }
 9879|  2.93k|  if (components.pathname_start > buffer.size()) {
  ------------------
  |  Branch (9879:7): [True: 0, False: 2.93k]
  ------------------
 9880|      0|    ada_log("url_aggregator::validate pathname_start overflow \n",
 9881|      0|            to_diagram());
 9882|      0|    return false;
 9883|      0|  }
 9884|       |
 9885|  2.93k|  if (components.protocol_end > 0) {
  ------------------
  |  Branch (9885:7): [True: 2.93k, False: 0]
  ------------------
 9886|  2.93k|    if (buffer[components.protocol_end - 1] != ':') {
  ------------------
  |  Branch (9886:9): [True: 0, False: 2.93k]
  ------------------
 9887|      0|      ada_log(
 9888|      0|          "url_aggregator::validate missing : at the end of the protocol \n",
 9889|      0|          to_diagram());
 9890|      0|      return false;
 9891|      0|    }
 9892|  2.93k|  }
 9893|       |
 9894|  2.93k|  if (components.username_end != buffer.size() &&
  ------------------
  |  Branch (9894:7): [True: 2.93k, False: 0]
  ------------------
 9895|  2.93k|      components.username_end > components.protocol_end + 2) {
  ------------------
  |  Branch (9895:7): [True: 0, False: 2.93k]
  ------------------
 9896|      0|    if (buffer[components.username_end] != ':' &&
  ------------------
  |  Branch (9896:9): [True: 0, False: 0]
  ------------------
 9897|      0|        buffer[components.username_end] != '@') {
  ------------------
  |  Branch (9897:9): [True: 0, False: 0]
  ------------------
 9898|      0|      ada_log(
 9899|      0|          "url_aggregator::validate missing : or @ at the end of the username "
 9900|      0|          "\n",
 9901|      0|          to_diagram());
 9902|      0|      return false;
 9903|      0|    }
 9904|      0|  }
 9905|       |
 9906|  2.93k|  if (components.host_start != buffer.size()) {
  ------------------
  |  Branch (9906:7): [True: 2.93k, False: 0]
  ------------------
 9907|  2.93k|    if (components.host_start > components.username_end) {
  ------------------
  |  Branch (9907:9): [True: 0, False: 2.93k]
  ------------------
 9908|      0|      if (buffer[components.host_start] != '@') {
  ------------------
  |  Branch (9908:11): [True: 0, False: 0]
  ------------------
 9909|      0|        ada_log(
 9910|      0|            "url_aggregator::validate missing @ at the end of the password \n",
 9911|      0|            to_diagram());
 9912|      0|        return false;
 9913|      0|      }
 9914|  2.93k|    } else if (components.host_start == components.username_end &&
  ------------------
  |  Branch (9914:16): [True: 2.93k, False: 0]
  ------------------
 9915|  2.93k|               components.host_end > components.host_start) {
  ------------------
  |  Branch (9915:16): [True: 2.93k, False: 0]
  ------------------
 9916|  2.93k|      if (components.host_start == components.protocol_end + 2) {
  ------------------
  |  Branch (9916:11): [True: 2.93k, False: 0]
  ------------------
 9917|  2.93k|        if (buffer[components.protocol_end] != '/' ||
  ------------------
  |  Branch (9917:13): [True: 0, False: 2.93k]
  ------------------
 9918|  2.93k|            buffer[components.protocol_end + 1] != '/') {
  ------------------
  |  Branch (9918:13): [True: 0, False: 2.93k]
  ------------------
 9919|      0|          ada_log(
 9920|      0|              "url_aggregator::validate missing // between protocol and host "
 9921|      0|              "\n",
 9922|      0|              to_diagram());
 9923|      0|          return false;
 9924|      0|        }
 9925|  2.93k|      } else {
 9926|      0|        if (components.host_start > components.protocol_end &&
  ------------------
  |  Branch (9926:13): [True: 0, False: 0]
  ------------------
 9927|      0|            buffer[components.host_start] != '@') {
  ------------------
  |  Branch (9927:13): [True: 0, False: 0]
  ------------------
 9928|      0|          ada_log(
 9929|      0|              "url_aggregator::validate missing @ at the end of the username "
 9930|      0|              "\n",
 9931|      0|              to_diagram());
 9932|      0|          return false;
 9933|      0|        }
 9934|      0|      }
 9935|  2.93k|    } else {
 9936|      0|      if (components.host_end != components.host_start) {
  ------------------
  |  Branch (9936:11): [True: 0, False: 0]
  ------------------
 9937|      0|        ada_log("url_aggregator::validate expected omitted host \n",
 9938|      0|                to_diagram());
 9939|      0|        return false;
 9940|      0|      }
 9941|      0|    }
 9942|  2.93k|  }
 9943|  2.93k|  if (components.host_end != buffer.size() &&
  ------------------
  |  Branch (9943:7): [True: 2.93k, False: 0]
  ------------------
 9944|  2.93k|      components.pathname_start > components.host_end) {
  ------------------
  |  Branch (9944:7): [True: 0, False: 2.93k]
  ------------------
 9945|      0|    if (components.pathname_start == components.host_end + 2 &&
  ------------------
  |  Branch (9945:9): [True: 0, False: 0]
  ------------------
 9946|      0|        buffer[components.host_end] == '/' &&
  ------------------
  |  Branch (9946:9): [True: 0, False: 0]
  ------------------
 9947|      0|        buffer[components.host_end + 1] == '.') {
  ------------------
  |  Branch (9947:9): [True: 0, False: 0]
  ------------------
 9948|      0|      if (components.pathname_start + 1 >= buffer.size() ||
  ------------------
  |  Branch (9948:11): [True: 0, False: 0]
  ------------------
 9949|      0|          buffer[components.pathname_start] != '/' ||
  ------------------
  |  Branch (9949:11): [True: 0, False: 0]
  ------------------
 9950|      0|          buffer[components.pathname_start + 1] != '/') {
  ------------------
  |  Branch (9950:11): [True: 0, False: 0]
  ------------------
 9951|      0|        ada_log(
 9952|      0|            "url_aggregator::validate expected the path to begin with // \n",
 9953|      0|            to_diagram());
 9954|      0|        return false;
 9955|      0|      }
 9956|      0|    } else if (buffer[components.host_end] != ':') {
  ------------------
  |  Branch (9956:16): [True: 0, False: 0]
  ------------------
 9957|      0|      ada_log("url_aggregator::validate missing : at the port \n",
 9958|      0|              to_diagram());
 9959|      0|      return false;
 9960|      0|    }
 9961|      0|  }
 9962|  2.93k|  if (components.pathname_start != buffer.size() &&
  ------------------
  |  Branch (9962:7): [True: 2.93k, False: 0]
  ------------------
 9963|  2.93k|      components.pathname_start < components.search_start &&
  ------------------
  |  Branch (9963:7): [True: 2.93k, False: 0]
  ------------------
 9964|  2.93k|      components.pathname_start < components.hash_start && !has_opaque_path) {
  ------------------
  |  Branch (9964:7): [True: 2.93k, False: 0]
  |  Branch (9964:60): [True: 2.93k, False: 0]
  ------------------
 9965|  2.93k|    if (buffer[components.pathname_start] != '/') {
  ------------------
  |  Branch (9965:9): [True: 0, False: 2.93k]
  ------------------
 9966|      0|      ada_log("url_aggregator::validate missing / at the path \n",
 9967|      0|              to_diagram());
 9968|      0|      return false;
 9969|      0|    }
 9970|  2.93k|  }
 9971|  2.93k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9971:7): [True: 1.57k, False: 1.35k]
  ------------------
 9972|  1.57k|    if (buffer[components.search_start] != '?') {
  ------------------
  |  Branch (9972:9): [True: 0, False: 1.57k]
  ------------------
 9973|      0|      ada_log("url_aggregator::validate missing ? at the search \n",
 9974|      0|              to_diagram());
 9975|      0|      return false;
 9976|      0|    }
 9977|  1.57k|  }
 9978|  2.93k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9978:7): [True: 437, False: 2.49k]
  ------------------
 9979|    437|    if (buffer[components.hash_start] != '#') {
  ------------------
  |  Branch (9979:9): [True: 0, False: 437]
  ------------------
 9980|      0|      ada_log("url_aggregator::validate missing # at the hash \n",
 9981|      0|              to_diagram());
 9982|      0|      return false;
 9983|      0|    }
 9984|    437|  }
 9985|       |
 9986|  2.93k|  return true;
 9987|  2.93k|}
_ZNK3ada14url_components24check_offset_consistencyEv:
 8303|  2.93k|    const noexcept {
 8304|       |  /**
 8305|       |   * https://user:pass@example.com:1234/foo/bar?baz#quux
 8306|       |   *       |     |    |          | ^^^^|       |   |
 8307|       |   *       |     |    |          | |   |       |   `----- hash_start
 8308|       |   *       |     |    |          | |   |       `--------- search_start
 8309|       |   *       |     |    |          | |   `----------------- pathname_start
 8310|       |   *       |     |    |          | `--------------------- port
 8311|       |   *       |     |    |          `----------------------- host_end
 8312|       |   *       |     |    `---------------------------------- host_start
 8313|       |   *       |     `--------------------------------------- username_end
 8314|       |   *       `--------------------------------------------- protocol_end
 8315|       |   */
 8316|       |  // These conditions can be made more strict.
 8317|  2.93k|  if (protocol_end == url_components::omitted) {
  ------------------
  |  Branch (8317:7): [True: 0, False: 2.93k]
  ------------------
 8318|      0|    return false;
 8319|      0|  }
 8320|  2.93k|  uint32_t index = protocol_end;
 8321|       |
 8322|  2.93k|  if (username_end == url_components::omitted) {
  ------------------
  |  Branch (8322:7): [True: 0, False: 2.93k]
  ------------------
 8323|      0|    return false;
 8324|      0|  }
 8325|  2.93k|  if (username_end < index) {
  ------------------
  |  Branch (8325:7): [True: 0, False: 2.93k]
  ------------------
 8326|      0|    return false;
 8327|      0|  }
 8328|  2.93k|  index = username_end;
 8329|       |
 8330|  2.93k|  if (host_start == url_components::omitted) {
  ------------------
  |  Branch (8330:7): [True: 0, False: 2.93k]
  ------------------
 8331|      0|    return false;
 8332|      0|  }
 8333|  2.93k|  if (host_start < index) {
  ------------------
  |  Branch (8333:7): [True: 0, False: 2.93k]
  ------------------
 8334|      0|    return false;
 8335|      0|  }
 8336|  2.93k|  index = host_start;
 8337|       |
 8338|  2.93k|  if (port != url_components::omitted) {
  ------------------
  |  Branch (8338:7): [True: 0, False: 2.93k]
  ------------------
 8339|      0|    if (port > 0xffff) {
  ------------------
  |  Branch (8339:9): [True: 0, False: 0]
  ------------------
 8340|      0|      return false;
 8341|      0|    }
 8342|      0|    uint32_t port_length = helpers::fast_digit_count(port) + 1;
 8343|      0|    if (index + port_length < index) {
  ------------------
  |  Branch (8343:9): [True: 0, False: 0]
  ------------------
 8344|      0|      return false;
 8345|      0|    }
 8346|      0|    index += port_length;
 8347|      0|  }
 8348|       |
 8349|  2.93k|  if (pathname_start == url_components::omitted) {
  ------------------
  |  Branch (8349:7): [True: 0, False: 2.93k]
  ------------------
 8350|      0|    return false;
 8351|      0|  }
 8352|  2.93k|  if (pathname_start < index) {
  ------------------
  |  Branch (8352:7): [True: 0, False: 2.93k]
  ------------------
 8353|      0|    return false;
 8354|      0|  }
 8355|  2.93k|  index = pathname_start;
 8356|       |
 8357|  2.93k|  if (search_start != url_components::omitted) {
  ------------------
  |  Branch (8357:7): [True: 1.57k, False: 1.35k]
  ------------------
 8358|  1.57k|    if (search_start < index) {
  ------------------
  |  Branch (8358:9): [True: 0, False: 1.57k]
  ------------------
 8359|      0|      return false;
 8360|      0|    }
 8361|  1.57k|    index = search_start;
 8362|  1.57k|  }
 8363|       |
 8364|  2.93k|  if (hash_start != url_components::omitted) {
  ------------------
  |  Branch (8364:7): [True: 437, False: 2.49k]
  ------------------
 8365|    437|    if (hash_start < index) {
  ------------------
  |  Branch (8365:9): [True: 0, False: 437]
  ------------------
 8366|      0|      return false;
 8367|      0|    }
 8368|    437|  }
 8369|       |
 8370|  2.93k|  return true;
 8371|  2.93k|}
_ZNK3ada22url_search_params_iterINSt3__117basic_string_viewIcNS1_11char_traitsIcEEEELNS_27url_search_params_iter_typeE0EE8has_nextEv:
10576|  22.2k|inline bool url_search_params_iter<T, Type>::has_next() const {
10577|  22.2k|  return pos < params.params.size();
10578|  22.2k|}
_ZNK3ada22url_search_params_iterINSt3__117basic_string_viewIcNS1_11char_traitsIcEEEELNS_27url_search_params_iter_typeE1EE8has_nextEv:
10576|  22.2k|inline bool url_search_params_iter<T, Type>::has_next() const {
10577|  22.2k|  return pos < params.params.size();
10578|  22.2k|}
_ZNK3ada22url_search_params_iterINSt3__14pairINS1_17basic_string_viewIcNS1_11char_traitsIcEEEES6_EELNS_27url_search_params_iter_typeE2EE8has_nextEv:
10576|  22.2k|inline bool url_search_params_iter<T, Type>::has_next() const {
10577|  22.2k|  return pos < params.params.size();
10578|  22.2k|}

LLVMFuzzerTestOneInput:
    9|  2.93k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
   10|  2.93k|  FuzzedDataProvider fdp(data, size);
   11|  2.93k|  std::string source = fdp.ConsumeRandomLengthString(256);
   12|  2.93k|  std::string base_source = fdp.ConsumeRandomLengthString(256);
   13|  2.93k|  std::string key3 = fdp.ConsumeRandomLengthString(64);
   14|  2.93k|  std::string value3 = fdp.ConsumeRandomLengthString(64);
   15|       |
   16|       |  /**
   17|       |   * ada::url_search_params
   18|       |   */
   19|  2.93k|  volatile size_t length = 0;
   20|       |
   21|  2.93k|  auto base_source_view =
   22|  2.93k|      std::string_view(base_source.data(), base_source.length());
   23|       |
   24|       |  // Test constructor with initial value
   25|  2.93k|  auto initialized = ada::url_search_params(base_source_view);
   26|  2.93k|  length += initialized.size();
   27|  2.93k|  initialized.to_string();
   28|       |
   29|       |  // Test get() and get_all() on initialized params
   30|  2.93k|  {
   31|  2.93k|    auto val = initialized.get(source);
   32|  2.93k|    if (val.has_value()) {
  ------------------
  |  Branch (32:9): [True: 270, False: 2.66k]
  ------------------
   33|    270|      length += val->size();
   34|    270|    }
   35|  2.93k|    auto all_vals = initialized.get_all(source);
   36|  2.93k|    for (const auto& v : all_vals) {
  ------------------
  |  Branch (36:24): [True: 2.79k, False: 2.93k]
  ------------------
   37|  2.79k|      length += v.size();
   38|  2.79k|    }
   39|  2.93k|  }
   40|       |
   41|       |  // Test sort() on initialized params
   42|  2.93k|  initialized.sort();
   43|       |
   44|       |  // Test C++ range-for iteration; also verify has(k) and has(k,v) consistency.
   45|  10.7k|  for (const auto& pair : initialized) {
  ------------------
  |  Branch (45:25): [True: 10.7k, False: 2.93k]
  ------------------
   46|  10.7k|    length += pair.first.size();
   47|  10.7k|    length += pair.second.size();
   48|       |
   49|       |    // Every key seen in iteration must be reported by has(key).
   50|  10.7k|    if (!initialized.has(pair.first)) {
  ------------------
  |  Branch (50:9): [True: 0, False: 10.7k]
  ------------------
   51|      0|      printf(
   52|      0|          "url_search_params: iteration yielded key '%s' but has(key) is "
   53|      0|          "false\n",
   54|      0|          std::string(pair.first).c_str());
   55|      0|      abort();
   56|      0|    }
   57|       |
   58|       |    // has(key, value) → has(key)
   59|  10.7k|    if (initialized.has(pair.first, pair.second) &&
  ------------------
  |  Branch (59:9): [True: 10.7k, False: 0]
  ------------------
   60|  10.7k|        !initialized.has(pair.first)) {
  ------------------
  |  Branch (60:9): [True: 0, False: 10.7k]
  ------------------
   61|      0|      printf(
   62|      0|          "url_search_params: has(key,value) is true but has(key) is false "
   63|      0|          "for key '%s'\n",
   64|      0|          std::string(pair.first).c_str());
   65|      0|      abort();
   66|      0|    }
   67|       |
   68|       |    // get(key) must return a value when the key exists.
   69|  10.7k|    auto got = initialized.get(pair.first);
   70|  10.7k|    if (!got.has_value()) {
  ------------------
  |  Branch (70:9): [True: 0, False: 10.7k]
  ------------------
   71|      0|      printf(
   72|      0|          "url_search_params: has(key) is true but get(key) returned nullopt "
   73|      0|          "for key '%s'\n",
   74|      0|          std::string(pair.first).c_str());
   75|      0|      abort();
   76|      0|    }
   77|  10.7k|  }
   78|       |
   79|       |  // Test index-based access
   80|  2.93k|  if (initialized.size() > 0) {
  ------------------
  |  Branch (80:7): [True: 1.15k, False: 1.77k]
  ------------------
   81|  1.15k|    auto front = initialized.front();
   82|  1.15k|    length += front.first.size();
   83|  1.15k|    auto back = initialized.back();
   84|  1.15k|    length += back.first.size();
   85|  1.15k|    auto first = initialized[0];
   86|  1.15k|    length += first.first.size();
   87|  1.15k|  }
   88|       |
   89|       |  // Test default-constructed params with various mutations
   90|  2.93k|  auto search_params = ada::url_search_params();
   91|  2.93k|  search_params.append(source, base_source);
   92|  2.93k|  search_params.append(key3, value3);
   93|  2.93k|  search_params.set(source, base_source);
   94|  2.93k|  search_params.to_string();
   95|       |
   96|       |  // Test size()
   97|  2.93k|  length += search_params.size();
   98|       |
   99|       |  // Test has() and has(key, value) overloads
  100|  2.93k|  volatile bool has_key = search_params.has(base_source);
  101|  2.93k|  if (has_key) {
  ------------------
  |  Branch (101:7): [True: 1.74k, False: 1.18k]
  ------------------
  102|  1.74k|    search_params.append(base_source, source);
  103|  1.74k|  }
  104|       |
  105|       |  // Test get() - returns first matching value
  106|  2.93k|  {
  107|  2.93k|    auto val = search_params.get(source);
  108|  2.93k|    if (val.has_value()) {
  ------------------
  |  Branch (108:9): [True: 2.93k, False: 0]
  ------------------
  109|  2.93k|      length += val->size();
  110|  2.93k|    }
  111|  2.93k|  }
  112|       |
  113|       |  // Test get_all() - returns all matching values
  114|  2.93k|  {
  115|  2.93k|    auto all_vals = search_params.get_all(source);
  116|  2.93k|    length += all_vals.size();
  117|  3.41k|    for (const auto& v : all_vals) {
  ------------------
  |  Branch (117:24): [True: 3.41k, False: 2.93k]
  ------------------
  118|  3.41k|      length += v.size();
  119|  3.41k|    }
  120|  2.93k|  }
  121|       |
  122|       |  // Test remove(key) and remove(key, value) overloads
  123|  2.93k|  search_params.remove(source);
  124|  2.93k|  search_params.remove(source, base_source);
  125|       |
  126|       |  // Test has(key, value) after remove
  127|  2.93k|  if (search_params.has(base_source, source)) {
  ------------------
  |  Branch (127:7): [True: 1.26k, False: 1.66k]
  ------------------
  128|  1.26k|    search_params.remove(base_source);
  129|  1.26k|    search_params.remove(base_source, source);
  130|  1.26k|  }
  131|       |
  132|       |  // Append more pairs for iteration testing
  133|  2.93k|  search_params.append(key3, value3);
  134|  2.93k|  search_params.append(source, key3);
  135|  2.93k|  search_params.append(base_source, value3);
  136|       |
  137|       |  // Test sort()
  138|  2.93k|  search_params.sort();
  139|       |
  140|       |  // Test serialization after sort
  141|  2.93k|  std::string serialized = search_params.to_string();
  142|  2.93k|  length += serialized.size();
  143|       |
  144|       |  // Test JavaScript-style iterator: keys
  145|  2.93k|  auto keys = search_params.get_keys();
  146|  12.5k|  while (keys.has_next()) {
  ------------------
  |  Branch (146:10): [True: 9.64k, False: 2.93k]
  ------------------
  147|  9.64k|    auto k = keys.next();
  148|  9.64k|    if (k.has_value()) {
  ------------------
  |  Branch (148:9): [True: 9.64k, False: 0]
  ------------------
  149|  9.64k|      length += k->size();
  150|  9.64k|    }
  151|  9.64k|  }
  152|       |
  153|       |  // Test JavaScript-style iterator: values
  154|  2.93k|  auto values = search_params.get_values();
  155|  12.5k|  while (values.has_next()) {
  ------------------
  |  Branch (155:10): [True: 9.64k, False: 2.93k]
  ------------------
  156|  9.64k|    auto v = values.next();
  157|  9.64k|    if (v.has_value()) {
  ------------------
  |  Branch (157:9): [True: 9.64k, False: 0]
  ------------------
  158|  9.64k|      length += v->size();
  159|  9.64k|    }
  160|  9.64k|  }
  161|       |
  162|       |  // Test JavaScript-style iterator: entries
  163|  2.93k|  auto entries = search_params.get_entries();
  164|  12.5k|  while (entries.has_next()) {
  ------------------
  |  Branch (164:10): [True: 9.64k, False: 2.93k]
  ------------------
  165|  9.64k|    auto e = entries.next();
  166|  9.64k|    if (e.has_value()) {
  ------------------
  |  Branch (166:9): [True: 9.64k, False: 0]
  ------------------
  167|  9.64k|      length += e->first.size();
  168|  9.64k|      length += e->second.size();
  169|  9.64k|    }
  170|  9.64k|  }
  171|       |
  172|       |  // Test C++ range-for on the mutated params
  173|  9.64k|  for (const auto& pair : search_params) {
  ------------------
  |  Branch (173:25): [True: 9.64k, False: 2.93k]
  ------------------
  174|  9.64k|    length += pair.first.size();
  175|  9.64k|    length += pair.second.size();
  176|  9.64k|  }
  177|       |
  178|       |  // Test reset() - private method used by C API
  179|  2.93k|  std::string resetted_value = fdp.ConsumeRandomLengthString(256);
  180|  2.93k|  search_params.reset(resetted_value);
  181|  2.93k|  length += search_params.size();
  182|       |
  183|       |  // Test that reset() followed by iteration doesn't crash
  184|  3.47k|  for (const auto& pair : search_params) {
  ------------------
  |  Branch (184:25): [True: 3.47k, False: 2.93k]
  ------------------
  185|  3.47k|    length += pair.first.size();
  186|  3.47k|    length += pair.second.size();
  187|  3.47k|  }
  188|       |
  189|       |  // Test get() after reset
  190|  2.93k|  {
  191|  2.93k|    auto val = search_params.get(source);
  192|  2.93k|    if (val.has_value()) {
  ------------------
  |  Branch (192:9): [True: 41, False: 2.89k]
  ------------------
  193|     41|      length += val->size();
  194|     41|    }
  195|  2.93k|  }
  196|       |
  197|       |  // Test copy constructor and copy assignment
  198|  2.93k|  ada::url_search_params copied = search_params;
  199|  2.93k|  length += copied.size();
  200|  2.93k|  ada::url_search_params assigned;
  201|  2.93k|  assigned = search_params;
  202|  2.93k|  length += assigned.size();
  203|       |
  204|       |  // Test move constructor and move assignment
  205|  2.93k|  ada::url_search_params move_constructed = std::move(copied);
  206|  2.93k|  length += move_constructed.size();
  207|  2.93k|  ada::url_search_params move_assigned;
  208|  2.93k|  move_assigned = std::move(assigned);
  209|  2.93k|  length += move_assigned.size();
  210|       |
  211|       |  /**
  212|       |   * Serialisation idempotency.
  213|       |   *
  214|       |   * The application/x-www-form-urlencoded serialiser must be a fixed point:
  215|       |   * parsing the serialised form of any url_search_params and serialising
  216|       |   * again must produce the same string. This invariant is mandated by the
  217|       |   * WHATWG spec and must hold for all inputs.
  218|       |   *
  219|       |   * We test this on both the initialised params (constructed from fuzz input)
  220|       |   * and the mutated params (after append / set / remove / sort).
  221|       |   */
  222|       |
  223|       |  // Initialised params idempotency.
  224|  2.93k|  {
  225|  2.93k|    std::string s1 = initialized.to_string();
  226|  2.93k|    ada::url_search_params reparsed(s1);
  227|  2.93k|    std::string s2 = reparsed.to_string();
  228|  2.93k|    if (s1 != s2) {
  ------------------
  |  Branch (228:9): [True: 0, False: 2.93k]
  ------------------
  229|      0|      printf(
  230|      0|          "url_search_params serialisation not idempotent (initialized)!\n"
  231|      0|          "  first:  %s\n  second: %s\n",
  232|      0|          s1.c_str(), s2.c_str());
  233|      0|      abort();
  234|      0|    }
  235|  2.93k|  }
  236|       |
  237|       |  // Mutated params idempotency.
  238|  2.93k|  {
  239|  2.93k|    std::string s1 = move_assigned.to_string();
  240|  2.93k|    ada::url_search_params reparsed(s1);
  241|  2.93k|    std::string s2 = reparsed.to_string();
  242|  2.93k|    if (s1 != s2) {
  ------------------
  |  Branch (242:9): [True: 0, False: 2.93k]
  ------------------
  243|      0|      printf(
  244|      0|          "url_search_params serialisation not idempotent (mutated)!\n"
  245|      0|          "  first:  %s\n  second: %s\n",
  246|      0|          s1.c_str(), s2.c_str());
  247|      0|      abort();
  248|      0|    }
  249|  2.93k|  }
  250|       |
  251|       |  /**
  252|       |   * Round-trip via URL.
  253|       |   *
  254|       |   * Embed the fuzz input as the query component of a real URL, extract the
  255|       |   * search params from the parsed URL's search string, and verify that the
  256|       |   * resulting params serialise idempotently. This exercises the interface
  257|       |   * between URL parsing and search-params parsing.
  258|       |   */
  259|  2.93k|  {
  260|  2.93k|    std::string url_str = "https://example.com/?" + source;
  261|  2.93k|    auto parsed_url = ada::parse<ada::url_aggregator>(url_str);
  262|  2.93k|    if (parsed_url) {
  ------------------
  |  Branch (262:9): [True: 2.93k, False: 0]
  ------------------
  263|  2.93k|      std::string search_raw = std::string(parsed_url->get_search());
  264|  2.93k|      std::string_view search_view = search_raw;
  265|  2.93k|      if (!search_view.empty() && search_view[0] == '?') {
  ------------------
  |  Branch (265:11): [True: 1.62k, False: 1.30k]
  |  Branch (265:35): [True: 1.62k, False: 0]
  ------------------
  266|  1.62k|        search_view = search_view.substr(1);
  267|  1.62k|      }
  268|       |
  269|  2.93k|      ada::url_search_params sp_from_url(search_view);
  270|       |
  271|       |      // Size and iteration must not crash.
  272|  2.93k|      length += sp_from_url.size();
  273|  3.63k|      for (const auto& pair : sp_from_url) {
  ------------------
  |  Branch (273:29): [True: 3.63k, False: 2.93k]
  ------------------
  274|  3.63k|        length += pair.first.size();
  275|  3.63k|        length += pair.second.size();
  276|  3.63k|      }
  277|       |
  278|       |      // Idempotency check.
  279|  2.93k|      std::string t1 = sp_from_url.to_string();
  280|  2.93k|      ada::url_search_params sp2(t1);
  281|  2.93k|      std::string t2 = sp2.to_string();
  282|  2.93k|      if (t1 != t2) {
  ------------------
  |  Branch (282:11): [True: 0, False: 2.93k]
  ------------------
  283|      0|        printf(
  284|      0|            "url_search_params via URL round-trip not idempotent!\n"
  285|      0|            "  first:  %s\n  second: %s\n",
  286|      0|            t1.c_str(), t2.c_str());
  287|      0|        abort();
  288|      0|      }
  289|       |
  290|       |      // Set the serialised params back on the URL – must not crash.
  291|  2.93k|      parsed_url->set_search(t1);
  292|  2.93k|      volatile bool v = parsed_url->validate();
  293|  2.93k|      (void)v;
  294|  2.93k|    }
  295|  2.93k|  }
  296|       |
  297|  2.93k|  return 0;
  298|  2.93k|}

