LLVMFuzzerTestOneInput:
    8|  1.93k|{
    9|       |   // use a vector with null termination instead of a std::string to avoid
   10|       |   // small string optimization to hide bounds problems
   11|  1.93k|   std::vector<char> buffer{Data, Data + Size};
   12|       |
   13|       |   // non-null terminated
   14|  1.93k|   {
   15|  1.93k|      const auto& input = buffer;
   16|  1.93k|      [[maybe_unused]] auto beautiful = glz::prettify_json(input);
   17|  1.93k|   }
   18|       |
   19|       |   // null terminated
   20|  1.93k|   {
   21|  1.93k|      buffer.push_back('\0');
   22|  1.93k|      const auto& input = buffer;
   23|  1.93k|      [[maybe_unused]] auto beautiful = glz::prettify_json(input);
   24|  1.93k|   }
   25|       |
   26|       |   // The comment enabled path is a different scan: read_jsonc_comment only runs here, and it is
   27|       |   // the scanner that has to report an unterminated comment rather than hand an empty view to a
   28|       |   // memcpy. Fuzzed as its own input because a document rejected by the plain path may be accepted
   29|       |   // by this one.
   30|  1.93k|   {
   31|  1.93k|      const std::vector<char> jsonc{Data, Data + Size};
   32|  1.93k|      [[maybe_unused]] auto beautiful = glz::prettify_jsonc(jsonc);
   33|  1.93k|   }
   34|       |
   35|       |   // Only a self-terminating buffer selects the null terminated scan. A vector carrying a
   36|       |   // trailing NUL does not: that NUL is just a byte inside the document.
   37|  1.93k|   {
   38|  1.93k|      const std::string jsonc{Data, Data + Size};
   39|  1.93k|      [[maybe_unused]] auto beautiful = glz::prettify_jsonc(jsonc);
   40|  1.93k|   }
   41|       |
   42|  1.93k|   return 0;
   43|  1.93k|}

_ZN3glz11grow_bufferINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvRT_m:
  143|  20.4k|   {
  144|  20.4k|      using traits = buffer_traits<std::remove_cvref_t<B>>;
  145|  20.4k|      if constexpr (requires { traits::grow(b, required); }) {
  146|  20.4k|         traits::grow(b, required);
  147|       |      }
  148|       |      else {
  149|       |         // A user specialization written before `grow` existed: keep the growth it used to get.
  150|       |         resize_unfilled(b, 2 * required);
  151|       |      }
  152|  20.4k|   }
_ZN3glz13buffer_traitsINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE4growERS7_mQL_ZNS_13buffer_traits12is_resizableEE:
  118|  20.4k|      {
  119|  20.4k|         resize_unfilled(b, 2 * required);
  120|  20.4k|      }
_ZN3glz15resize_unfilledINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvRT_m:
   63|  20.4k|   {
   64|  20.4k|      if constexpr (requires { b.resize_and_overwrite(n, [](auto*, size_t written) { return written; }); }) {
   65|  20.4k|         b.resize_and_overwrite(n, [](auto*, size_t written) noexcept { return written; });
   66|       |      }
   67|       |      else {
   68|       |         b.resize(n);
   69|       |      }
   70|  20.4k|   }
_ZZN3glz15resize_unfilledINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvRT_mENKUlPS8_mE_clIcEEDaSA_m:
   65|  20.4k|         b.resize_and_overwrite(n, [](auto*, size_t written) noexcept { return written; });

_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10contiguousERKNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT0_:
   40|  3.87k|   {
   41|  3.87k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  3.87k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  3.87k|      auto end = it + buffer.size();
   45|       |
   46|  3.87k|      return std::pair{it, end};
   47|  3.87k|   }
_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10contiguousERKNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT0_:
   40|  1.93k|   {
   41|  1.93k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  1.93k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  1.93k|      auto end = it + buffer.size();
   45|       |
   46|  1.93k|      return std::pair{it, end};
   47|  1.93k|   }
_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10contiguousERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEEEDaOT0_:
   40|  1.93k|   {
   41|  1.93k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  1.93k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  1.93k|      auto end = it + buffer.size();
   45|       |
   46|  1.93k|      return std::pair{it, end};
   47|  1.93k|   }

_ZN3glz6detail16read_json_stringITkNS_10is_contextERNS_7contextERPKcS5_EENSt3__117basic_string_viewIcNS7_11char_traitsIcEEEEOT_OT0_T1_:
  156|   230k|   {
  157|   230k|      auto start = it;
  158|   230k|      ++it; // skip quote
  159|       |      // The bound as a pointer, so each chunk costs one compare. Where eight bytes are not left,
  160|       |      // the fallback is the opening quote, which sits before `it` and fails the test on the first
  161|       |      // look; never `it` itself, which would pass and read a chunk past `end`.
  162|   230k|      const auto* const chunk_limit = (end - it >= 8) ? end - 8 : it - 1;
  ------------------
  |  Branch (162:39): [True: 230k, False: 691]
  ------------------
  163|  2.71M|      while (it <= chunk_limit) {
  ------------------
  |  Branch (163:14): [True: 2.71M, False: 857]
  ------------------
  164|  2.71M|         uint64_t chunk;
  165|  2.71M|         std::memcpy(&chunk, it, 8);
  166|       |         if constexpr (std::endian::native == std::endian::big) {
  167|       |            chunk = std::byteswap(chunk);
  168|       |         }
  169|  2.71M|         const uint64_t quote = has_quote(chunk);
  170|  2.71M|         if (quote) {
  ------------------
  |  Branch (170:14): [True: 230k, False: 2.48M]
  ------------------
  171|   230k|            it += (countr_zero(quote) >> 3);
  172|       |
  173|   230k|            auto* prev = it - 1;
  174|   232k|            while (*prev == '\\') {
  ------------------
  |  Branch (174:20): [True: 1.27k, False: 230k]
  ------------------
  175|  1.27k|               --prev;
  176|  1.27k|            }
  177|   230k|            if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (177:17): [True: 230k, False: 763]
  ------------------
  178|   230k|               ++it; // add quote
  179|   230k|               return {start, size_t(it - start)};
  180|   230k|            }
  181|    763|            ++it; // skip escaped quote and continue
  182|    763|         }
  183|  2.48M|         else {
  184|  2.48M|            it += 8;
  185|  2.48M|         }
  186|  2.71M|      }
  187|       |
  188|  1.71k|      while (it < end) {
  ------------------
  |  Branch (188:14): [True: 1.46k, False: 252]
  ------------------
  189|  1.46k|         if (*it == '"') {
  ------------------
  |  Branch (189:14): [True: 670, False: 792]
  ------------------
  190|    670|            auto* prev = it - 1;
  191|  2.12k|            while (*prev == '\\') {
  ------------------
  |  Branch (191:20): [True: 1.45k, False: 670]
  ------------------
  192|  1.45k|               --prev;
  193|  1.45k|            }
  194|    670|            if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (194:17): [True: 605, False: 65]
  ------------------
  195|    605|               ++it; // add quote
  196|    605|               return {start, size_t(it - start)};
  197|    605|            }
  198|    670|         }
  199|    857|         ++it;
  200|    857|      }
  201|       |
  202|    252|      ctx.error = error_code::unexpected_end;
  203|    252|      return {};
  204|    857|   }
_ZN3glz6detail10emit_bytesILb1ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextENS2_17basic_string_viewIcS5_EEEEbRT1_RT0_RmRKT2_:
   91|   372k|   {
   92|   372k|      using T = std::remove_cvref_t<decltype(x)>;
   93|       |      if constexpr (byte_sized<T>) {
   94|       |         if constexpr (has_bounded_capacity<B>) {
   95|       |            if (not ensure_space(ctx, b, ix + 1)) [[unlikely]] {
   96|       |               return false;
   97|       |            }
   98|       |         }
   99|       |         dump<Checked>(x, b, ix);
  100|       |      }
  101|   372k|      else {
  102|   372k|         const sv s = [&] {
  103|   372k|            if constexpr (std::is_bounded_array_v<T>) {
  104|   372k|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|   372k|            }
  106|   372k|            else {
  107|   372k|               return sv{x};
  108|   372k|            }
  109|   372k|         }();
  110|       |         if constexpr (has_bounded_capacity<B>) {
  111|       |            if (not ensure_space(ctx, b, ix + s.size())) [[unlikely]] {
  112|       |               return false;
  113|       |            }
  114|       |         }
  115|   372k|         dump<Checked>(s, b, ix);
  116|   372k|      }
  117|   372k|      return true;
  118|   372k|   }
_ZZN3glz6detail10emit_bytesILb1ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextENS2_17basic_string_viewIcS5_EEEEbRT1_RT0_RmRKT2_ENKUlvE_clEv:
  102|   372k|         const sv s = [&] {
  103|       |            if constexpr (std::is_bounded_array_v<T>) {
  104|       |               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|       |            }
  106|   372k|            else {
  107|   372k|               return sv{x};
  108|   372k|            }
  109|   372k|         }();
_ZN3glz6detail10emit_bytesILb1ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextEcEEbRT1_RT0_RmRKT2_:
   91|   119M|   {
   92|   119M|      using T = std::remove_cvref_t<decltype(x)>;
   93|   119M|      if constexpr (byte_sized<T>) {
   94|       |         if constexpr (has_bounded_capacity<B>) {
   95|       |            if (not ensure_space(ctx, b, ix + 1)) [[unlikely]] {
   96|       |               return false;
   97|       |            }
   98|       |         }
   99|   119M|         dump<Checked>(x, b, ix);
  100|       |      }
  101|       |      else {
  102|       |         const sv s = [&] {
  103|       |            if constexpr (std::is_bounded_array_v<T>) {
  104|       |               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|       |            }
  106|       |            else {
  107|       |               return sv{x};
  108|       |            }
  109|       |         }();
  110|       |         if constexpr (has_bounded_capacity<B>) {
  111|       |            if (not ensure_space(ctx, b, ix + s.size())) [[unlikely]] {
  112|       |               return false;
  113|       |            }
  114|       |         }
  115|       |         dump<Checked>(s, b, ix);
  116|       |      }
  117|   119M|      return true;
  118|   119M|   }
_ZN3glz6detail15append_new_lineILb0ELh3ERNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEERmEEvOT1_OT2_l:
   63|   119M|   {
   64|   119M|      dump('\n', b, ix);
   65|       |      if constexpr (use_tabs) {
   66|       |         dumpn('\t', indent, b, ix);
   67|       |      }
   68|   119M|      else {
   69|   119M|         dumpn(' ', indent * indentation_width, b, ix);
   70|   119M|      }
   71|   119M|   };
_ZN3glz6detail16read_json_numberILb0ERPKcS3_EENSt3__117basic_string_viewIcNS5_11char_traitsIcEEEEOT0_T1_:
  304|  53.7k|   {
  305|  53.7k|      auto start = it;
  306|       |      if constexpr (null_terminated) {
  307|       |         while (numeric_table[uint8_t(*it)]) {
  308|       |            ++it;
  309|       |         }
  310|       |      }
  311|  53.7k|      else {
  312|  2.69M|         while ((it < end) && numeric_table[uint8_t(*it)]) {
  ------------------
  |  Branch (312:17): [True: 2.69M, False: 153]
  |  Branch (312:31): [True: 2.64M, False: 53.5k]
  ------------------
  313|  2.64M|            ++it;
  314|  2.64M|         }
  315|  53.7k|      }
  316|  53.7k|      return {start, size_t(it - start)};
  317|  53.7k|   }
_ZN3glz6detail13match_literalITnNS_14string_literalEXtlNS2_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETkNS_10is_contextERNS_7contextERPKcS8_EEbOT0_OT1_T2_:
  130|  6.64k|   {
  131|  6.64k|      static constexpr auto s = literal.sv();
  132|  6.64k|      if (end - it < std::ptrdiff_t(s.size())) [[unlikely]] {
  ------------------
  |  Branch (132:11): [True: 63, False: 6.57k]
  ------------------
  133|     63|         ctx.error = error_code::unexpected_end;
  134|     63|         return false;
  135|     63|      }
  136|  6.57k|      if (not comparitor<s>(it)) [[unlikely]] {
  ------------------
  |  Branch (136:11): [True: 333, False: 6.24k]
  ------------------
  137|    333|         ctx.error = error_code::syntax_error;
  138|    333|         return false;
  139|    333|      }
  140|  6.24k|      it += s.size();
  141|  6.24k|      return true;
  142|  6.57k|   }
_ZN3glz6detail10emit_bytesILb1ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextEA5_cEEbRT1_RT0_RmRKT2_:
   91|  14.3k|   {
   92|  14.3k|      using T = std::remove_cvref_t<decltype(x)>;
   93|       |      if constexpr (byte_sized<T>) {
   94|       |         if constexpr (has_bounded_capacity<B>) {
   95|       |            if (not ensure_space(ctx, b, ix + 1)) [[unlikely]] {
   96|       |               return false;
   97|       |            }
   98|       |         }
   99|       |         dump<Checked>(x, b, ix);
  100|       |      }
  101|  14.3k|      else {
  102|  14.3k|         const sv s = [&] {
  103|  14.3k|            if constexpr (std::is_bounded_array_v<T>) {
  104|  14.3k|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|  14.3k|            }
  106|  14.3k|            else {
  107|  14.3k|               return sv{x};
  108|  14.3k|            }
  109|  14.3k|         }();
  110|       |         if constexpr (has_bounded_capacity<B>) {
  111|       |            if (not ensure_space(ctx, b, ix + s.size())) [[unlikely]] {
  112|       |               return false;
  113|       |            }
  114|       |         }
  115|  14.3k|         dump<Checked>(s, b, ix);
  116|  14.3k|      }
  117|  14.3k|      return true;
  118|  14.3k|   }
_ZZN3glz6detail10emit_bytesILb1ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextEA5_cEEbRT1_RT0_RmRKT2_ENKUlvE_clEv:
  102|  14.3k|         const sv s = [&] {
  103|  14.3k|            if constexpr (std::is_bounded_array_v<T>) {
  104|  14.3k|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|       |            }
  106|       |            else {
  107|       |               return sv{x};
  108|       |            }
  109|  14.3k|         }();
_ZN3glz6detail13match_literalITnNS_14string_literalEXtlNS2_ILm5EEEtlA5_cLc116ELc114ELc117ELc101EEEETkNS_10is_contextERNS_7contextERPKcS8_EEbOT0_OT1_T2_:
  130|  8.46k|   {
  131|  8.46k|      static constexpr auto s = literal.sv();
  132|  8.46k|      if (end - it < std::ptrdiff_t(s.size())) [[unlikely]] {
  ------------------
  |  Branch (132:11): [True: 88, False: 8.38k]
  ------------------
  133|     88|         ctx.error = error_code::unexpected_end;
  134|     88|         return false;
  135|     88|      }
  136|  8.38k|      if (not comparitor<s>(it)) [[unlikely]] {
  ------------------
  |  Branch (136:11): [True: 310, False: 8.07k]
  ------------------
  137|    310|         ctx.error = error_code::syntax_error;
  138|    310|         return false;
  139|    310|      }
  140|  8.07k|      it += s.size();
  141|  8.07k|      return true;
  142|  8.38k|   }
_ZN3glz6detail13match_literalITnNS_14string_literalEXtlNS2_ILm6EEEtlA6_cLc102ELc97ELc108ELc115ELc101EEEETkNS_10is_contextERNS_7contextERPKcS8_EEbOT0_OT1_T2_:
  130|  4.96k|   {
  131|  4.96k|      static constexpr auto s = literal.sv();
  132|  4.96k|      if (end - it < std::ptrdiff_t(s.size())) [[unlikely]] {
  ------------------
  |  Branch (132:11): [True: 130, False: 4.83k]
  ------------------
  133|    130|         ctx.error = error_code::unexpected_end;
  134|    130|         return false;
  135|    130|      }
  136|  4.83k|      if (not comparitor<s>(it)) [[unlikely]] {
  ------------------
  |  Branch (136:11): [True: 440, False: 4.39k]
  ------------------
  137|    440|         ctx.error = error_code::syntax_error;
  138|    440|         return false;
  139|    440|      }
  140|  4.39k|      it += s.size();
  141|  4.39k|      return true;
  142|  4.83k|   }
_ZN3glz6detail10emit_bytesILb1ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextEA6_cEEbRT1_RT0_RmRKT2_:
   91|  4.39k|   {
   92|  4.39k|      using T = std::remove_cvref_t<decltype(x)>;
   93|       |      if constexpr (byte_sized<T>) {
   94|       |         if constexpr (has_bounded_capacity<B>) {
   95|       |            if (not ensure_space(ctx, b, ix + 1)) [[unlikely]] {
   96|       |               return false;
   97|       |            }
   98|       |         }
   99|       |         dump<Checked>(x, b, ix);
  100|       |      }
  101|  4.39k|      else {
  102|  4.39k|         const sv s = [&] {
  103|  4.39k|            if constexpr (std::is_bounded_array_v<T>) {
  104|  4.39k|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|  4.39k|            }
  106|  4.39k|            else {
  107|  4.39k|               return sv{x};
  108|  4.39k|            }
  109|  4.39k|         }();
  110|       |         if constexpr (has_bounded_capacity<B>) {
  111|       |            if (not ensure_space(ctx, b, ix + s.size())) [[unlikely]] {
  112|       |               return false;
  113|       |            }
  114|       |         }
  115|  4.39k|         dump<Checked>(s, b, ix);
  116|  4.39k|      }
  117|  4.39k|      return true;
  118|  4.39k|   }
_ZZN3glz6detail10emit_bytesILb1ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextEA6_cEEbRT1_RT0_RmRKT2_ENKUlvE_clEv:
  102|  4.39k|         const sv s = [&] {
  103|  4.39k|            if constexpr (std::is_bounded_array_v<T>) {
  104|  4.39k|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|       |            }
  106|       |            else {
  107|       |               return sv{x};
  108|       |            }
  109|  4.39k|         }();
_ZN3glz6detail18read_jsonc_commentITkNS_10is_contextERNS_7contextERPKcS5_EENS0_13jsonc_commentEOT_OT0_T1_:
  227|  15.4k|   {
  228|  15.4k|      const auto start = it;
  229|  15.4k|      ++it; // past the opening '/'
  230|       |
  231|       |      // The caller matched one '/'; that says nothing about a second byte being there at all.
  232|       |      // Stepping over both regardless leaves `it` past `end`, and every scan the caller runs after
  233|       |      // this one starts from there.
  234|  15.4k|      if (it == end) [[unlikely]] {
  ------------------
  |  Branch (234:11): [True: 16, False: 15.4k]
  ------------------
  235|     16|         ctx.error = error_code::unexpected_end;
  236|     16|         return {};
  237|     16|      }
  238|       |
  239|  15.4k|      if (*it == '/') {
  ------------------
  |  Branch (239:11): [True: 13.8k, False: 1.52k]
  ------------------
  240|  13.8k|         ++it; // past the second '/'
  241|  2.04M|         while (it != end && *it != '\n' && *it != '\r') {
  ------------------
  |  Branch (241:17): [True: 2.04M, False: 150]
  |  Branch (241:30): [True: 2.04M, False: 3.35k]
  |  Branch (241:45): [True: 2.03M, False: 10.3k]
  ------------------
  242|  2.03M|            ++it;
  243|  2.03M|         }
  244|       |         // The terminator is left where it is: minify drops it along with the rest of the
  245|       |         // whitespace and prettify emits its own break. A carriage return ends the comment on its
  246|       |         // own, so a file with CR line endings is not swallowed by its first comment; a line feed
  247|       |         // behind it is then ordinary whitespace.
  248|  13.8k|         return {sv{start, size_t(it - start)}, true};
  249|  13.8k|      }
  250|       |
  251|  1.52k|      if (*it != '*') [[unlikely]] {
  ------------------
  |  Branch (251:11): [True: 72, False: 1.45k]
  ------------------
  252|     72|         ctx.error = error_code::expected_end_comment;
  253|     72|         return {};
  254|     72|      }
  255|  1.45k|      ++it; // past the '*' of the opener
  256|       |
  257|       |      // Only a '*' after the opening delimiter can close the comment, which is what the `content`
  258|       |      // guards below are for: without them the '*' of the opener closes the comment it opened, so
  259|       |      // "/*/" reads as complete and swallows whatever follows it.
  260|  1.45k|      const auto content = it;
  261|       |
  262|       |      // The bound as a pointer, so each chunk costs one compare. `end - 8` only points into the
  263|       |      // buffer once that much of it is left; where it is not, the fallback is the byte before the
  264|       |      // cursor, which is inside the opener and so fails the test on the first look. Never `it`
  265|       |      // itself -- that passes, and the chunk behind it would read past the end of the buffer.
  266|  1.45k|      const auto* const chunk_limit = (end - it >= 8) ? end - 8 : it - 1;
  ------------------
  |  Branch (266:39): [True: 1.35k, False: 100]
  ------------------
  267|  1.05M|      while (it <= chunk_limit) {
  ------------------
  |  Branch (267:14): [True: 1.05M, False: 272]
  ------------------
  268|  1.05M|         uint64_t chunk;
  269|  1.05M|         std::memcpy(&chunk, it, 8);
  270|       |         if constexpr (std::endian::native == std::endian::big) {
  271|       |            chunk = std::byteswap(chunk);
  272|       |         }
  273|  1.05M|         const uint64_t slash = has_char<'/'>(chunk);
  274|  1.05M|         if (slash) {
  ------------------
  |  Branch (274:14): [True: 184k, False: 869k]
  ------------------
  275|   184k|            it += (countr_zero(slash) >> 3);
  276|       |
  277|   184k|            if (it > content && it[-1] == '*') {
  ------------------
  |  Branch (277:17): [True: 183k, False: 672]
  |  Branch (277:33): [True: 1.18k, False: 182k]
  ------------------
  278|  1.18k|               ++it; // add slash
  279|  1.18k|               return {sv{start, size_t(it - start)}, false};
  280|  1.18k|            }
  281|       |            // skip slash and continue
  282|   183k|            ++it;
  283|   183k|         }
  284|   869k|         else {
  285|   869k|            it += 8;
  286|   869k|         }
  287|  1.05M|      }
  288|       |
  289|       |      // Tail end of buffer. Should be rare we even get here
  290|  1.09k|      while (it < end) {
  ------------------
  |  Branch (290:14): [True: 866, False: 230]
  ------------------
  291|    866|         if (it > content && it[-1] == '*' && *it == '/') {
  ------------------
  |  Branch (291:14): [True: 770, False: 96]
  |  Branch (291:30): [True: 108, False: 662]
  |  Branch (291:47): [True: 42, False: 66]
  ------------------
  292|     42|            ++it; // add slash
  293|     42|            return {sv{start, size_t(it - start)}, false};
  294|     42|         }
  295|    824|         ++it;
  296|    824|      }
  297|       |
  298|    230|      ctx.error = error_code::expected_end_comment;
  299|    230|      return {};
  300|    272|   }
_ZN3glz6detail16read_json_numberILb1ERPKcS3_EENSt3__117basic_string_viewIcNS5_11char_traitsIcEEEEOT0_T1_:
  304|  22.6k|   {
  305|  22.6k|      auto start = it;
  306|  22.6k|      if constexpr (null_terminated) {
  307|   909k|         while (numeric_table[uint8_t(*it)]) {
  ------------------
  |  Branch (307:17): [True: 886k, False: 22.6k]
  ------------------
  308|   886k|            ++it;
  309|   886k|         }
  310|       |      }
  311|       |      else {
  312|       |         while ((it < end) && numeric_table[uint8_t(*it)]) {
  313|       |            ++it;
  314|       |         }
  315|       |      }
  316|  22.6k|      return {start, size_t(it - start)};
  317|  22.6k|   }

_ZN3glz13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEENSt3__16vectorIcNS2_9allocatorIcEEEEEENS2_12basic_stringIcNS2_11char_traitsIcEES5_EERKT0_:
  350|  3.87k|   {
  351|  3.87k|      context ctx{};
  352|  3.87k|      std::string out{};
  353|  3.87k|      detail::prettify_json<Opts>(ctx, in, out);
  354|  3.87k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (354:11): [True: 3.04k, False: 828]
  ------------------
  355|  3.04k|         return {}; // an incomplete result is not a document; see above
  356|  3.04k|      }
  357|    828|      return out;
  358|  3.87k|   }
_ZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10contiguousERKNSt3__16vectorIcNS3_9allocatorIcEEEETkNS_13output_bufferERNS3_12basic_stringIcNS3_11char_traitsIcEES6_EETkNS_10is_contextERNS_7contextEEEmOT2_OT0_OT1_:
  294|  3.87k|      {
  295|  3.87k|         if constexpr (resizable<Out>) {
  296|  3.87k|            if (in.size() == 0) {
  ------------------
  |  Branch (296:17): [True: 0, False: 3.87k]
  ------------------
  297|      0|               out.resize(0); // resize is what `resizable` promises; clear() is not
  298|      0|               return 0;
  299|      0|            }
  300|  3.87k|            out.resize(in.size() * 2);
  301|  3.87k|         }
  302|      0|         size_t ix = 0;
  303|  3.87k|         auto [it, end] = read_iterators<Opts>(in);
  304|  3.87k|         if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (304:14): [True: 0, False: 3.87k]
  ------------------
  305|      0|            return 0;
  306|      0|         }
  307|       |
  308|       |         if constexpr (self_terminating<In>) {
  309|       |            prettify_json<opt_true<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  310|       |         }
  311|  3.87k|         else {
  312|  3.87k|            prettify_json<opt_false<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  313|  3.87k|         }
  314|       |
  315|  3.87k|         if constexpr (resizable<Out>) {
  316|  3.87k|            out.resize(ix);
  317|  3.87k|         }
  318|  3.87k|         return ix;
  319|  3.87k|      }
_ZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_:
   17|  3.87k|      {
   18|  3.87k|         constexpr bool use_tabs = check_indentation_char(Opts) == '\t';
   19|  3.87k|         constexpr auto indent_width = check_indentation_width(Opts);
   20|       |
   21|  3.87k|         using enum json_type;
   22|       |
   23|       |         // Indexed by nesting level, with level 0 the top. Sized for the depth the readers accept (see
   24|       |         // enter_depth), so that every document glz::validate_jsonc passes can be prettified.
   25|  3.87k|         std::array<json_type, max_recursive_depth_limit + 1> state{};
   26|  3.87k|         int64_t indent{};
   27|       |
   28|       |         // Enters one level of nesting, failing past the readers' limit.
   29|  3.87k|         const auto open_level = [&](const json_type type) {
   30|  3.87k|            if (size_t(indent) >= max_recursive_depth_limit) [[unlikely]] {
   31|  3.87k|               ctx.error = error_code::exceeded_max_recursive_depth;
   32|  3.87k|               return false;
   33|  3.87k|            }
   34|  3.87k|            state[++indent] = type;
   35|  3.87k|            return true;
   36|  3.87k|         };
   37|       |
   38|       |         // Set while the output cursor sits on a line that a `//` comment has commented out. Only
   39|       |         // the comment-enabled path can set it, so the plain JSON writer keeps the code it had.
   40|  3.87k|         [[maybe_unused]] bool line_comment_open = false;
   41|       |
   42|       |         // Every line break the writer emits goes through this, because a break is also what ends a
   43|       |         // line comment: doing it in one place is what keeps the two from doubling up. The newline
   44|       |         // and the indentation behind it are also what make the output unbounded -- there is no
   45|       |         // bound on prettified output that a single reservation up front could use -- so this is
   46|       |         // the write a bounded destination is likeliest to run out on.
   47|  3.87k|         const auto new_line = [&] {
   48|  3.87k|            if constexpr (has_bounded_capacity<decltype(b)>) {
   49|  3.87k|               const size_t n = use_tabs ? size_t(indent) : size_t(indent) * indent_width;
   50|  3.87k|               if (not ensure_space(ctx, b, ix + 1 + n)) [[unlikely]] {
   51|  3.87k|                  return false;
   52|  3.87k|               }
   53|  3.87k|            }
   54|  3.87k|            append_new_line<use_tabs, indent_width>(b, ix, indent);
   55|  3.87k|            if constexpr (Opts.comments) {
   56|  3.87k|               line_comment_open = false;
   57|  3.87k|            }
   58|  3.87k|            return true;
   59|  3.87k|         };
   60|       |
   61|       |         // Every write below goes through this, which is what fixes their order in one place: an
   62|       |         // open line comment is closed first, because anything written into one is commented out,
   63|       |         // and emit_bytes then takes the reservation from the argument rather than from a byte
   64|       |         // count spelled out beside the write.
   65|       |         //
   66|       |         // Deferring that break to the next write rather than emitting it with the comment is what
   67|       |         // keeps a comment at the end of the input from leaving a trailing newline behind, and lets
   68|       |         // a break the writer was going to emit anyway serve as this one.
   69|       |         //
   70|       |         // A break that fails is reported rather than swallowed: on a bounded destination that ran
   71|       |         // out, carrying on would leave `line_comment_open` set and put this write *inside* the
   72|       |         // comment, which is not a truncated document but a wrong one.
   73|  3.87k|         const auto put = [&](const auto& x) {
   74|  3.87k|            if constexpr (Opts.comments) {
   75|  3.87k|               if (line_comment_open) [[unlikely]] {
   76|  3.87k|                  if (not new_line()) [[unlikely]] {
   77|  3.87k|                     return false;
   78|  3.87k|                  }
   79|  3.87k|               }
   80|  3.87k|            }
   81|  3.87k|            return emit_bytes<true>(ctx, b, ix, x);
   82|  3.87k|         };
   83|       |
   84|  49.2M|         while (it < end) {
  ------------------
  |  Branch (84:17): [True: 49.2M, False: 828]
  ------------------
   85|  49.2M|            switch (json_types[uint8_t(*it)]) {
   86|  91.6k|            case String: {
  ------------------
  |  Branch (86:13): [True: 91.6k, False: 49.1M]
  ------------------
   87|  91.6k|               const auto value = read_json_string(ctx, it, end);
   88|  91.6k|               if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (88:20): [True: 122, False: 91.4k]
  ------------------
   89|    122|                  return;
   90|    122|               }
   91|       |               // non-empty: the scanner reports an empty view as an error
   92|  91.4k|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (92:20): [True: 0, False: 91.4k]
  ------------------
   93|      0|                  return;
   94|      0|               }
   95|  91.4k|               break;
   96|  91.4k|            }
   97|  48.4M|            case Comma: {
  ------------------
  |  Branch (97:13): [True: 48.4M, False: 825k]
  ------------------
   98|  48.4M|               if (not put(',')) [[unlikely]] {
  ------------------
  |  Branch (98:20): [True: 0, False: 48.4M]
  ------------------
   99|      0|                  return;
  100|      0|               }
  101|  48.4M|               ++it;
  102|  48.4M|               if constexpr (check_new_lines_in_arrays(Opts)) {
  103|  48.4M|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (103:23): [True: 0, False: 48.4M]
  ------------------
  104|      0|                     return;
  105|      0|                  }
  106|       |               }
  107|       |               else {
  108|       |                  if (state[indent] == Object_Start) {
  109|       |                     if (not new_line()) [[unlikely]] {
  110|       |                        return;
  111|       |                     }
  112|       |                  }
  113|       |                  else if (not put(use_tabs ? '\t' : ' ')) [[unlikely]] {
  114|       |                     return;
  115|       |                  }
  116|       |               }
  117|  48.4M|               break;
  118|  48.4M|            }
  119|  48.4M|            case Number: {
  ------------------
  |  Branch (119:13): [True: 31.0k, False: 49.2M]
  ------------------
  120|  31.0k|               const auto value = read_json_number<Opts.null_terminated>(it, end);
  121|       |               // non-empty: a Number match is one valid character
  122|  31.0k|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (122:20): [True: 0, False: 31.0k]
  ------------------
  123|      0|                  return;
  124|      0|               }
  125|  31.0k|               break;
  126|  31.0k|            }
  127|  31.0k|            case Colon: {
  ------------------
  |  Branch (127:13): [True: 21.7k, False: 49.2M]
  ------------------
  128|  21.7k|               static constexpr sv colon = use_tabs ? sv{":\t"} : sv{": "};
  ------------------
  |  Branch (128:44): [Folded, False: 21.7k]
  ------------------
  129|  21.7k|               if (not put(colon)) [[unlikely]] {
  ------------------
  |  Branch (129:20): [True: 0, False: 21.7k]
  ------------------
  130|      0|                  return;
  131|      0|               }
  132|  21.7k|               ++it;
  133|  21.7k|               break;
  134|  21.7k|            }
  135|   274k|            case Array_Start: {
  ------------------
  |  Branch (135:13): [True: 274k, False: 48.9M]
  ------------------
  136|   274k|               if (not put('[')) [[unlikely]] {
  ------------------
  |  Branch (136:20): [True: 0, False: 274k]
  ------------------
  137|      0|                  return;
  138|      0|               }
  139|   274k|               ++it;
  140|   274k|               if (not open_level(Array_Start)) [[unlikely]] {
  ------------------
  |  Branch (140:20): [True: 26, False: 273k]
  ------------------
  141|     26|                  return;
  142|     26|               }
  143|   273k|               if constexpr (check_new_lines_in_arrays(Opts)) {
  144|   273k|                  if constexpr (not Opts.null_terminated) {
  145|   273k|                     if (it != end && *it != ']') {
  ------------------
  |  Branch (145:26): [True: 273k, False: 120]
  |  Branch (145:39): [True: 272k, False: 1.24k]
  ------------------
  146|   272k|                        if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (146:29): [True: 0, False: 272k]
  ------------------
  147|      0|                           return;
  148|      0|                        }
  149|   272k|                     }
  150|       |                  }
  151|       |                  else {
  152|       |                     if (*it != ']') {
  153|       |                        if (not new_line()) [[unlikely]] {
  154|       |                           return;
  155|       |                        }
  156|       |                     }
  157|       |                  }
  158|   273k|               }
  159|   273k|               break;
  160|   274k|            }
  161|   273k|            case Array_End: {
  ------------------
  |  Branch (161:13): [True: 36.2k, False: 49.2M]
  ------------------
  162|  36.2k|               --indent;
  163|  36.2k|               if (indent < 0) {
  ------------------
  |  Branch (163:20): [True: 4, False: 36.2k]
  ------------------
  164|      4|                  ctx.error = error_code::syntax_error;
  165|      4|                  return;
  166|      4|               }
  167|       |               // This break is the one the bracket wanted anyway, and it closes an open line
  168|       |               // comment on its way, leaving the put below nothing to close.
  169|  36.2k|               if constexpr (check_new_lines_in_arrays(Opts)) {
  170|  36.2k|                  if (it[-1] != '[') {
  ------------------
  |  Branch (170:23): [True: 35.0k, False: 1.24k]
  ------------------
  171|  35.0k|                     if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (171:26): [True: 0, False: 35.0k]
  ------------------
  172|      0|                        return;
  173|      0|                     }
  174|  35.0k|                  }
  175|  36.2k|               }
  176|  36.2k|               if (not put(']')) [[unlikely]] {
  ------------------
  |  Branch (176:20): [True: 0, False: 36.2k]
  ------------------
  177|      0|                  return;
  178|      0|               }
  179|  36.2k|               ++it;
  180|  36.2k|               break;
  181|  36.2k|            }
  182|  3.05k|            case Null: {
  ------------------
  |  Branch (182:13): [True: 3.05k, False: 49.2M]
  ------------------
  183|       |               // The type table matched on the first byte alone; see match_literal for why writing
  184|       |               // the literal from the writer's own spelling needs the rest of it checked.
  185|  3.05k|               if (not match_literal<"null">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (185:20): [True: 196, False: 2.86k]
  ------------------
  186|    196|                  return;
  187|    196|               }
  188|  2.86k|               if (not put("null")) [[unlikely]] {
  ------------------
  |  Branch (188:20): [True: 0, False: 2.86k]
  ------------------
  189|      0|                  return;
  190|      0|               }
  191|  2.86k|               break;
  192|  2.86k|            }
  193|  4.00k|            case Bool: {
  ------------------
  |  Branch (193:13): [True: 4.00k, False: 49.2M]
  ------------------
  194|  4.00k|               if (*it == 't') {
  ------------------
  |  Branch (194:20): [True: 1.89k, False: 2.11k]
  ------------------
  195|  1.89k|                  if (not match_literal<"true">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (195:23): [True: 196, False: 1.70k]
  ------------------
  196|    196|                     return;
  197|    196|                  }
  198|  1.70k|                  if (not put("true")) [[unlikely]] {
  ------------------
  |  Branch (198:23): [True: 0, False: 1.70k]
  ------------------
  199|      0|                     return;
  200|      0|                  }
  201|  1.70k|                  break;
  202|  1.70k|               }
  203|  2.11k|               else {
  204|  2.11k|                  if (not match_literal<"false">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (204:23): [True: 276, False: 1.83k]
  ------------------
  205|    276|                     return;
  206|    276|                  }
  207|  1.83k|                  if (not put("false")) [[unlikely]] {
  ------------------
  |  Branch (207:23): [True: 0, False: 1.83k]
  ------------------
  208|      0|                     return;
  209|      0|                  }
  210|  1.83k|                  break;
  211|  1.83k|               }
  212|  4.00k|            }
  213|   151k|            case Object_Start: {
  ------------------
  |  Branch (213:13): [True: 151k, False: 49.0M]
  ------------------
  214|   151k|               if (not put('{')) [[unlikely]] {
  ------------------
  |  Branch (214:20): [True: 0, False: 151k]
  ------------------
  215|      0|                  return;
  216|      0|               }
  217|   151k|               ++it;
  218|   151k|               if (not open_level(Object_Start)) [[unlikely]] {
  ------------------
  |  Branch (218:20): [True: 26, False: 151k]
  ------------------
  219|     26|                  return;
  220|     26|               }
  221|   151k|               if constexpr (not Opts.null_terminated) {
  222|   151k|                  if (it != end && *it != '}') {
  ------------------
  |  Branch (222:23): [True: 151k, False: 106]
  |  Branch (222:36): [True: 148k, False: 2.67k]
  ------------------
  223|   148k|                     if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (223:26): [True: 0, False: 148k]
  ------------------
  224|      0|                        return;
  225|      0|                     }
  226|   148k|                  }
  227|       |               }
  228|       |               else {
  229|       |                  if (*it != '}') {
  230|       |                     if (not new_line()) [[unlikely]] {
  231|       |                        return;
  232|       |                     }
  233|       |                  }
  234|       |               }
  235|   151k|               break;
  236|   151k|            }
  237|   208k|            case Object_End: {
  ------------------
  |  Branch (237:13): [True: 208k, False: 49.0M]
  ------------------
  238|   208k|               --indent;
  239|   208k|               if (indent < 0) {
  ------------------
  |  Branch (239:20): [True: 4, False: 208k]
  ------------------
  240|      4|                  ctx.error = error_code::syntax_error;
  241|      4|                  return;
  242|      4|               }
  243|       |               // As in Array_End, this break doubles as the close of an open line comment.
  244|   208k|               if (it[-1] != '{') {
  ------------------
  |  Branch (244:20): [True: 205k, False: 2.67k]
  ------------------
  245|   205k|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (245:23): [True: 0, False: 205k]
  ------------------
  246|      0|                     return;
  247|      0|                  }
  248|   205k|               }
  249|   208k|               if (not put('}')) [[unlikely]] {
  ------------------
  |  Branch (249:20): [True: 0, False: 208k]
  ------------------
  250|      0|                  return;
  251|      0|               }
  252|   208k|               ++it;
  253|   208k|               break;
  254|   208k|            }
  255|    842|            case Comment: {
  ------------------
  |  Branch (255:13): [True: 842, False: 49.2M]
  ------------------
  256|       |               if constexpr (Opts.comments) {
  257|       |                  const auto comment = read_jsonc_comment(ctx, it, end);
  258|       |                  if (bool(ctx.error)) [[unlikely]] {
  259|       |                     return;
  260|       |                  }
  261|       |                  // non-empty: an empty view comes with an error
  262|       |                  if (not put(comment.text)) [[unlikely]] {
  263|       |                     return;
  264|       |                  }
  265|       |                  line_comment_open = comment.line;
  266|       |                  break;
  267|       |               }
  268|    842|               else {
  269|       |                  // A '/' opens a comment, and plain JSON has none. Skipping it as though it were
  270|       |                  // whitespace silently rewrote the document: "{\"a\":1} // tail" came out as
  271|       |                  // "{...}true", the 't' of "tail" taken for a literal. minify_json has always
  272|       |                  // reported this, and the two had no business disagreeing.
  273|    842|                  ctx.error = error_code::syntax_error;
  274|    842|                  return;
  275|    842|               }
  276|    842|            }
  277|  2.53k|            case Whitespace: {
  ------------------
  |  Branch (277:13): [True: 1.69k, False: 49.2M]
  ------------------
  278|       |               // Skip whitespace characters that are part of raw JSON content
  279|  2.53k|               ++it;
  280|  2.53k|               break;
  281|    842|            }
  282|  1.35k|            [[unlikely]] default: {
  ------------------
  |  Branch (282:26): [True: 1.35k, False: 49.2M]
  ------------------
  283|  1.35k|               ctx.error = error_code::syntax_error;
  284|  1.35k|               return;
  285|      0|            }
  286|  49.2M|            }
  287|  49.2M|         }
  288|  3.87k|      }
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clINS8_17basic_string_viewIcSB_EEEEDaSS_:
   73|   144k|         const auto put = [&](const auto& x) {
   74|       |            if constexpr (Opts.comments) {
   75|       |               if (line_comment_open) [[unlikely]] {
   76|       |                  if (not new_line()) [[unlikely]] {
   77|       |                     return false;
   78|       |                  }
   79|       |               }
   80|       |            }
   81|   144k|            return emit_bytes<true>(ctx, b, ix, x);
   82|   144k|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIcEEDaSS_:
   73|  49.0M|         const auto put = [&](const auto& x) {
   74|       |            if constexpr (Opts.comments) {
   75|       |               if (line_comment_open) [[unlikely]] {
   76|       |                  if (not new_line()) [[unlikely]] {
   77|       |                     return false;
   78|       |                  }
   79|       |               }
   80|       |            }
   81|  49.0M|            return emit_bytes<true>(ctx, b, ix, x);
   82|  49.0M|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE_clEv:
   47|  49.0M|         const auto new_line = [&] {
   48|       |            if constexpr (has_bounded_capacity<decltype(b)>) {
   49|       |               const size_t n = use_tabs ? size_t(indent) : size_t(indent) * indent_width;
   50|       |               if (not ensure_space(ctx, b, ix + 1 + n)) [[unlikely]] {
   51|       |                  return false;
   52|       |               }
   53|       |            }
   54|  49.0M|            append_new_line<use_tabs, indent_width>(b, ix, indent);
   55|       |            if constexpr (Opts.comments) {
   56|       |               line_comment_open = false;
   57|       |            }
   58|  49.0M|            return true;
   59|  49.0M|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlNS0_9json_typeEE_clESQ_:
   29|   425k|         const auto open_level = [&](const json_type type) {
   30|   425k|            if (size_t(indent) >= max_recursive_depth_limit) [[unlikely]] {
  ------------------
  |  Branch (30:17): [True: 52, False: 425k]
  ------------------
   31|     52|               ctx.error = error_code::exceeded_max_recursive_depth;
   32|     52|               return false;
   33|     52|            }
   34|   425k|            state[++indent] = type;
   35|   425k|            return true;
   36|   425k|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA5_cEEDaSS_:
   73|  4.56k|         const auto put = [&](const auto& x) {
   74|       |            if constexpr (Opts.comments) {
   75|       |               if (line_comment_open) [[unlikely]] {
   76|       |                  if (not new_line()) [[unlikely]] {
   77|       |                     return false;
   78|       |                  }
   79|       |               }
   80|       |            }
   81|  4.56k|            return emit_bytes<true>(ctx, b, ix, x);
   82|  4.56k|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA6_cEEDaSS_:
   73|  1.83k|         const auto put = [&](const auto& x) {
   74|       |            if constexpr (Opts.comments) {
   75|       |               if (line_comment_open) [[unlikely]] {
   76|       |                  if (not new_line()) [[unlikely]] {
   77|       |                     return false;
   78|       |                  }
   79|       |               }
   80|       |            }
   81|  1.83k|            return emit_bytes<true>(ctx, b, ix, x);
   82|  1.83k|         };
_ZN3glz14prettify_jsoncITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEENSt3__16vectorIcNS2_9allocatorIcEEEEEENS2_12basic_stringIcNS2_11char_traitsIcEES5_EERKT0_:
  373|  1.93k|   {
  374|  1.93k|      context ctx{};
  375|  1.93k|      std::string out{};
  376|  1.93k|      detail::prettify_json<opt_true<Opts, &opts::comments>>(ctx, in, out);
  377|  1.93k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (377:11): [True: 920, False: 1.01k]
  ------------------
  378|    920|         return {}; // an incomplete result is not a document; see above
  379|    920|      }
  380|  1.01k|      return out;
  381|  1.93k|   }
_ZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10contiguousERKNSt3__16vectorIcNS3_9allocatorIcEEEETkNS_13output_bufferERNS3_12basic_stringIcNS3_11char_traitsIcEES6_EETkNS_10is_contextERNS_7contextEEEmOT2_OT0_OT1_:
  294|  1.93k|      {
  295|  1.93k|         if constexpr (resizable<Out>) {
  296|  1.93k|            if (in.size() == 0) {
  ------------------
  |  Branch (296:17): [True: 0, False: 1.93k]
  ------------------
  297|      0|               out.resize(0); // resize is what `resizable` promises; clear() is not
  298|      0|               return 0;
  299|      0|            }
  300|  1.93k|            out.resize(in.size() * 2);
  301|  1.93k|         }
  302|      0|         size_t ix = 0;
  303|  1.93k|         auto [it, end] = read_iterators<Opts>(in);
  304|  1.93k|         if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (304:14): [True: 0, False: 1.93k]
  ------------------
  305|      0|            return 0;
  306|      0|         }
  307|       |
  308|       |         if constexpr (self_terminating<In>) {
  309|       |            prettify_json<opt_true<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  310|       |         }
  311|  1.93k|         else {
  312|  1.93k|            prettify_json<opt_false<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  313|  1.93k|         }
  314|       |
  315|  1.93k|         if constexpr (resizable<Out>) {
  316|  1.93k|            out.resize(ix);
  317|  1.93k|         }
  318|  1.93k|         return ix;
  319|  1.93k|      }
_ZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_:
   17|  1.93k|      {
   18|  1.93k|         constexpr bool use_tabs = check_indentation_char(Opts) == '\t';
   19|  1.93k|         constexpr auto indent_width = check_indentation_width(Opts);
   20|       |
   21|  1.93k|         using enum json_type;
   22|       |
   23|       |         // Indexed by nesting level, with level 0 the top. Sized for the depth the readers accept (see
   24|       |         // enter_depth), so that every document glz::validate_jsonc passes can be prettified.
   25|  1.93k|         std::array<json_type, max_recursive_depth_limit + 1> state{};
   26|  1.93k|         int64_t indent{};
   27|       |
   28|       |         // Enters one level of nesting, failing past the readers' limit.
   29|  1.93k|         const auto open_level = [&](const json_type type) {
   30|  1.93k|            if (size_t(indent) >= max_recursive_depth_limit) [[unlikely]] {
   31|  1.93k|               ctx.error = error_code::exceeded_max_recursive_depth;
   32|  1.93k|               return false;
   33|  1.93k|            }
   34|  1.93k|            state[++indent] = type;
   35|  1.93k|            return true;
   36|  1.93k|         };
   37|       |
   38|       |         // Set while the output cursor sits on a line that a `//` comment has commented out. Only
   39|       |         // the comment-enabled path can set it, so the plain JSON writer keeps the code it had.
   40|  1.93k|         [[maybe_unused]] bool line_comment_open = false;
   41|       |
   42|       |         // Every line break the writer emits goes through this, because a break is also what ends a
   43|       |         // line comment: doing it in one place is what keeps the two from doubling up. The newline
   44|       |         // and the indentation behind it are also what make the output unbounded -- there is no
   45|       |         // bound on prettified output that a single reservation up front could use -- so this is
   46|       |         // the write a bounded destination is likeliest to run out on.
   47|  1.93k|         const auto new_line = [&] {
   48|  1.93k|            if constexpr (has_bounded_capacity<decltype(b)>) {
   49|  1.93k|               const size_t n = use_tabs ? size_t(indent) : size_t(indent) * indent_width;
   50|  1.93k|               if (not ensure_space(ctx, b, ix + 1 + n)) [[unlikely]] {
   51|  1.93k|                  return false;
   52|  1.93k|               }
   53|  1.93k|            }
   54|  1.93k|            append_new_line<use_tabs, indent_width>(b, ix, indent);
   55|  1.93k|            if constexpr (Opts.comments) {
   56|  1.93k|               line_comment_open = false;
   57|  1.93k|            }
   58|  1.93k|            return true;
   59|  1.93k|         };
   60|       |
   61|       |         // Every write below goes through this, which is what fixes their order in one place: an
   62|       |         // open line comment is closed first, because anything written into one is commented out,
   63|       |         // and emit_bytes then takes the reservation from the argument rather than from a byte
   64|       |         // count spelled out beside the write.
   65|       |         //
   66|       |         // Deferring that break to the next write rather than emitting it with the comment is what
   67|       |         // keeps a comment at the end of the input from leaving a trailing newline behind, and lets
   68|       |         // a break the writer was going to emit anyway serve as this one.
   69|       |         //
   70|       |         // A break that fails is reported rather than swallowed: on a bounded destination that ran
   71|       |         // out, carrying on would leave `line_comment_open` set and put this write *inside* the
   72|       |         // comment, which is not a truncated document but a wrong one.
   73|  1.93k|         const auto put = [&](const auto& x) {
   74|  1.93k|            if constexpr (Opts.comments) {
   75|  1.93k|               if (line_comment_open) [[unlikely]] {
   76|  1.93k|                  if (not new_line()) [[unlikely]] {
   77|  1.93k|                     return false;
   78|  1.93k|                  }
   79|  1.93k|               }
   80|  1.93k|            }
   81|  1.93k|            return emit_bytes<true>(ctx, b, ix, x);
   82|  1.93k|         };
   83|       |
   84|  35.4M|         while (it < end) {
  ------------------
  |  Branch (84:17): [True: 35.4M, False: 1.01k]
  ------------------
   85|  35.4M|            switch (json_types[uint8_t(*it)]) {
   86|  69.6k|            case String: {
  ------------------
  |  Branch (86:13): [True: 69.6k, False: 35.3M]
  ------------------
   87|  69.6k|               const auto value = read_json_string(ctx, it, end);
   88|  69.6k|               if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (88:20): [True: 65, False: 69.6k]
  ------------------
   89|     65|                  return;
   90|     65|               }
   91|       |               // non-empty: the scanner reports an empty view as an error
   92|  69.6k|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (92:20): [True: 0, False: 69.6k]
  ------------------
   93|      0|                  return;
   94|      0|               }
   95|  69.6k|               break;
   96|  69.6k|            }
   97|  34.9M|            case Comma: {
  ------------------
  |  Branch (97:13): [True: 34.9M, False: 472k]
  ------------------
   98|  34.9M|               if (not put(',')) [[unlikely]] {
  ------------------
  |  Branch (98:20): [True: 0, False: 34.9M]
  ------------------
   99|      0|                  return;
  100|      0|               }
  101|  34.9M|               ++it;
  102|  34.9M|               if constexpr (check_new_lines_in_arrays(Opts)) {
  103|  34.9M|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (103:23): [True: 0, False: 34.9M]
  ------------------
  104|      0|                     return;
  105|      0|                  }
  106|       |               }
  107|       |               else {
  108|       |                  if (state[indent] == Object_Start) {
  109|       |                     if (not new_line()) [[unlikely]] {
  110|       |                        return;
  111|       |                     }
  112|       |                  }
  113|       |                  else if (not put(use_tabs ? '\t' : ' ')) [[unlikely]] {
  114|       |                     return;
  115|       |                  }
  116|       |               }
  117|  34.9M|               break;
  118|  34.9M|            }
  119|  34.9M|            case Number: {
  ------------------
  |  Branch (119:13): [True: 22.6k, False: 35.4M]
  ------------------
  120|  22.6k|               const auto value = read_json_number<Opts.null_terminated>(it, end);
  121|       |               // non-empty: a Number match is one valid character
  122|  22.6k|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (122:20): [True: 0, False: 22.6k]
  ------------------
  123|      0|                  return;
  124|      0|               }
  125|  22.6k|               break;
  126|  22.6k|            }
  127|  22.6k|            case Colon: {
  ------------------
  |  Branch (127:13): [True: 14.3k, False: 35.4M]
  ------------------
  128|  14.3k|               static constexpr sv colon = use_tabs ? sv{":\t"} : sv{": "};
  ------------------
  |  Branch (128:44): [Folded, False: 14.3k]
  ------------------
  129|  14.3k|               if (not put(colon)) [[unlikely]] {
  ------------------
  |  Branch (129:20): [True: 0, False: 14.3k]
  ------------------
  130|      0|                  return;
  131|      0|               }
  132|  14.3k|               ++it;
  133|  14.3k|               break;
  134|  14.3k|            }
  135|   139k|            case Array_Start: {
  ------------------
  |  Branch (135:13): [True: 139k, False: 35.2M]
  ------------------
  136|   139k|               if (not put('[')) [[unlikely]] {
  ------------------
  |  Branch (136:20): [True: 0, False: 139k]
  ------------------
  137|      0|                  return;
  138|      0|               }
  139|   139k|               ++it;
  140|   139k|               if (not open_level(Array_Start)) [[unlikely]] {
  ------------------
  |  Branch (140:20): [True: 16, False: 139k]
  ------------------
  141|     16|                  return;
  142|     16|               }
  143|   139k|               if constexpr (check_new_lines_in_arrays(Opts)) {
  144|   139k|                  if constexpr (not Opts.null_terminated) {
  145|   139k|                     if (it != end && *it != ']') {
  ------------------
  |  Branch (145:26): [True: 139k, False: 131]
  |  Branch (145:39): [True: 138k, False: 818]
  ------------------
  146|   138k|                        if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (146:29): [True: 0, False: 138k]
  ------------------
  147|      0|                           return;
  148|      0|                        }
  149|   138k|                     }
  150|       |                  }
  151|       |                  else {
  152|       |                     if (*it != ']') {
  153|       |                        if (not new_line()) [[unlikely]] {
  154|       |                           return;
  155|       |                        }
  156|       |                     }
  157|       |                  }
  158|   139k|               }
  159|   139k|               break;
  160|   139k|            }
  161|   139k|            case Array_End: {
  ------------------
  |  Branch (161:13): [True: 18.7k, False: 35.4M]
  ------------------
  162|  18.7k|               --indent;
  163|  18.7k|               if (indent < 0) {
  ------------------
  |  Branch (163:20): [True: 2, False: 18.7k]
  ------------------
  164|      2|                  ctx.error = error_code::syntax_error;
  165|      2|                  return;
  166|      2|               }
  167|       |               // This break is the one the bracket wanted anyway, and it closes an open line
  168|       |               // comment on its way, leaving the put below nothing to close.
  169|  18.7k|               if constexpr (check_new_lines_in_arrays(Opts)) {
  170|  18.7k|                  if (it[-1] != '[') {
  ------------------
  |  Branch (170:23): [True: 17.9k, False: 818]
  ------------------
  171|  17.9k|                     if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (171:26): [True: 0, False: 17.9k]
  ------------------
  172|      0|                        return;
  173|      0|                     }
  174|  17.9k|                  }
  175|  18.7k|               }
  176|  18.7k|               if (not put(']')) [[unlikely]] {
  ------------------
  |  Branch (176:20): [True: 0, False: 18.7k]
  ------------------
  177|      0|                  return;
  178|      0|               }
  179|  18.7k|               ++it;
  180|  18.7k|               break;
  181|  18.7k|            }
  182|  1.79k|            case Null: {
  ------------------
  |  Branch (182:13): [True: 1.79k, False: 35.4M]
  ------------------
  183|       |               // The type table matched on the first byte alone; see match_literal for why writing
  184|       |               // the literal from the writer's own spelling needs the rest of it checked.
  185|  1.79k|               if (not match_literal<"null">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (185:20): [True: 100, False: 1.69k]
  ------------------
  186|    100|                  return;
  187|    100|               }
  188|  1.69k|               if (not put("null")) [[unlikely]] {
  ------------------
  |  Branch (188:20): [True: 0, False: 1.69k]
  ------------------
  189|      0|                  return;
  190|      0|               }
  191|  1.69k|               break;
  192|  1.69k|            }
  193|  4.71k|            case Bool: {
  ------------------
  |  Branch (193:13): [True: 4.71k, False: 35.4M]
  ------------------
  194|  4.71k|               if (*it == 't') {
  ------------------
  |  Branch (194:20): [True: 3.28k, False: 1.42k]
  ------------------
  195|  3.28k|                  if (not match_literal<"true">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (195:23): [True: 101, False: 3.18k]
  ------------------
  196|    101|                     return;
  197|    101|                  }
  198|  3.18k|                  if (not put("true")) [[unlikely]] {
  ------------------
  |  Branch (198:23): [True: 0, False: 3.18k]
  ------------------
  199|      0|                     return;
  200|      0|                  }
  201|  3.18k|                  break;
  202|  3.18k|               }
  203|  1.42k|               else {
  204|  1.42k|                  if (not match_literal<"false">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (204:23): [True: 147, False: 1.28k]
  ------------------
  205|    147|                     return;
  206|    147|                  }
  207|  1.28k|                  if (not put("false")) [[unlikely]] {
  ------------------
  |  Branch (207:23): [True: 0, False: 1.28k]
  ------------------
  208|      0|                     return;
  209|      0|                  }
  210|  1.28k|                  break;
  211|  1.28k|               }
  212|  4.71k|            }
  213|  78.3k|            case Object_Start: {
  ------------------
  |  Branch (213:13): [True: 78.3k, False: 35.3M]
  ------------------
  214|  78.3k|               if (not put('{')) [[unlikely]] {
  ------------------
  |  Branch (214:20): [True: 0, False: 78.3k]
  ------------------
  215|      0|                  return;
  216|      0|               }
  217|  78.3k|               ++it;
  218|  78.3k|               if (not open_level(Object_Start)) [[unlikely]] {
  ------------------
  |  Branch (218:20): [True: 14, False: 78.3k]
  ------------------
  219|     14|                  return;
  220|     14|               }
  221|  78.3k|               if constexpr (not Opts.null_terminated) {
  222|  78.3k|                  if (it != end && *it != '}') {
  ------------------
  |  Branch (222:23): [True: 78.2k, False: 126]
  |  Branch (222:36): [True: 76.8k, False: 1.37k]
  ------------------
  223|  76.8k|                     if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (223:26): [True: 0, False: 76.8k]
  ------------------
  224|      0|                        return;
  225|      0|                     }
  226|  76.8k|                  }
  227|       |               }
  228|       |               else {
  229|       |                  if (*it != '}') {
  230|       |                     if (not new_line()) [[unlikely]] {
  231|       |                        return;
  232|       |                     }
  233|       |                  }
  234|       |               }
  235|  78.3k|               break;
  236|  78.3k|            }
  237|   105k|            case Object_End: {
  ------------------
  |  Branch (237:13): [True: 105k, False: 35.3M]
  ------------------
  238|   105k|               --indent;
  239|   105k|               if (indent < 0) {
  ------------------
  |  Branch (239:20): [True: 2, False: 105k]
  ------------------
  240|      2|                  ctx.error = error_code::syntax_error;
  241|      2|                  return;
  242|      2|               }
  243|       |               // As in Array_End, this break doubles as the close of an open line comment.
  244|   105k|               if (it[-1] != '{') {
  ------------------
  |  Branch (244:20): [True: 103k, False: 1.37k]
  ------------------
  245|   103k|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (245:23): [True: 0, False: 103k]
  ------------------
  246|      0|                     return;
  247|      0|                  }
  248|   103k|               }
  249|   105k|               if (not put('}')) [[unlikely]] {
  ------------------
  |  Branch (249:20): [True: 0, False: 105k]
  ------------------
  250|      0|                  return;
  251|      0|               }
  252|   105k|               ++it;
  253|   105k|               break;
  254|   105k|            }
  255|  7.71k|            case Comment: {
  ------------------
  |  Branch (255:13): [True: 7.71k, False: 35.4M]
  ------------------
  256|  7.71k|               if constexpr (Opts.comments) {
  257|  7.71k|                  const auto comment = read_jsonc_comment(ctx, it, end);
  258|  7.71k|                  if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (258:23): [True: 159, False: 7.55k]
  ------------------
  259|    159|                     return;
  260|    159|                  }
  261|       |                  // non-empty: an empty view comes with an error
  262|  7.55k|                  if (not put(comment.text)) [[unlikely]] {
  ------------------
  |  Branch (262:23): [True: 0, False: 7.55k]
  ------------------
  263|      0|                     return;
  264|      0|                  }
  265|  7.55k|                  line_comment_open = comment.line;
  266|  7.55k|                  break;
  267|       |               }
  268|       |               else {
  269|       |                  // A '/' opens a comment, and plain JSON has none. Skipping it as though it were
  270|       |                  // whitespace silently rewrote the document: "{\"a\":1} // tail" came out as
  271|       |                  // "{...}true", the 't' of "tail" taken for a literal. minify_json has always
  272|       |                  // reported this, and the two had no business disagreeing.
  273|       |                  ctx.error = error_code::syntax_error;
  274|       |                  return;
  275|       |               }
  276|  7.71k|            }
  277|  16.4k|            case Whitespace: {
  ------------------
  |  Branch (277:13): [True: 8.69k, False: 35.4M]
  ------------------
  278|       |               // Skip whitespace characters that are part of raw JSON content
  279|  16.4k|               ++it;
  280|  16.4k|               break;
  281|  7.71k|            }
  282|    314|            [[unlikely]] default: {
  ------------------
  |  Branch (282:26): [True: 314, False: 35.4M]
  ------------------
  283|    314|               ctx.error = error_code::syntax_error;
  284|    314|               return;
  285|      0|            }
  286|  35.4M|            }
  287|  35.4M|         }
  288|  1.93k|      }
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clINS8_17basic_string_viewIcSB_EEEEDaSS_:
   73|   114k|         const auto put = [&](const auto& x) {
   74|   114k|            if constexpr (Opts.comments) {
   75|   114k|               if (line_comment_open) [[unlikely]] {
  ------------------
  |  Branch (75:20): [True: 2.22k, False: 111k]
  ------------------
   76|  2.22k|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (76:23): [True: 0, False: 2.22k]
  ------------------
   77|      0|                     return false;
   78|      0|                  }
   79|  2.22k|               }
   80|   114k|            }
   81|   114k|            return emit_bytes<true>(ctx, b, ix, x);
   82|   114k|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIcEEDaSS_:
   73|  35.3M|         const auto put = [&](const auto& x) {
   74|  35.3M|            if constexpr (Opts.comments) {
   75|  35.3M|               if (line_comment_open) [[unlikely]] {
  ------------------
  |  Branch (75:20): [True: 1.80k, False: 35.3M]
  ------------------
   76|  1.80k|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (76:23): [True: 0, False: 1.80k]
  ------------------
   77|      0|                     return false;
   78|      0|                  }
   79|  1.80k|               }
   80|  35.3M|            }
   81|  35.3M|            return emit_bytes<true>(ctx, b, ix, x);
   82|  35.3M|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE_clEv:
   47|  35.3M|         const auto new_line = [&] {
   48|       |            if constexpr (has_bounded_capacity<decltype(b)>) {
   49|       |               const size_t n = use_tabs ? size_t(indent) : size_t(indent) * indent_width;
   50|       |               if (not ensure_space(ctx, b, ix + 1 + n)) [[unlikely]] {
   51|       |                  return false;
   52|       |               }
   53|       |            }
   54|  35.3M|            append_new_line<use_tabs, indent_width>(b, ix, indent);
   55|  35.3M|            if constexpr (Opts.comments) {
   56|  35.3M|               line_comment_open = false;
   57|  35.3M|            }
   58|  35.3M|            return true;
   59|  35.3M|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlNS0_9json_typeEE_clESQ_:
   29|   218k|         const auto open_level = [&](const json_type type) {
   30|   218k|            if (size_t(indent) >= max_recursive_depth_limit) [[unlikely]] {
  ------------------
  |  Branch (30:17): [True: 30, False: 218k]
  ------------------
   31|     30|               ctx.error = error_code::exceeded_max_recursive_depth;
   32|     30|               return false;
   33|     30|            }
   34|   218k|            state[++indent] = type;
   35|   218k|            return true;
   36|   218k|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA5_cEEDaSS_:
   73|  4.87k|         const auto put = [&](const auto& x) {
   74|  4.87k|            if constexpr (Opts.comments) {
   75|  4.87k|               if (line_comment_open) [[unlikely]] {
  ------------------
  |  Branch (75:20): [True: 2.53k, False: 2.33k]
  ------------------
   76|  2.53k|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (76:23): [True: 0, False: 2.53k]
  ------------------
   77|      0|                     return false;
   78|      0|                  }
   79|  2.53k|               }
   80|  4.87k|            }
   81|  4.87k|            return emit_bytes<true>(ctx, b, ix, x);
   82|  4.87k|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA6_cEEDaSS_:
   73|  1.28k|         const auto put = [&](const auto& x) {
   74|  1.28k|            if constexpr (Opts.comments) {
   75|  1.28k|               if (line_comment_open) [[unlikely]] {
  ------------------
  |  Branch (75:20): [True: 270, False: 1.01k]
  ------------------
   76|    270|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (76:23): [True: 0, False: 270]
  ------------------
   77|      0|                     return false;
   78|      0|                  }
   79|    270|               }
   80|  1.28k|            }
   81|  1.28k|            return emit_bytes<true>(ctx, b, ix, x);
   82|  1.28k|         };
_ZN3glz14prettify_jsoncITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEEES8_RKT0_:
  373|  1.93k|   {
  374|  1.93k|      context ctx{};
  375|  1.93k|      std::string out{};
  376|  1.93k|      detail::prettify_json<opt_true<Opts, &opts::comments>>(ctx, in, out);
  377|  1.93k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (377:11): [True: 920, False: 1.01k]
  ------------------
  378|    920|         return {}; // an incomplete result is not a document; see above
  379|    920|      }
  380|  1.01k|      return out;
  381|  1.93k|   }
_ZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10contiguousERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEETkNS_13output_bufferERS9_TkNS_10is_contextERNS_7contextEEEmOT2_OT0_OT1_:
  294|  1.93k|      {
  295|  1.93k|         if constexpr (resizable<Out>) {
  296|  1.93k|            if (in.size() == 0) {
  ------------------
  |  Branch (296:17): [True: 0, False: 1.93k]
  ------------------
  297|      0|               out.resize(0); // resize is what `resizable` promises; clear() is not
  298|      0|               return 0;
  299|      0|            }
  300|  1.93k|            out.resize(in.size() * 2);
  301|  1.93k|         }
  302|      0|         size_t ix = 0;
  303|  1.93k|         auto [it, end] = read_iterators<Opts>(in);
  304|  1.93k|         if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (304:14): [True: 0, False: 1.93k]
  ------------------
  305|      0|            return 0;
  306|      0|         }
  307|       |
  308|  1.93k|         if constexpr (self_terminating<In>) {
  309|  1.93k|            prettify_json<opt_true<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  310|       |         }
  311|       |         else {
  312|       |            prettify_json<opt_false<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  313|       |         }
  314|       |
  315|  1.93k|         if constexpr (resizable<Out>) {
  316|  1.93k|            out.resize(ix);
  317|  1.93k|         }
  318|  1.93k|         return ix;
  319|  1.93k|      }
_ZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_:
   17|  1.93k|      {
   18|  1.93k|         constexpr bool use_tabs = check_indentation_char(Opts) == '\t';
   19|  1.93k|         constexpr auto indent_width = check_indentation_width(Opts);
   20|       |
   21|  1.93k|         using enum json_type;
   22|       |
   23|       |         // Indexed by nesting level, with level 0 the top. Sized for the depth the readers accept (see
   24|       |         // enter_depth), so that every document glz::validate_jsonc passes can be prettified.
   25|  1.93k|         std::array<json_type, max_recursive_depth_limit + 1> state{};
   26|  1.93k|         int64_t indent{};
   27|       |
   28|       |         // Enters one level of nesting, failing past the readers' limit.
   29|  1.93k|         const auto open_level = [&](const json_type type) {
   30|  1.93k|            if (size_t(indent) >= max_recursive_depth_limit) [[unlikely]] {
   31|  1.93k|               ctx.error = error_code::exceeded_max_recursive_depth;
   32|  1.93k|               return false;
   33|  1.93k|            }
   34|  1.93k|            state[++indent] = type;
   35|  1.93k|            return true;
   36|  1.93k|         };
   37|       |
   38|       |         // Set while the output cursor sits on a line that a `//` comment has commented out. Only
   39|       |         // the comment-enabled path can set it, so the plain JSON writer keeps the code it had.
   40|  1.93k|         [[maybe_unused]] bool line_comment_open = false;
   41|       |
   42|       |         // Every line break the writer emits goes through this, because a break is also what ends a
   43|       |         // line comment: doing it in one place is what keeps the two from doubling up. The newline
   44|       |         // and the indentation behind it are also what make the output unbounded -- there is no
   45|       |         // bound on prettified output that a single reservation up front could use -- so this is
   46|       |         // the write a bounded destination is likeliest to run out on.
   47|  1.93k|         const auto new_line = [&] {
   48|  1.93k|            if constexpr (has_bounded_capacity<decltype(b)>) {
   49|  1.93k|               const size_t n = use_tabs ? size_t(indent) : size_t(indent) * indent_width;
   50|  1.93k|               if (not ensure_space(ctx, b, ix + 1 + n)) [[unlikely]] {
   51|  1.93k|                  return false;
   52|  1.93k|               }
   53|  1.93k|            }
   54|  1.93k|            append_new_line<use_tabs, indent_width>(b, ix, indent);
   55|  1.93k|            if constexpr (Opts.comments) {
   56|  1.93k|               line_comment_open = false;
   57|  1.93k|            }
   58|  1.93k|            return true;
   59|  1.93k|         };
   60|       |
   61|       |         // Every write below goes through this, which is what fixes their order in one place: an
   62|       |         // open line comment is closed first, because anything written into one is commented out,
   63|       |         // and emit_bytes then takes the reservation from the argument rather than from a byte
   64|       |         // count spelled out beside the write.
   65|       |         //
   66|       |         // Deferring that break to the next write rather than emitting it with the comment is what
   67|       |         // keeps a comment at the end of the input from leaving a trailing newline behind, and lets
   68|       |         // a break the writer was going to emit anyway serve as this one.
   69|       |         //
   70|       |         // A break that fails is reported rather than swallowed: on a bounded destination that ran
   71|       |         // out, carrying on would leave `line_comment_open` set and put this write *inside* the
   72|       |         // comment, which is not a truncated document but a wrong one.
   73|  1.93k|         const auto put = [&](const auto& x) {
   74|  1.93k|            if constexpr (Opts.comments) {
   75|  1.93k|               if (line_comment_open) [[unlikely]] {
   76|  1.93k|                  if (not new_line()) [[unlikely]] {
   77|  1.93k|                     return false;
   78|  1.93k|                  }
   79|  1.93k|               }
   80|  1.93k|            }
   81|  1.93k|            return emit_bytes<true>(ctx, b, ix, x);
   82|  1.93k|         };
   83|       |
   84|  35.4M|         while (it < end) {
  ------------------
  |  Branch (84:17): [True: 35.4M, False: 1.01k]
  ------------------
   85|  35.4M|            switch (json_types[uint8_t(*it)]) {
   86|  69.6k|            case String: {
  ------------------
  |  Branch (86:13): [True: 69.6k, False: 35.3M]
  ------------------
   87|  69.6k|               const auto value = read_json_string(ctx, it, end);
   88|  69.6k|               if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (88:20): [True: 65, False: 69.6k]
  ------------------
   89|     65|                  return;
   90|     65|               }
   91|       |               // non-empty: the scanner reports an empty view as an error
   92|  69.6k|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (92:20): [True: 0, False: 69.6k]
  ------------------
   93|      0|                  return;
   94|      0|               }
   95|  69.6k|               break;
   96|  69.6k|            }
   97|  34.9M|            case Comma: {
  ------------------
  |  Branch (97:13): [True: 34.9M, False: 472k]
  ------------------
   98|  34.9M|               if (not put(',')) [[unlikely]] {
  ------------------
  |  Branch (98:20): [True: 0, False: 34.9M]
  ------------------
   99|      0|                  return;
  100|      0|               }
  101|  34.9M|               ++it;
  102|  34.9M|               if constexpr (check_new_lines_in_arrays(Opts)) {
  103|  34.9M|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (103:23): [True: 0, False: 34.9M]
  ------------------
  104|      0|                     return;
  105|      0|                  }
  106|       |               }
  107|       |               else {
  108|       |                  if (state[indent] == Object_Start) {
  109|       |                     if (not new_line()) [[unlikely]] {
  110|       |                        return;
  111|       |                     }
  112|       |                  }
  113|       |                  else if (not put(use_tabs ? '\t' : ' ')) [[unlikely]] {
  114|       |                     return;
  115|       |                  }
  116|       |               }
  117|  34.9M|               break;
  118|  34.9M|            }
  119|  34.9M|            case Number: {
  ------------------
  |  Branch (119:13): [True: 22.6k, False: 35.4M]
  ------------------
  120|  22.6k|               const auto value = read_json_number<Opts.null_terminated>(it, end);
  121|       |               // non-empty: a Number match is one valid character
  122|  22.6k|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (122:20): [True: 0, False: 22.6k]
  ------------------
  123|      0|                  return;
  124|      0|               }
  125|  22.6k|               break;
  126|  22.6k|            }
  127|  22.6k|            case Colon: {
  ------------------
  |  Branch (127:13): [True: 14.3k, False: 35.4M]
  ------------------
  128|  14.3k|               static constexpr sv colon = use_tabs ? sv{":\t"} : sv{": "};
  ------------------
  |  Branch (128:44): [Folded, False: 14.3k]
  ------------------
  129|  14.3k|               if (not put(colon)) [[unlikely]] {
  ------------------
  |  Branch (129:20): [True: 0, False: 14.3k]
  ------------------
  130|      0|                  return;
  131|      0|               }
  132|  14.3k|               ++it;
  133|  14.3k|               break;
  134|  14.3k|            }
  135|   139k|            case Array_Start: {
  ------------------
  |  Branch (135:13): [True: 139k, False: 35.2M]
  ------------------
  136|   139k|               if (not put('[')) [[unlikely]] {
  ------------------
  |  Branch (136:20): [True: 0, False: 139k]
  ------------------
  137|      0|                  return;
  138|      0|               }
  139|   139k|               ++it;
  140|   139k|               if (not open_level(Array_Start)) [[unlikely]] {
  ------------------
  |  Branch (140:20): [True: 16, False: 139k]
  ------------------
  141|     16|                  return;
  142|     16|               }
  143|   139k|               if constexpr (check_new_lines_in_arrays(Opts)) {
  144|       |                  if constexpr (not Opts.null_terminated) {
  145|       |                     if (it != end && *it != ']') {
  146|       |                        if (not new_line()) [[unlikely]] {
  147|       |                           return;
  148|       |                        }
  149|       |                     }
  150|       |                  }
  151|   139k|                  else {
  152|   139k|                     if (*it != ']') {
  ------------------
  |  Branch (152:26): [True: 139k, False: 818]
  ------------------
  153|   139k|                        if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (153:29): [True: 0, False: 139k]
  ------------------
  154|      0|                           return;
  155|      0|                        }
  156|   139k|                     }
  157|   139k|                  }
  158|   139k|               }
  159|   139k|               break;
  160|   139k|            }
  161|   139k|            case Array_End: {
  ------------------
  |  Branch (161:13): [True: 18.7k, False: 35.4M]
  ------------------
  162|  18.7k|               --indent;
  163|  18.7k|               if (indent < 0) {
  ------------------
  |  Branch (163:20): [True: 2, False: 18.7k]
  ------------------
  164|      2|                  ctx.error = error_code::syntax_error;
  165|      2|                  return;
  166|      2|               }
  167|       |               // This break is the one the bracket wanted anyway, and it closes an open line
  168|       |               // comment on its way, leaving the put below nothing to close.
  169|  18.7k|               if constexpr (check_new_lines_in_arrays(Opts)) {
  170|  18.7k|                  if (it[-1] != '[') {
  ------------------
  |  Branch (170:23): [True: 17.9k, False: 818]
  ------------------
  171|  17.9k|                     if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (171:26): [True: 0, False: 17.9k]
  ------------------
  172|      0|                        return;
  173|      0|                     }
  174|  17.9k|                  }
  175|  18.7k|               }
  176|  18.7k|               if (not put(']')) [[unlikely]] {
  ------------------
  |  Branch (176:20): [True: 0, False: 18.7k]
  ------------------
  177|      0|                  return;
  178|      0|               }
  179|  18.7k|               ++it;
  180|  18.7k|               break;
  181|  18.7k|            }
  182|  1.79k|            case Null: {
  ------------------
  |  Branch (182:13): [True: 1.79k, False: 35.4M]
  ------------------
  183|       |               // The type table matched on the first byte alone; see match_literal for why writing
  184|       |               // the literal from the writer's own spelling needs the rest of it checked.
  185|  1.79k|               if (not match_literal<"null">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (185:20): [True: 100, False: 1.69k]
  ------------------
  186|    100|                  return;
  187|    100|               }
  188|  1.69k|               if (not put("null")) [[unlikely]] {
  ------------------
  |  Branch (188:20): [True: 0, False: 1.69k]
  ------------------
  189|      0|                  return;
  190|      0|               }
  191|  1.69k|               break;
  192|  1.69k|            }
  193|  4.71k|            case Bool: {
  ------------------
  |  Branch (193:13): [True: 4.71k, False: 35.4M]
  ------------------
  194|  4.71k|               if (*it == 't') {
  ------------------
  |  Branch (194:20): [True: 3.28k, False: 1.42k]
  ------------------
  195|  3.28k|                  if (not match_literal<"true">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (195:23): [True: 101, False: 3.18k]
  ------------------
  196|    101|                     return;
  197|    101|                  }
  198|  3.18k|                  if (not put("true")) [[unlikely]] {
  ------------------
  |  Branch (198:23): [True: 0, False: 3.18k]
  ------------------
  199|      0|                     return;
  200|      0|                  }
  201|  3.18k|                  break;
  202|  3.18k|               }
  203|  1.42k|               else {
  204|  1.42k|                  if (not match_literal<"false">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (204:23): [True: 147, False: 1.28k]
  ------------------
  205|    147|                     return;
  206|    147|                  }
  207|  1.28k|                  if (not put("false")) [[unlikely]] {
  ------------------
  |  Branch (207:23): [True: 0, False: 1.28k]
  ------------------
  208|      0|                     return;
  209|      0|                  }
  210|  1.28k|                  break;
  211|  1.28k|               }
  212|  4.71k|            }
  213|  78.3k|            case Object_Start: {
  ------------------
  |  Branch (213:13): [True: 78.3k, False: 35.3M]
  ------------------
  214|  78.3k|               if (not put('{')) [[unlikely]] {
  ------------------
  |  Branch (214:20): [True: 0, False: 78.3k]
  ------------------
  215|      0|                  return;
  216|      0|               }
  217|  78.3k|               ++it;
  218|  78.3k|               if (not open_level(Object_Start)) [[unlikely]] {
  ------------------
  |  Branch (218:20): [True: 14, False: 78.3k]
  ------------------
  219|     14|                  return;
  220|     14|               }
  221|       |               if constexpr (not Opts.null_terminated) {
  222|       |                  if (it != end && *it != '}') {
  223|       |                     if (not new_line()) [[unlikely]] {
  224|       |                        return;
  225|       |                     }
  226|       |                  }
  227|       |               }
  228|  78.3k|               else {
  229|  78.3k|                  if (*it != '}') {
  ------------------
  |  Branch (229:23): [True: 76.9k, False: 1.37k]
  ------------------
  230|  76.9k|                     if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (230:26): [True: 0, False: 76.9k]
  ------------------
  231|      0|                        return;
  232|      0|                     }
  233|  76.9k|                  }
  234|  78.3k|               }
  235|  78.3k|               break;
  236|  78.3k|            }
  237|   105k|            case Object_End: {
  ------------------
  |  Branch (237:13): [True: 105k, False: 35.3M]
  ------------------
  238|   105k|               --indent;
  239|   105k|               if (indent < 0) {
  ------------------
  |  Branch (239:20): [True: 2, False: 105k]
  ------------------
  240|      2|                  ctx.error = error_code::syntax_error;
  241|      2|                  return;
  242|      2|               }
  243|       |               // As in Array_End, this break doubles as the close of an open line comment.
  244|   105k|               if (it[-1] != '{') {
  ------------------
  |  Branch (244:20): [True: 103k, False: 1.37k]
  ------------------
  245|   103k|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (245:23): [True: 0, False: 103k]
  ------------------
  246|      0|                     return;
  247|      0|                  }
  248|   103k|               }
  249|   105k|               if (not put('}')) [[unlikely]] {
  ------------------
  |  Branch (249:20): [True: 0, False: 105k]
  ------------------
  250|      0|                  return;
  251|      0|               }
  252|   105k|               ++it;
  253|   105k|               break;
  254|   105k|            }
  255|  7.71k|            case Comment: {
  ------------------
  |  Branch (255:13): [True: 7.71k, False: 35.4M]
  ------------------
  256|  7.71k|               if constexpr (Opts.comments) {
  257|  7.71k|                  const auto comment = read_jsonc_comment(ctx, it, end);
  258|  7.71k|                  if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (258:23): [True: 159, False: 7.55k]
  ------------------
  259|    159|                     return;
  260|    159|                  }
  261|       |                  // non-empty: an empty view comes with an error
  262|  7.55k|                  if (not put(comment.text)) [[unlikely]] {
  ------------------
  |  Branch (262:23): [True: 0, False: 7.55k]
  ------------------
  263|      0|                     return;
  264|      0|                  }
  265|  7.55k|                  line_comment_open = comment.line;
  266|  7.55k|                  break;
  267|       |               }
  268|       |               else {
  269|       |                  // A '/' opens a comment, and plain JSON has none. Skipping it as though it were
  270|       |                  // whitespace silently rewrote the document: "{\"a\":1} // tail" came out as
  271|       |                  // "{...}true", the 't' of "tail" taken for a literal. minify_json has always
  272|       |                  // reported this, and the two had no business disagreeing.
  273|       |                  ctx.error = error_code::syntax_error;
  274|       |                  return;
  275|       |               }
  276|  7.71k|            }
  277|  16.4k|            case Whitespace: {
  ------------------
  |  Branch (277:13): [True: 8.69k, False: 35.4M]
  ------------------
  278|       |               // Skip whitespace characters that are part of raw JSON content
  279|  16.4k|               ++it;
  280|  16.4k|               break;
  281|  7.71k|            }
  282|    314|            [[unlikely]] default: {
  ------------------
  |  Branch (282:26): [True: 314, False: 35.4M]
  ------------------
  283|    314|               ctx.error = error_code::syntax_error;
  284|    314|               return;
  285|      0|            }
  286|  35.4M|            }
  287|  35.4M|         }
  288|  1.93k|      }
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clINS8_17basic_string_viewIcSB_EEEEDaSS_:
   73|   114k|         const auto put = [&](const auto& x) {
   74|   114k|            if constexpr (Opts.comments) {
   75|   114k|               if (line_comment_open) [[unlikely]] {
  ------------------
  |  Branch (75:20): [True: 2.22k, False: 111k]
  ------------------
   76|  2.22k|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (76:23): [True: 0, False: 2.22k]
  ------------------
   77|      0|                     return false;
   78|      0|                  }
   79|  2.22k|               }
   80|   114k|            }
   81|   114k|            return emit_bytes<true>(ctx, b, ix, x);
   82|   114k|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIcEEDaSS_:
   73|  35.3M|         const auto put = [&](const auto& x) {
   74|  35.3M|            if constexpr (Opts.comments) {
   75|  35.3M|               if (line_comment_open) [[unlikely]] {
  ------------------
  |  Branch (75:20): [True: 1.80k, False: 35.3M]
  ------------------
   76|  1.80k|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (76:23): [True: 0, False: 1.80k]
  ------------------
   77|      0|                     return false;
   78|      0|                  }
   79|  1.80k|               }
   80|  35.3M|            }
   81|  35.3M|            return emit_bytes<true>(ctx, b, ix, x);
   82|  35.3M|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE_clEv:
   47|  35.3M|         const auto new_line = [&] {
   48|       |            if constexpr (has_bounded_capacity<decltype(b)>) {
   49|       |               const size_t n = use_tabs ? size_t(indent) : size_t(indent) * indent_width;
   50|       |               if (not ensure_space(ctx, b, ix + 1 + n)) [[unlikely]] {
   51|       |                  return false;
   52|       |               }
   53|       |            }
   54|  35.3M|            append_new_line<use_tabs, indent_width>(b, ix, indent);
   55|  35.3M|            if constexpr (Opts.comments) {
   56|  35.3M|               line_comment_open = false;
   57|  35.3M|            }
   58|  35.3M|            return true;
   59|  35.3M|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlNS0_9json_typeEE_clESQ_:
   29|   218k|         const auto open_level = [&](const json_type type) {
   30|   218k|            if (size_t(indent) >= max_recursive_depth_limit) [[unlikely]] {
  ------------------
  |  Branch (30:17): [True: 30, False: 218k]
  ------------------
   31|     30|               ctx.error = error_code::exceeded_max_recursive_depth;
   32|     30|               return false;
   33|     30|            }
   34|   218k|            state[++indent] = type;
   35|   218k|            return true;
   36|   218k|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA5_cEEDaSS_:
   73|  4.87k|         const auto put = [&](const auto& x) {
   74|  4.87k|            if constexpr (Opts.comments) {
   75|  4.87k|               if (line_comment_open) [[unlikely]] {
  ------------------
  |  Branch (75:20): [True: 2.53k, False: 2.33k]
  ------------------
   76|  2.53k|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (76:23): [True: 0, False: 2.53k]
  ------------------
   77|      0|                     return false;
   78|      0|                  }
   79|  2.53k|               }
   80|  4.87k|            }
   81|  4.87k|            return emit_bytes<true>(ctx, b, ix, x);
   82|  4.87k|         };
_ZZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA6_cEEDaSS_:
   73|  1.28k|         const auto put = [&](const auto& x) {
   74|  1.28k|            if constexpr (Opts.comments) {
   75|  1.28k|               if (line_comment_open) [[unlikely]] {
  ------------------
  |  Branch (75:20): [True: 270, False: 1.01k]
  ------------------
   76|    270|                  if (not new_line()) [[unlikely]] {
  ------------------
  |  Branch (76:23): [True: 0, False: 270]
  ------------------
   77|      0|                     return false;
   78|      0|                  }
   79|    270|               }
   80|  1.28k|            }
   81|  1.28k|            return emit_bytes<true>(ctx, b, ix, x);
   82|  1.28k|         };

_ZN3glz9has_quoteEm:
   86|  2.71M|   {
   87|  2.71M|      return has_zero(chunk ^ repeat_byte8('"'));
   88|  2.71M|   }
_ZN3glz8has_zeroEm:
   81|  3.76M|   {
   82|  3.76M|      return (((chunk - 0x0101010101010101ull) & ~chunk) & 0x8080808080808080ull);
   83|  3.76M|   }
_ZN3glz11countr_zeroEm:
   29|   415k|   {
   30|       |#ifdef _MSC_VER
   31|       |      return std::countr_zero(x);
   32|       |#else
   33|   415k|#if __has_builtin(__builtin_ctzll)
   34|   415k|      return __builtin_ctzll(x);
   35|       |#else
   36|       |      return std::countr_zero(x);
   37|       |#endif
   38|   415k|#endif
   39|   415k|   }
_ZN3glz8has_charILc47EEEmm:
  102|  1.05M|   {
  103|  1.05M|      return has_zero(chunk ^ repeat_byte8(Char));
  104|  1.05M|   }

_ZN3glz10comparitorIL_ZZNS_6detail13match_literalITnNS_14string_literalEXtlNS3_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETkNS_10is_contextERNS_7contextERPKcS9_EEbOT0_OT1_T2_E1sELm4EcEEbPKSD_:
  245|  6.57k|   {
  246|       |      // pack() builds values in little-endian order (byte 0 in LSB position).
  247|       |      // On big-endian systems, memcpy produces native (big-endian) values,
  248|       |      // so we need to byteswap to match the packed representation.
  249|       |      if constexpr (N == 8) {
  250|       |         static constexpr auto packed = pack<Str, 8>();
  251|       |         uint64_t in;
  252|       |         std::memcpy(&in, other, 8);
  253|       |         if constexpr (std::endian::native == std::endian::big) {
  254|       |            in = std::byteswap(in);
  255|       |         }
  256|       |         return (in == packed);
  257|       |      }
  258|       |      else if constexpr (N == 7) {
  259|       |         static constexpr auto packed = pack_buffered<Str, 8>();
  260|       |         uint64_t in{};
  261|       |         std::memcpy(&in, other, 7);
  262|       |         if constexpr (std::endian::native == std::endian::big) {
  263|       |            in = std::byteswap(in);
  264|       |         }
  265|       |         return (in == packed);
  266|       |      }
  267|       |      else if constexpr (N == 6) {
  268|       |         static constexpr auto packed = pack_buffered<Str, 8>();
  269|       |         uint64_t in{};
  270|       |         std::memcpy(&in, other, 6);
  271|       |         if constexpr (std::endian::native == std::endian::big) {
  272|       |            in = std::byteswap(in);
  273|       |         }
  274|       |         return (in == packed);
  275|       |      }
  276|       |      else if constexpr (N == 5) {
  277|       |         static constexpr auto packed = pack<Str, 4>();
  278|       |         uint32_t in;
  279|       |         std::memcpy(&in, other, 4);
  280|       |         if constexpr (std::endian::native == std::endian::big) {
  281|       |            in = std::byteswap(in);
  282|       |         }
  283|       |         return (in == packed) & (Str[4] == other[4]);
  284|       |      }
  285|  6.57k|      else if constexpr (N == 4) {
  286|  6.57k|         static constexpr auto packed = pack<Str, 4>();
  287|  6.57k|         uint32_t in;
  288|  6.57k|         std::memcpy(&in, other, 4);
  289|       |         if constexpr (std::endian::native == std::endian::big) {
  290|       |            in = std::byteswap(in);
  291|       |         }
  292|  6.57k|         return (in == packed);
  293|       |      }
  294|       |      else if constexpr (N == 3) {
  295|       |         static constexpr auto packed = pack<Str, 2>();
  296|       |         uint16_t in;
  297|       |         std::memcpy(&in, other, 2);
  298|       |         if constexpr (std::endian::native == std::endian::big) {
  299|       |            in = std::byteswap(in);
  300|       |         }
  301|       |         return (in == packed) & (Str[2] == other[2]);
  302|       |      }
  303|       |      else if constexpr (N == 2) {
  304|       |         static constexpr auto packed = pack<Str, 2>();
  305|       |         uint16_t in;
  306|       |         std::memcpy(&in, other, 2);
  307|       |         if constexpr (std::endian::native == std::endian::big) {
  308|       |            in = std::byteswap(in);
  309|       |         }
  310|       |         return (in == packed);
  311|       |      }
  312|       |      else if constexpr (N == 1) {
  313|       |         return Str[0] == other[0];
  314|       |      }
  315|       |      else if constexpr (N == 0) {
  316|       |         return true;
  317|       |      }
  318|       |      else {
  319|       |         // Clang and GCC optimize this extremely well for constexpr std::string_view
  320|       |         // Packing data can create more binary on GCC
  321|       |         // The other cases probably aren't needed as compiler explorer shows them optimized equally well as memcmp
  322|       |         return 0 == std::memcmp(Str.data(), other, N);
  323|       |      }
  324|  6.57k|   }
_ZN3glz10comparitorIL_ZZNS_6detail13match_literalITnNS_14string_literalEXtlNS3_ILm5EEEtlA5_cLc116ELc114ELc117ELc101EEEETkNS_10is_contextERNS_7contextERPKcS9_EEbOT0_OT1_T2_E1sELm4EcEEbPKSD_:
  245|  8.38k|   {
  246|       |      // pack() builds values in little-endian order (byte 0 in LSB position).
  247|       |      // On big-endian systems, memcpy produces native (big-endian) values,
  248|       |      // so we need to byteswap to match the packed representation.
  249|       |      if constexpr (N == 8) {
  250|       |         static constexpr auto packed = pack<Str, 8>();
  251|       |         uint64_t in;
  252|       |         std::memcpy(&in, other, 8);
  253|       |         if constexpr (std::endian::native == std::endian::big) {
  254|       |            in = std::byteswap(in);
  255|       |         }
  256|       |         return (in == packed);
  257|       |      }
  258|       |      else if constexpr (N == 7) {
  259|       |         static constexpr auto packed = pack_buffered<Str, 8>();
  260|       |         uint64_t in{};
  261|       |         std::memcpy(&in, other, 7);
  262|       |         if constexpr (std::endian::native == std::endian::big) {
  263|       |            in = std::byteswap(in);
  264|       |         }
  265|       |         return (in == packed);
  266|       |      }
  267|       |      else if constexpr (N == 6) {
  268|       |         static constexpr auto packed = pack_buffered<Str, 8>();
  269|       |         uint64_t in{};
  270|       |         std::memcpy(&in, other, 6);
  271|       |         if constexpr (std::endian::native == std::endian::big) {
  272|       |            in = std::byteswap(in);
  273|       |         }
  274|       |         return (in == packed);
  275|       |      }
  276|       |      else if constexpr (N == 5) {
  277|       |         static constexpr auto packed = pack<Str, 4>();
  278|       |         uint32_t in;
  279|       |         std::memcpy(&in, other, 4);
  280|       |         if constexpr (std::endian::native == std::endian::big) {
  281|       |            in = std::byteswap(in);
  282|       |         }
  283|       |         return (in == packed) & (Str[4] == other[4]);
  284|       |      }
  285|  8.38k|      else if constexpr (N == 4) {
  286|  8.38k|         static constexpr auto packed = pack<Str, 4>();
  287|  8.38k|         uint32_t in;
  288|  8.38k|         std::memcpy(&in, other, 4);
  289|       |         if constexpr (std::endian::native == std::endian::big) {
  290|       |            in = std::byteswap(in);
  291|       |         }
  292|  8.38k|         return (in == packed);
  293|       |      }
  294|       |      else if constexpr (N == 3) {
  295|       |         static constexpr auto packed = pack<Str, 2>();
  296|       |         uint16_t in;
  297|       |         std::memcpy(&in, other, 2);
  298|       |         if constexpr (std::endian::native == std::endian::big) {
  299|       |            in = std::byteswap(in);
  300|       |         }
  301|       |         return (in == packed) & (Str[2] == other[2]);
  302|       |      }
  303|       |      else if constexpr (N == 2) {
  304|       |         static constexpr auto packed = pack<Str, 2>();
  305|       |         uint16_t in;
  306|       |         std::memcpy(&in, other, 2);
  307|       |         if constexpr (std::endian::native == std::endian::big) {
  308|       |            in = std::byteswap(in);
  309|       |         }
  310|       |         return (in == packed);
  311|       |      }
  312|       |      else if constexpr (N == 1) {
  313|       |         return Str[0] == other[0];
  314|       |      }
  315|       |      else if constexpr (N == 0) {
  316|       |         return true;
  317|       |      }
  318|       |      else {
  319|       |         // Clang and GCC optimize this extremely well for constexpr std::string_view
  320|       |         // Packing data can create more binary on GCC
  321|       |         // The other cases probably aren't needed as compiler explorer shows them optimized equally well as memcmp
  322|       |         return 0 == std::memcmp(Str.data(), other, N);
  323|       |      }
  324|  8.38k|   }
_ZN3glz10comparitorIL_ZZNS_6detail13match_literalITnNS_14string_literalEXtlNS3_ILm6EEEtlA6_cLc102ELc97ELc108ELc115ELc101EEEETkNS_10is_contextERNS_7contextERPKcS9_EEbOT0_OT1_T2_E1sELm5EcEEbPKSD_:
  245|  4.83k|   {
  246|       |      // pack() builds values in little-endian order (byte 0 in LSB position).
  247|       |      // On big-endian systems, memcpy produces native (big-endian) values,
  248|       |      // so we need to byteswap to match the packed representation.
  249|       |      if constexpr (N == 8) {
  250|       |         static constexpr auto packed = pack<Str, 8>();
  251|       |         uint64_t in;
  252|       |         std::memcpy(&in, other, 8);
  253|       |         if constexpr (std::endian::native == std::endian::big) {
  254|       |            in = std::byteswap(in);
  255|       |         }
  256|       |         return (in == packed);
  257|       |      }
  258|       |      else if constexpr (N == 7) {
  259|       |         static constexpr auto packed = pack_buffered<Str, 8>();
  260|       |         uint64_t in{};
  261|       |         std::memcpy(&in, other, 7);
  262|       |         if constexpr (std::endian::native == std::endian::big) {
  263|       |            in = std::byteswap(in);
  264|       |         }
  265|       |         return (in == packed);
  266|       |      }
  267|       |      else if constexpr (N == 6) {
  268|       |         static constexpr auto packed = pack_buffered<Str, 8>();
  269|       |         uint64_t in{};
  270|       |         std::memcpy(&in, other, 6);
  271|       |         if constexpr (std::endian::native == std::endian::big) {
  272|       |            in = std::byteswap(in);
  273|       |         }
  274|       |         return (in == packed);
  275|       |      }
  276|  4.83k|      else if constexpr (N == 5) {
  277|  4.83k|         static constexpr auto packed = pack<Str, 4>();
  278|  4.83k|         uint32_t in;
  279|  4.83k|         std::memcpy(&in, other, 4);
  280|       |         if constexpr (std::endian::native == std::endian::big) {
  281|       |            in = std::byteswap(in);
  282|       |         }
  283|  4.83k|         return (in == packed) & (Str[4] == other[4]);
  284|       |      }
  285|       |      else if constexpr (N == 4) {
  286|       |         static constexpr auto packed = pack<Str, 4>();
  287|       |         uint32_t in;
  288|       |         std::memcpy(&in, other, 4);
  289|       |         if constexpr (std::endian::native == std::endian::big) {
  290|       |            in = std::byteswap(in);
  291|       |         }
  292|       |         return (in == packed);
  293|       |      }
  294|       |      else if constexpr (N == 3) {
  295|       |         static constexpr auto packed = pack<Str, 2>();
  296|       |         uint16_t in;
  297|       |         std::memcpy(&in, other, 2);
  298|       |         if constexpr (std::endian::native == std::endian::big) {
  299|       |            in = std::byteswap(in);
  300|       |         }
  301|       |         return (in == packed) & (Str[2] == other[2]);
  302|       |      }
  303|       |      else if constexpr (N == 2) {
  304|       |         static constexpr auto packed = pack<Str, 2>();
  305|       |         uint16_t in;
  306|       |         std::memcpy(&in, other, 2);
  307|       |         if constexpr (std::endian::native == std::endian::big) {
  308|       |            in = std::byteswap(in);
  309|       |         }
  310|       |         return (in == packed);
  311|       |      }
  312|       |      else if constexpr (N == 1) {
  313|       |         return Str[0] == other[0];
  314|       |      }
  315|       |      else if constexpr (N == 0) {
  316|       |         return true;
  317|       |      }
  318|       |      else {
  319|       |         // Clang and GCC optimize this extremely well for constexpr std::string_view
  320|       |         // Packing data can create more binary on GCC
  321|       |         // The other cases probably aren't needed as compiler explorer shows them optimized equally well as memcmp
  322|       |         return 0 == std::memcmp(Str.data(), other, N);
  323|       |      }
  324|  4.83k|   }

_ZN3glz4dumpILb1ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvNS1_17basic_string_viewIcS4_EERT0_Rm:
  192|   391k|   {
  193|   391k|      const auto n = str.size();
  194|   391k|      if constexpr (vector_like<B>) {
  195|   391k|         if constexpr (Checked) {
  196|   391k|            const auto k = ix + n;
  197|   391k|            if (ix + n > b.size()) [[unlikely]] {
  ------------------
  |  Branch (197:17): [True: 692, False: 390k]
  ------------------
  198|    692|               grow_buffer(b, k);
  199|    692|            }
  200|   391k|         }
  201|   391k|      }
  202|   391k|      std::memcpy(&b[ix], str.data(), n);
  203|   391k|      ix += n;
  204|   391k|   }
_ZN3glz4dumpILb1ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEETkNS_10byte_sizedEcEEvT1_RT0_Rm:
  150|   239M|   {
  151|   239M|      if constexpr (Checked && vector_like<B>) {
  152|   239M|         if (ix == b.size()) [[unlikely]] {
  ------------------
  |  Branch (152:14): [True: 2.14k, False: 239M]
  ------------------
  153|  2.14k|            grow_buffer(b, b.size() == 0 ? 64 : ix + 1);
  ------------------
  |  Branch (153:28): [True: 0, False: 2.14k]
  ------------------
  154|  2.14k|         }
  155|   239M|      }
  156|   239M|      assign_maybe_cast(c, b, ix);
  157|   239M|      ++ix;
  158|   239M|   }
_ZN3glz17assign_maybe_castITkNS_10byte_sizedEcNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvT_RT0_Rm:
   95|   239M|   {
   96|   239M|      using V = std::decay_t<decltype(b[0])>;
   97|   239M|      using C = std::decay_t<decltype(c)>;
   98|   239M|      if constexpr (std::same_as<V, C>) {
   99|   239M|         b[ix] = c;
  100|       |      }
  101|       |      else {
  102|       |         b[ix] = static_cast<V>(c);
  103|       |      }
  104|   239M|   }
_ZN3glz5dumpnINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEETkNS_10byte_sizedEcEEvT0_mRT_Rm:
  222|   119M|   {
  223|   119M|      if constexpr (vector_like<B>) {
  224|   119M|         const auto k = ix + n;
  225|   119M|         if (k > b.size()) [[unlikely]] {
  ------------------
  |  Branch (225:14): [True: 17.6k, False: 119M]
  ------------------
  226|  17.6k|            grow_buffer(b, k);
  227|  17.6k|         }
  228|   119M|      }
  229|   119M|      fill_bytes(data_at(b, ix), c, n);
  230|   119M|      ix += n;
  231|   119M|   }
_ZN3glz10fill_bytesIcEEvPT_cm:
   54|   119M|   {
   55|   119M|      auto* p = reinterpret_cast<char*>(dst);
   56|   119M|      if (n >= 64) [[unlikely]] {
  ------------------
  |  Branch (56:11): [True: 119M, False: 570k]
  ------------------
   57|   119M|         std::memset(p, c, n);
   58|   119M|         return;
   59|   119M|      }
   60|   570k|      const uint64_t v = 0x0101010101010101ull * uint8_t(c);
   61|   570k|      if (n >= 8) {
  ------------------
  |  Branch (61:11): [True: 154k, False: 415k]
  ------------------
   62|   154k|         size_t i = 0;
   63|   768k|         for (; i + 8 <= n; i += 8) {
  ------------------
  |  Branch (63:17): [True: 614k, False: 154k]
  ------------------
   64|   614k|            std::memcpy(p + i, &v, 8);
   65|   614k|         }
   66|   154k|         if (i < n) {
  ------------------
  |  Branch (66:14): [True: 136k, False: 17.3k]
  ------------------
   67|   136k|            std::memcpy(p + n - 8, &v, 8); // overlaps what is already written, stays within n
   68|   136k|         }
   69|   154k|      }
   70|   415k|      else if (n >= 4) {
  ------------------
  |  Branch (70:16): [True: 25.7k, False: 390k]
  ------------------
   71|  25.7k|         std::memcpy(p, &v, 4);
   72|  25.7k|         std::memcpy(p + n - 4, &v, 4);
   73|  25.7k|      }
   74|   390k|      else if (n) {
  ------------------
  |  Branch (74:16): [True: 28.0k, False: 362k]
  ------------------
   75|  28.0k|         std::memcpy(p, &v, 1);
   76|  28.0k|         std::memcpy(p + (n >> 1), &v, 1);
   77|  28.0k|         std::memcpy(p + n - 1, &v, 1);
   78|  28.0k|      }
   79|   570k|   }
_ZN3glz7data_atINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEDaRT_m:
  117|   119M|   {
  118|       |      if constexpr (std::is_pointer_v<std::remove_cvref_t<B>>) {
  119|       |         return b + ix;
  120|       |      }
  121|   119M|      else {
  122|   119M|         static_assert(has_data<std::remove_cvref_t<B>>,
  123|   119M|                       "an output buffer must be contiguous: dump writes through memset and memcpy");
  124|       |         if constexpr (has_data_offset<std::remove_cvref_t<B>>) {
  125|       |            assert(ix >= b.data_offset() && "Index before flush offset");
  126|       |            return b.data() + (ix - b.data_offset());
  127|       |         }
  128|   119M|         else {
  129|   119M|            return b.data() + ix;
  130|   119M|         }
  131|   119M|      }
  132|   119M|   }

