LLVMFuzzerTestOneInput:
    9|  3.44k|{
   10|       |   // use a vector with null termination instead of a std::string to avoid
   11|       |   // small string optimization to hide bounds problems
   12|  3.44k|   std::vector<char> buffer{Data, Data + Size};
   13|       |
   14|       |   // non-null terminated
   15|  3.44k|   {
   16|  3.44k|      [[maybe_unused]] auto maybe_smaller = glz::minify_json(buffer);
   17|  3.44k|   }
   18|       |
   19|       |   // null terminated
   20|  3.44k|   {
   21|  3.44k|      buffer.push_back('\0');
   22|  3.44k|      [[maybe_unused]] auto maybe_smaller = glz::minify_json(buffer);
   23|  3.44k|   }
   24|       |
   25|       |   // The comment enabled path is a different scan: read_jsonc_comment only runs here, and it is
   26|       |   // the scanner that has to report an unterminated comment rather than swallow the buffer. Fuzzed
   27|       |   // as its own input because a document rejected by the plain path may be accepted by this one.
   28|  3.44k|   {
   29|  3.44k|      std::vector<char> jsonc{Data, Data + Size};
   30|  3.44k|      [[maybe_unused]] auto maybe_smaller = glz::minify_jsonc(jsonc);
   31|  3.44k|   }
   32|       |
   33|       |   // Only a self-terminating buffer selects the null terminated scan, whose run ends on the
   34|       |   // sentinel rather than on a bound in its loop condition. A vector carrying a trailing NUL does
   35|       |   // not: that NUL is just a byte inside the document.
   36|  3.44k|   {
   37|  3.44k|      std::string jsonc{Data, Data + Size};
   38|  3.44k|      [[maybe_unused]] auto maybe_smaller = glz::minify_jsonc(jsonc);
   39|  3.44k|   }
   40|       |
   41|       |   // Minifying only ever removes bytes, so a bounded output large enough for the input is large
   42|       |   // enough for the result -- and one that is not has to say so rather than be written past.
   43|  3.44k|   {
   44|  3.44k|      std::vector<char> jsonc{Data, Data + Size};
   45|  3.44k|      std::array<char, 64> bounded{};
   46|  3.44k|      [[maybe_unused]] const auto ec = glz::minify_jsonc(jsonc, bounded);
   47|  3.44k|   }
   48|       |
   49|  3.44k|   return 0;
   50|  3.44k|}

_ZN3glz12ensure_spaceINSt3__15arrayIcLm64EEETkNS_10is_contextENS_7contextEEEbRT0_RT_m:
  265|  21.2k|   {
  266|  21.2k|      using Buffer = std::remove_cvref_t<B>;
  267|       |
  268|       |      if constexpr (vector_like<Buffer>) {
  269|       |         if (required > b.size()) [[unlikely]] {
  270|       |            grow_buffer(b, required);
  271|       |         }
  272|       |         return true;
  273|       |      }
  274|  21.2k|      else if constexpr (has_bounded_capacity<Buffer>) {
  275|  21.2k|         if (required > buffer_traits<Buffer>::capacity(b)) [[unlikely]] {
  ------------------
  |  Branch (275:14): [True: 304, False: 20.9k]
  ------------------
  276|    304|            ctx.error = error_code::buffer_overflow;
  277|    304|            return false;
  278|    304|         }
  279|  20.9k|         return true;
  280|       |      }
  281|       |      else {
  282|       |         return true; // Raw pointer or other - trust caller
  283|       |      }
  284|  21.2k|   }
_ZN3glz13buffer_traitsINSt3__15arrayIcLm64EEEE8capacityERKS3_:
  250|  21.2k|      GLZ_ALWAYS_INLINE static constexpr size_t capacity(const std::array<T, N>&) noexcept { return N; }

_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10contiguousERNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT0_:
   40|  6.88k|   {
   41|  6.88k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  6.88k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  6.88k|      auto end = it + buffer.size();
   45|       |
   46|  6.88k|      return std::pair{it, end};
   47|  6.88k|   }
_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10contiguousERNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT0_:
   40|  6.88k|   {
   41|  6.88k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  6.88k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  6.88k|      auto end = it + buffer.size();
   45|       |
   46|  6.88k|      return std::pair{it, end};
   47|  6.88k|   }
_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10contiguousERNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEEEDaOT0_:
   40|  3.44k|   {
   41|  3.44k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  3.44k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  3.44k|      auto end = it + buffer.size();
   45|       |
   46|  3.44k|      return std::pair{it, end};
   47|  3.44k|   }

_ZN3glz6detail16read_json_stringITkNS_10is_contextERNS_7contextERPKcS5_EENSt3__117basic_string_viewIcNS7_11char_traitsIcEEEEOT_OT0_T1_:
  156|  6.80k|   {
  157|  6.80k|      auto start = it;
  158|  6.80k|      ++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|  6.80k|      const auto* const chunk_limit = (end - it >= 8) ? end - 8 : it - 1;
  ------------------
  |  Branch (162:39): [True: 5.87k, False: 927]
  ------------------
  163|  5.55M|      while (it <= chunk_limit) {
  ------------------
  |  Branch (163:14): [True: 5.55M, False: 1.28k]
  ------------------
  164|  5.55M|         uint64_t chunk;
  165|  5.55M|         std::memcpy(&chunk, it, 8);
  166|       |         if constexpr (std::endian::native == std::endian::big) {
  167|       |            chunk = std::byteswap(chunk);
  168|       |         }
  169|  5.55M|         const uint64_t quote = has_quote(chunk);
  170|  5.55M|         if (quote) {
  ------------------
  |  Branch (170:14): [True: 6.16k, False: 5.54M]
  ------------------
  171|  6.16k|            it += (countr_zero(quote) >> 3);
  172|       |
  173|  6.16k|            auto* prev = it - 1;
  174|  7.52k|            while (*prev == '\\') {
  ------------------
  |  Branch (174:20): [True: 1.36k, False: 6.16k]
  ------------------
  175|  1.36k|               --prev;
  176|  1.36k|            }
  177|  6.16k|            if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (177:17): [True: 5.51k, False: 650]
  ------------------
  178|  5.51k|               ++it; // add quote
  179|  5.51k|               return {start, size_t(it - start)};
  180|  5.51k|            }
  181|    650|            ++it; // skip escaped quote and continue
  182|    650|         }
  183|  5.54M|         else {
  184|  5.54M|            it += 8;
  185|  5.54M|         }
  186|  5.55M|      }
  187|       |
  188|  3.16k|      while (it < end) {
  ------------------
  |  Branch (188:14): [True: 2.64k, False: 516]
  ------------------
  189|  2.64k|         if (*it == '"') {
  ------------------
  |  Branch (189:14): [True: 851, False: 1.79k]
  ------------------
  190|    851|            auto* prev = it - 1;
  191|  2.50k|            while (*prev == '\\') {
  ------------------
  |  Branch (191:20): [True: 1.65k, False: 851]
  ------------------
  192|  1.65k|               --prev;
  193|  1.65k|            }
  194|    851|            if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (194:17): [True: 772, False: 79]
  ------------------
  195|    772|               ++it; // add quote
  196|    772|               return {start, size_t(it - start)};
  197|    772|            }
  198|    851|         }
  199|  1.87k|         ++it;
  200|  1.87k|      }
  201|       |
  202|    516|      ctx.error = error_code::unexpected_end;
  203|    516|      return {};
  204|  1.28k|   }
_ZN3glz6detail10emit_bytesILb0ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextENS2_17basic_string_viewIcS5_EEEEbRT1_RT0_RmRKT2_:
   91|  14.1k|   {
   92|  14.1k|      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.1k|      else {
  102|  14.1k|         const sv s = [&] {
  103|  14.1k|            if constexpr (std::is_bounded_array_v<T>) {
  104|  14.1k|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|  14.1k|            }
  106|  14.1k|            else {
  107|  14.1k|               return sv{x};
  108|  14.1k|            }
  109|  14.1k|         }();
  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.1k|         dump<Checked>(s, b, ix);
  116|  14.1k|      }
  117|  14.1k|      return true;
  118|  14.1k|   }
_ZZN3glz6detail10emit_bytesILb0ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextENS2_17basic_string_viewIcS5_EEEEbRT1_RT0_RmRKT2_ENKUlvE_clEv:
  102|  14.1k|         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|  14.1k|            else {
  107|  14.1k|               return sv{x};
  108|  14.1k|            }
  109|  14.1k|         }();
_ZN3glz6detail10emit_bytesILb0ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextEcEEbRT1_RT0_RmRKT2_:
   91|   100k|   {
   92|   100k|      using T = std::remove_cvref_t<decltype(x)>;
   93|   100k|      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|   100k|         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|   100k|      return true;
  118|   100k|   }
_ZN3glz6detail16read_json_numberILb0ERPKcS3_EENSt3__117basic_string_viewIcNS5_11char_traitsIcEEEEOT0_T1_:
  304|  5.49k|   {
  305|  5.49k|      auto start = it;
  306|       |      if constexpr (null_terminated) {
  307|       |         while (numeric_table[uint8_t(*it)]) {
  308|       |            ++it;
  309|       |         }
  310|       |      }
  311|  5.49k|      else {
  312|  13.8M|         while ((it < end) && numeric_table[uint8_t(*it)]) {
  ------------------
  |  Branch (312:17): [True: 13.8M, False: 149]
  |  Branch (312:31): [True: 13.8M, False: 5.35k]
  ------------------
  313|  13.8M|            ++it;
  314|  13.8M|         }
  315|  5.49k|      }
  316|  5.49k|      return {start, size_t(it - start)};
  317|  5.49k|   }
_ZN3glz6detail13match_literalITnNS_14string_literalEXtlNS2_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETkNS_10is_contextERNS_7contextERPKcS8_EEbOT0_OT1_T2_:
  130|  3.40k|   {
  131|  3.40k|      static constexpr auto s = literal.sv();
  132|  3.40k|      if (end - it < std::ptrdiff_t(s.size())) [[unlikely]] {
  ------------------
  |  Branch (132:11): [True: 90, False: 3.31k]
  ------------------
  133|     90|         ctx.error = error_code::unexpected_end;
  134|     90|         return false;
  135|     90|      }
  136|  3.31k|      if (not comparitor<s>(it)) [[unlikely]] {
  ------------------
  |  Branch (136:11): [True: 489, False: 2.82k]
  ------------------
  137|    489|         ctx.error = error_code::syntax_error;
  138|    489|         return false;
  139|    489|      }
  140|  2.82k|      it += s.size();
  141|  2.82k|      return true;
  142|  3.31k|   }
_ZN3glz6detail10emit_bytesILb0ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextEA5_cEEbRT1_RT0_RmRKT2_:
   91|  5.65k|   {
   92|  5.65k|      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|  5.65k|      else {
  102|  5.65k|         const sv s = [&] {
  103|  5.65k|            if constexpr (std::is_bounded_array_v<T>) {
  104|  5.65k|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|  5.65k|            }
  106|  5.65k|            else {
  107|  5.65k|               return sv{x};
  108|  5.65k|            }
  109|  5.65k|         }();
  110|       |         if constexpr (has_bounded_capacity<B>) {
  111|       |            if (not ensure_space(ctx, b, ix + s.size())) [[unlikely]] {
  112|       |               return false;
  113|       |            }
  114|       |         }
  115|  5.65k|         dump<Checked>(s, b, ix);
  116|  5.65k|      }
  117|  5.65k|      return true;
  118|  5.65k|   }
_ZZN3glz6detail10emit_bytesILb0ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextEA5_cEEbRT1_RT0_RmRKT2_ENKUlvE_clEv:
  102|  5.65k|         const sv s = [&] {
  103|  5.65k|            if constexpr (std::is_bounded_array_v<T>) {
  104|  5.65k|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|       |            }
  106|       |            else {
  107|       |               return sv{x};
  108|       |            }
  109|  5.65k|         }();
_ZN3glz6detail13match_literalITnNS_14string_literalEXtlNS2_ILm5EEEtlA5_cLc116ELc114ELc117ELc101EEEETkNS_10is_contextERNS_7contextERPKcS8_EEbOT0_OT1_T2_:
  130|  4.00k|   {
  131|  4.00k|      static constexpr auto s = literal.sv();
  132|  4.00k|      if (end - it < std::ptrdiff_t(s.size())) [[unlikely]] {
  ------------------
  |  Branch (132:11): [True: 118, False: 3.88k]
  ------------------
  133|    118|         ctx.error = error_code::unexpected_end;
  134|    118|         return false;
  135|    118|      }
  136|  3.88k|      if (not comparitor<s>(it)) [[unlikely]] {
  ------------------
  |  Branch (136:11): [True: 427, False: 3.46k]
  ------------------
  137|    427|         ctx.error = error_code::syntax_error;
  138|    427|         return false;
  139|    427|      }
  140|  3.46k|      it += s.size();
  141|  3.46k|      return true;
  142|  3.88k|   }
_ZN3glz6detail13match_literalITnNS_14string_literalEXtlNS2_ILm6EEEtlA6_cLc102ELc97ELc108ELc115ELc101EEEETkNS_10is_contextERNS_7contextERPKcS8_EEbOT0_OT1_T2_:
  130|  3.22k|   {
  131|  3.22k|      static constexpr auto s = literal.sv();
  132|  3.22k|      if (end - it < std::ptrdiff_t(s.size())) [[unlikely]] {
  ------------------
  |  Branch (132:11): [True: 181, False: 3.04k]
  ------------------
  133|    181|         ctx.error = error_code::unexpected_end;
  134|    181|         return false;
  135|    181|      }
  136|  3.04k|      if (not comparitor<s>(it)) [[unlikely]] {
  ------------------
  |  Branch (136:11): [True: 454, False: 2.58k]
  ------------------
  137|    454|         ctx.error = error_code::syntax_error;
  138|    454|         return false;
  139|    454|      }
  140|  2.58k|      it += s.size();
  141|  2.58k|      return true;
  142|  3.04k|   }
_ZN3glz6detail10emit_bytesILb0ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextEA6_cEEbRT1_RT0_RmRKT2_:
   91|  2.37k|   {
   92|  2.37k|      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|  2.37k|      else {
  102|  2.37k|         const sv s = [&] {
  103|  2.37k|            if constexpr (std::is_bounded_array_v<T>) {
  104|  2.37k|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|  2.37k|            }
  106|  2.37k|            else {
  107|  2.37k|               return sv{x};
  108|  2.37k|            }
  109|  2.37k|         }();
  110|       |         if constexpr (has_bounded_capacity<B>) {
  111|       |            if (not ensure_space(ctx, b, ix + s.size())) [[unlikely]] {
  112|       |               return false;
  113|       |            }
  114|       |         }
  115|  2.37k|         dump<Checked>(s, b, ix);
  116|  2.37k|      }
  117|  2.37k|      return true;
  118|  2.37k|   }
_ZZN3glz6detail10emit_bytesILb0ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEETkNS_10is_contextENS_7contextEA6_cEEbRT1_RT0_RmRKT2_ENKUlvE_clEv:
  102|  2.37k|         const sv s = [&] {
  103|  2.37k|            if constexpr (std::is_bounded_array_v<T>) {
  104|  2.37k|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|       |            }
  106|       |            else {
  107|       |               return sv{x};
  108|       |            }
  109|  2.37k|         }();
_ZN3glz6detail18read_jsonc_commentITkNS_10is_contextERNS_7contextERPKcS5_EENS0_13jsonc_commentEOT_OT0_T1_:
  227|  6.97k|   {
  228|  6.97k|      const auto start = it;
  229|  6.97k|      ++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|  6.97k|      if (it == end) [[unlikely]] {
  ------------------
  |  Branch (234:11): [True: 34, False: 6.94k]
  ------------------
  235|     34|         ctx.error = error_code::unexpected_end;
  236|     34|         return {};
  237|     34|      }
  238|       |
  239|  6.94k|      if (*it == '/') {
  ------------------
  |  Branch (239:11): [True: 3.56k, False: 3.37k]
  ------------------
  240|  3.56k|         ++it; // past the second '/'
  241|  5.54k|         while (it != end && *it != '\n' && *it != '\r') {
  ------------------
  |  Branch (241:17): [True: 5.43k, False: 107]
  |  Branch (241:30): [True: 3.05k, False: 2.38k]
  |  Branch (241:45): [True: 1.98k, False: 1.07k]
  ------------------
  242|  1.98k|            ++it;
  243|  1.98k|         }
  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|  3.56k|         return {sv{start, size_t(it - start)}, true};
  249|  3.56k|      }
  250|       |
  251|  3.37k|      if (*it != '*') [[unlikely]] {
  ------------------
  |  Branch (251:11): [True: 81, False: 3.29k]
  ------------------
  252|     81|         ctx.error = error_code::expected_end_comment;
  253|     81|         return {};
  254|     81|      }
  255|  3.29k|      ++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|  3.29k|      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|  3.29k|      const auto* const chunk_limit = (end - it >= 8) ? end - 8 : it - 1;
  ------------------
  |  Branch (266:39): [True: 3.04k, False: 246]
  ------------------
  267|  3.16M|      while (it <= chunk_limit) {
  ------------------
  |  Branch (267:14): [True: 3.16M, False: 506]
  ------------------
  268|  3.16M|         uint64_t chunk;
  269|  3.16M|         std::memcpy(&chunk, it, 8);
  270|       |         if constexpr (std::endian::native == std::endian::big) {
  271|       |            chunk = std::byteswap(chunk);
  272|       |         }
  273|  3.16M|         const uint64_t slash = has_char<'/'>(chunk);
  274|  3.16M|         if (slash) {
  ------------------
  |  Branch (274:14): [True: 23.5k, False: 3.14M]
  ------------------
  275|  23.5k|            it += (countr_zero(slash) >> 3);
  276|       |
  277|  23.5k|            if (it > content && it[-1] == '*') {
  ------------------
  |  Branch (277:17): [True: 22.6k, False: 888]
  |  Branch (277:33): [True: 2.78k, False: 19.8k]
  ------------------
  278|  2.78k|               ++it; // add slash
  279|  2.78k|               return {sv{start, size_t(it - start)}, false};
  280|  2.78k|            }
  281|       |            // skip slash and continue
  282|  20.7k|            ++it;
  283|  20.7k|         }
  284|  3.14M|         else {
  285|  3.14M|            it += 8;
  286|  3.14M|         }
  287|  3.16M|      }
  288|       |
  289|       |      // Tail end of buffer. Should be rare we even get here
  290|  1.86k|      while (it < end) {
  ------------------
  |  Branch (290:14): [True: 1.56k, False: 293]
  ------------------
  291|  1.56k|         if (it > content && it[-1] == '*' && *it == '/') {
  ------------------
  |  Branch (291:14): [True: 1.33k, False: 237]
  |  Branch (291:30): [True: 361, False: 971]
  |  Branch (291:47): [True: 213, False: 148]
  ------------------
  292|    213|            ++it; // add slash
  293|    213|            return {sv{start, size_t(it - start)}, false};
  294|    213|         }
  295|  1.35k|         ++it;
  296|  1.35k|      }
  297|       |
  298|    293|      ctx.error = error_code::expected_end_comment;
  299|    293|      return {};
  300|    506|   }
_ZN3glz6detail16read_json_numberILb1ERPKcS3_EENSt3__117basic_string_viewIcNS5_11char_traitsIcEEEEOT0_T1_:
  304|  1.54k|   {
  305|  1.54k|      auto start = it;
  306|  1.54k|      if constexpr (null_terminated) {
  307|  3.46M|         while (numeric_table[uint8_t(*it)]) {
  ------------------
  |  Branch (307:17): [True: 3.46M, False: 1.54k]
  ------------------
  308|  3.46M|            ++it;
  309|  3.46M|         }
  310|       |      }
  311|       |      else {
  312|       |         while ((it < end) && numeric_table[uint8_t(*it)]) {
  313|       |            ++it;
  314|       |         }
  315|       |      }
  316|  1.54k|      return {start, size_t(it - start)};
  317|  1.54k|   }
_ZN3glz6detail10emit_bytesILb0ENSt3__15arrayIcLm64EEETkNS_10is_contextENS_7contextENS2_17basic_string_viewIcNS2_11char_traitsIcEEEEEEbRT1_RT0_RmRKT2_:
   91|  2.15k|   {
   92|  2.15k|      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|  2.15k|      else {
  102|  2.15k|         const sv s = [&] {
  103|  2.15k|            if constexpr (std::is_bounded_array_v<T>) {
  104|  2.15k|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|  2.15k|            }
  106|  2.15k|            else {
  107|  2.15k|               return sv{x};
  108|  2.15k|            }
  109|  2.15k|         }();
  110|  2.15k|         if constexpr (has_bounded_capacity<B>) {
  111|  2.15k|            if (not ensure_space(ctx, b, ix + s.size())) [[unlikely]] {
  ------------------
  |  Branch (111:17): [True: 144, False: 2.01k]
  ------------------
  112|    144|               return false;
  113|    144|            }
  114|  2.15k|         }
  115|  2.01k|         dump<Checked>(s, b, ix);
  116|  2.15k|      }
  117|      0|      return true;
  118|  2.15k|   }
_ZZN3glz6detail10emit_bytesILb0ENSt3__15arrayIcLm64EEETkNS_10is_contextENS_7contextENS2_17basic_string_viewIcNS2_11char_traitsIcEEEEEEbRT1_RT0_RmRKT2_ENKUlvE_clEv:
  102|  2.15k|         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|  2.15k|            else {
  107|  2.15k|               return sv{x};
  108|  2.15k|            }
  109|  2.15k|         }();
_ZN3glz6detail10emit_bytesILb0ENSt3__15arrayIcLm64EEETkNS_10is_contextENS_7contextEcEEbRT1_RT0_RmRKT2_:
   91|  18.2k|   {
   92|  18.2k|      using T = std::remove_cvref_t<decltype(x)>;
   93|  18.2k|      if constexpr (byte_sized<T>) {
   94|  18.2k|         if constexpr (has_bounded_capacity<B>) {
   95|  18.2k|            if (not ensure_space(ctx, b, ix + 1)) [[unlikely]] {
  ------------------
  |  Branch (95:17): [True: 127, False: 18.1k]
  ------------------
   96|    127|               return false;
   97|    127|            }
   98|  18.2k|         }
   99|  18.1k|         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|      0|      return true;
  118|  18.2k|   }
_ZN3glz6detail10emit_bytesILb0ENSt3__15arrayIcLm64EEETkNS_10is_contextENS_7contextEA5_cEEbRT1_RT0_RmRKT2_:
   91|    631|   {
   92|    631|      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|    631|      else {
  102|    631|         const sv s = [&] {
  103|    631|            if constexpr (std::is_bounded_array_v<T>) {
  104|    631|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|    631|            }
  106|    631|            else {
  107|    631|               return sv{x};
  108|    631|            }
  109|    631|         }();
  110|    631|         if constexpr (has_bounded_capacity<B>) {
  111|    631|            if (not ensure_space(ctx, b, ix + s.size())) [[unlikely]] {
  ------------------
  |  Branch (111:17): [True: 22, False: 609]
  ------------------
  112|     22|               return false;
  113|     22|            }
  114|    631|         }
  115|    609|         dump<Checked>(s, b, ix);
  116|    631|      }
  117|      0|      return true;
  118|    631|   }
_ZZN3glz6detail10emit_bytesILb0ENSt3__15arrayIcLm64EEETkNS_10is_contextENS_7contextEA5_cEEbRT1_RT0_RmRKT2_ENKUlvE_clEv:
  102|    631|         const sv s = [&] {
  103|    631|            if constexpr (std::is_bounded_array_v<T>) {
  104|    631|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|       |            }
  106|       |            else {
  107|       |               return sv{x};
  108|       |            }
  109|    631|         }();
_ZN3glz6detail10emit_bytesILb0ENSt3__15arrayIcLm64EEETkNS_10is_contextENS_7contextEA6_cEEbRT1_RT0_RmRKT2_:
   91|    218|   {
   92|    218|      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|    218|      else {
  102|    218|         const sv s = [&] {
  103|    218|            if constexpr (std::is_bounded_array_v<T>) {
  104|    218|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|    218|            }
  106|    218|            else {
  107|    218|               return sv{x};
  108|    218|            }
  109|    218|         }();
  110|    218|         if constexpr (has_bounded_capacity<B>) {
  111|    218|            if (not ensure_space(ctx, b, ix + s.size())) [[unlikely]] {
  ------------------
  |  Branch (111:17): [True: 11, False: 207]
  ------------------
  112|     11|               return false;
  113|     11|            }
  114|    218|         }
  115|    207|         dump<Checked>(s, b, ix);
  116|    218|      }
  117|      0|      return true;
  118|    218|   }
_ZZN3glz6detail10emit_bytesILb0ENSt3__15arrayIcLm64EEETkNS_10is_contextENS_7contextEA6_cEEbRT1_RT0_RmRKT2_ENKUlvE_clEv:
  102|    218|         const sv s = [&] {
  103|    218|            if constexpr (std::is_bounded_array_v<T>) {
  104|    218|               return sv{x, std::extent_v<T> - 1}; // a string literal, without its terminator
  105|       |            }
  106|       |            else {
  107|       |               return sv{x};
  108|       |            }
  109|    218|         }();

_ZN3glz11minify_jsonITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_9resizableENSt3__16vectorIcNS2_9allocatorIcEEEEEENS2_12basic_stringIcNS2_11char_traitsIcEES5_EERT0_:
  288|  6.88k|   {
  289|  6.88k|      context ctx{};
  290|  6.88k|      std::string out{};
  291|  6.88k|      detail::minify_json<Opts>(ctx, in, out);
  292|  6.88k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (292:11): [True: 5.82k, False: 1.06k]
  ------------------
  293|  5.82k|         return {}; // an incomplete result is not a document; see above
  294|  5.82k|      }
  295|  1.06k|      return out;
  296|  6.88k|   }
_ZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERNSt3__16vectorIcNS3_9allocatorIcEEEETkNS_13output_bufferERNS3_12basic_stringIcNS3_11char_traitsIcEES6_EETkNS_10is_contextERNS_7contextEQaa10contiguousIT0_E9resizableISG_EEEmOT2_OSG_OT1_:
  230|  6.88k|      {
  231|  6.88k|         if (in.size() == 0) {
  ------------------
  |  Branch (231:14): [True: 0, False: 6.88k]
  ------------------
  232|      0|            return 0;
  233|      0|         }
  234|       |
  235|  6.88k|         if constexpr (resizable<Out>) {
  236|       |            // Minifying only ever removes bytes, so this is room enough for whatever comes out.
  237|       |            // A bounded output is checked per write instead; see the scan above for why.
  238|  6.88k|            out.resize(in.size() + 2 * padding_bytes);
  239|  6.88k|         }
  240|  6.88k|         size_t ix = 0;
  241|  6.88k|         auto [it, end] = read_iterators<Opts>(in);
  242|  6.88k|         if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (242:14): [True: 0, False: 6.88k]
  ------------------
  243|      0|            return 0;
  244|      0|         }
  245|       |
  246|       |         // The input is no longer grown and shrunk around this: everything the scan below reads
  247|       |         // through -- read_json_string, read_json_number, skip_matching_ws -- bounds its own loads
  248|       |         // against `end`, so there is nothing left for the padding to protect.
  249|       |         if constexpr (self_terminating<In>) {
  250|       |            minify_json<opt_true<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  251|       |         }
  252|  6.88k|         else {
  253|  6.88k|            minify_json<opt_false<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  254|  6.88k|         }
  255|       |
  256|  6.88k|         if constexpr (resizable<Out>) {
  257|  6.88k|            out.resize(ix);
  258|  6.88k|         }
  259|  6.88k|         return ix;
  260|  6.88k|      }
_ZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_:
   18|  6.88k|      {
   19|  6.88k|         using enum json_type;
   20|       |
   21|       |         // Every write below goes through this, and the dump it makes is unchecked: the caller's
   22|       |         // one-shot sizing covers a resizable destination, because minifying only ever removes
   23|       |         // bytes, so the input's length is room enough.
   24|       |         //
   25|       |         // A bounded destination cannot be grown, and asking it for the input's length up front
   26|       |         // refuses a buffer that fits the result -- sizing the output to the minified length is the
   27|       |         // obvious thing to do, and `{ "a" : 1 }` into a 7 byte buffer has to work. So each write
   28|       |         // asks for exactly what it stores instead; see emit_bytes for where that count comes from.
   29|       |         // None of it survives for a resizable destination, which keeps the unchecked dumps and
   30|       |         // nothing more.
   31|  6.88k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
   32|       |
   33|  6.88k|         auto ws_start = it;
   34|  6.88k|         uint64_t ws_size{};
   35|       |
   36|  6.88k|         auto skip_expected_whitespace = [&] {
   37|  6.88k|            auto new_ws_start = it;
   38|  6.88k|            if (ws_size && std::ptrdiff_t(ws_size) < end - it) [[likely]] {
   39|  6.88k|               skip_matching_ws(ws_start, it, ws_size);
   40|  6.88k|            }
   41|       |
   42|  6.88k|            if constexpr (Opts.null_terminated) {
   43|  6.88k|               while (whitespace_table[uint8_t(*it)]) {
   44|  6.88k|                  ++it;
   45|  6.88k|               }
   46|  6.88k|            }
   47|  6.88k|            else {
   48|  6.88k|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
   49|  6.88k|                  ++it;
   50|  6.88k|               }
   51|  6.88k|            }
   52|  6.88k|            ws_start = new_ws_start;
   53|  6.88k|            ws_size = size_t(it - new_ws_start);
   54|  6.88k|         };
   55|       |
   56|  6.88k|         auto skip_whitespace = [&] {
   57|  6.88k|            if constexpr (Opts.null_terminated) {
   58|  6.88k|               while (whitespace_table[uint8_t(*it)]) {
   59|  6.88k|                  ++it;
   60|  6.88k|               }
   61|  6.88k|            }
   62|  6.88k|            else {
   63|  6.88k|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
   64|  6.88k|                  ++it;
   65|  6.88k|               }
   66|  6.88k|            }
   67|  6.88k|         };
   68|       |
   69|  6.88k|         skip_whitespace();
   70|       |
   71|  66.3k|         while ([&]() -> bool {
  ------------------
  |  Branch (71:17): [True: 65.2k, False: 1.06k]
  ------------------
   72|  66.3k|            if constexpr (Opts.null_terminated) {
   73|  66.3k|               return true;
   74|  66.3k|            }
   75|  66.3k|            else {
   76|  66.3k|               return it < end;
   77|  66.3k|            }
   78|  66.3k|         }()) {
   79|  65.2k|            switch (json_types[uint8_t(*it)]) {
   80|  2.92k|            case String: {
  ------------------
  |  Branch (80:13): [True: 2.92k, False: 62.3k]
  ------------------
   81|  2.92k|               const auto value = read_json_string(ctx, it, end);
   82|  2.92k|               if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (82:20): [True: 192, False: 2.73k]
  ------------------
   83|    192|                  return;
   84|    192|               }
   85|       |               // non-empty: the scanner reports an empty view as an error
   86|  2.73k|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (86:20): [True: 0, False: 2.73k]
  ------------------
   87|      0|                  return;
   88|      0|               }
   89|  2.73k|               skip_whitespace();
   90|  2.73k|               break;
   91|  2.73k|            }
   92|  14.6k|            case Comma: {
  ------------------
  |  Branch (92:13): [True: 14.6k, False: 50.6k]
  ------------------
   93|  14.6k|               if (not put(',')) [[unlikely]] {
  ------------------
  |  Branch (93:20): [True: 0, False: 14.6k]
  ------------------
   94|      0|                  return;
   95|      0|               }
   96|  14.6k|               ++it;
   97|  14.6k|               skip_expected_whitespace();
   98|  14.6k|               break;
   99|  14.6k|            }
  100|  3.03k|            case Number: {
  ------------------
  |  Branch (100:13): [True: 3.03k, False: 62.2k]
  ------------------
  101|  3.03k|               const auto value = read_json_number<Opts.null_terminated>(it, end);
  102|       |               // non-empty: a Number match is one valid character
  103|  3.03k|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (103:20): [True: 0, False: 3.03k]
  ------------------
  104|      0|                  return;
  105|      0|               }
  106|  3.03k|               skip_whitespace();
  107|  3.03k|               break;
  108|  3.03k|            }
  109|  3.09k|            case Colon: {
  ------------------
  |  Branch (109:13): [True: 3.09k, False: 62.1k]
  ------------------
  110|  3.09k|               if (not put(':')) [[unlikely]] {
  ------------------
  |  Branch (110:20): [True: 0, False: 3.09k]
  ------------------
  111|      0|                  return;
  112|      0|               }
  113|  3.09k|               ++it;
  114|  3.09k|               skip_whitespace();
  115|  3.09k|               break;
  116|  3.09k|            }
  117|  12.6k|            case Array_Start: {
  ------------------
  |  Branch (117:13): [True: 12.6k, False: 52.5k]
  ------------------
  118|  12.6k|               if (not put('[')) [[unlikely]] {
  ------------------
  |  Branch (118:20): [True: 0, False: 12.6k]
  ------------------
  119|      0|                  return;
  120|      0|               }
  121|  12.6k|               ++it;
  122|  12.6k|               skip_expected_whitespace();
  123|  12.6k|               break;
  124|  12.6k|            }
  125|  3.04k|            case Array_End: {
  ------------------
  |  Branch (125:13): [True: 3.04k, False: 62.2k]
  ------------------
  126|  3.04k|               if (not put(']')) [[unlikely]] {
  ------------------
  |  Branch (126:20): [True: 0, False: 3.04k]
  ------------------
  127|      0|                  return;
  128|      0|               }
  129|  3.04k|               ++it;
  130|  3.04k|               skip_whitespace();
  131|  3.04k|               break;
  132|  3.04k|            }
  133|  1.50k|            case Null: {
  ------------------
  |  Branch (133:13): [True: 1.50k, False: 63.7k]
  ------------------
  134|       |               // The type table matched on the first byte alone; see match_literal for why writing
  135|       |               // the literal from the writer's own spelling needs the rest of it checked. Stepping
  136|       |               // over it unchecked also puts `it` past `end`, and from there the loop goes on
  137|       |               // minifying whatever follows the document into an output sized for the document.
  138|  1.50k|               if (not match_literal<"null">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (138:20): [True: 234, False: 1.27k]
  ------------------
  139|    234|                  return;
  140|    234|               }
  141|  1.27k|               if (not put("null")) [[unlikely]] {
  ------------------
  |  Branch (141:20): [True: 0, False: 1.27k]
  ------------------
  142|      0|                  return;
  143|      0|               }
  144|  1.27k|               skip_whitespace();
  145|  1.27k|               break;
  146|  1.27k|            }
  147|  3.19k|            case Bool: {
  ------------------
  |  Branch (147:13): [True: 3.19k, False: 62.0k]
  ------------------
  148|  3.19k|               if (*it == 't') {
  ------------------
  |  Branch (148:20): [True: 1.75k, False: 1.44k]
  ------------------
  149|  1.75k|                  if (not match_literal<"true">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (149:23): [True: 222, False: 1.53k]
  ------------------
  150|    222|                     return;
  151|    222|                  }
  152|  1.53k|                  if (not put("true")) [[unlikely]] {
  ------------------
  |  Branch (152:23): [True: 0, False: 1.53k]
  ------------------
  153|      0|                     return;
  154|      0|                  }
  155|  1.53k|                  skip_whitespace();
  156|  1.53k|                  break;
  157|  1.53k|               }
  158|  1.44k|               else {
  159|  1.44k|                  if (not match_literal<"false">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (159:23): [True: 256, False: 1.18k]
  ------------------
  160|    256|                     return;
  161|    256|                  }
  162|  1.18k|                  if (not put("false")) [[unlikely]] {
  ------------------
  |  Branch (162:23): [True: 0, False: 1.18k]
  ------------------
  163|      0|                     return;
  164|      0|                  }
  165|  1.18k|                  skip_whitespace();
  166|  1.18k|                  break;
  167|  1.18k|               }
  168|  3.19k|            }
  169|  13.4k|            case Object_Start: {
  ------------------
  |  Branch (169:13): [True: 13.4k, False: 51.7k]
  ------------------
  170|  13.4k|               if (not put('{')) [[unlikely]] {
  ------------------
  |  Branch (170:20): [True: 0, False: 13.4k]
  ------------------
  171|      0|                  return;
  172|      0|               }
  173|  13.4k|               ++it;
  174|  13.4k|               skip_expected_whitespace();
  175|  13.4k|               break;
  176|  13.4k|            }
  177|  2.76k|            case Object_End: {
  ------------------
  |  Branch (177:13): [True: 2.76k, False: 62.4k]
  ------------------
  178|  2.76k|               if (not put('}')) [[unlikely]] {
  ------------------
  |  Branch (178:20): [True: 0, False: 2.76k]
  ------------------
  179|      0|                  return;
  180|      0|               }
  181|  2.76k|               ++it;
  182|  2.76k|               skip_whitespace();
  183|  2.76k|               break;
  184|  2.76k|            }
  185|    580|            case Comment: {
  ------------------
  |  Branch (185:13): [True: 580, False: 64.6k]
  ------------------
  186|       |               if constexpr (Opts.comments) {
  187|       |                  const auto comment = read_jsonc_comment(ctx, it, end);
  188|       |                  if (bool(ctx.error)) [[unlikely]] {
  189|       |                     return;
  190|       |                  }
  191|       |                  // A line comment is dropped rather than written out. Minifying is what removes
  192|       |                  // the newline that ends it, and a line comment with no line break behind it
  193|       |                  // comments out the whole rest of the output.
  194|       |                  if (not comment.line) {
  195|       |                     // non-empty: an empty view comes with an error
  196|       |                     if (not put(comment.text)) [[unlikely]] {
  197|       |                        return;
  198|       |                     }
  199|       |                  }
  200|       |                  skip_whitespace();
  201|       |                  break;
  202|       |               }
  203|    580|               else {
  204|    580|                  [[fallthrough]];
  205|    580|               }
  206|    580|            }
  207|  4.91k|            [[unlikely]] default: {
  ------------------
  |  Branch (207:26): [True: 4.33k, False: 60.9k]
  ------------------
  208|       |               // A null terminated run carries no bound in its loop condition, so it ends here, on
  209|       |               // the terminator, which is not a JSON token. Reaching it is the end of the document
  210|       |               // rather than an error -- unclassified is how the type table reports both, and
  211|       |               // without this the minifier left syntax_error behind on every input it was ever
  212|       |               // given, valid or not, which is what made its error not worth returning.
  213|       |               if constexpr (Opts.null_terminated) {
  214|       |                  if (it >= end) {
  215|       |                     return;
  216|       |                  }
  217|       |               }
  218|  4.91k|               ctx.error = error_code::syntax_error;
  219|  4.91k|               return;
  220|    580|            }
  221|  65.2k|            }
  222|  65.2k|         }
  223|  6.88k|      }
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE0_clEv:
   56|  25.5k|         auto skip_whitespace = [&] {
   57|       |            if constexpr (Opts.null_terminated) {
   58|       |               while (whitespace_table[uint8_t(*it)]) {
   59|       |                  ++it;
   60|       |               }
   61|       |            }
   62|  25.5k|            else {
   63|   235k|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (63:23): [True: 234k, False: 439]
  |  Branch (63:37): [True: 209k, False: 25.0k]
  ------------------
   64|   209k|                  ++it;
   65|   209k|               }
   66|  25.5k|            }
   67|  25.5k|         };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE1_clEv:
   71|  66.3k|         while ([&]() -> bool {
   72|       |            if constexpr (Opts.null_terminated) {
   73|       |               return true;
   74|       |            }
   75|  66.3k|            else {
   76|  66.3k|               return it < end;
   77|  66.3k|            }
   78|  66.3k|         }()) {
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clINS8_17basic_string_viewIcSB_EEEEDaSS_:
   31|  5.76k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIcEEDaSS_:
   31|  49.6k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE_clEv:
   36|  40.7k|         auto skip_expected_whitespace = [&] {
   37|  40.7k|            auto new_ws_start = it;
   38|  40.7k|            if (ws_size && std::ptrdiff_t(ws_size) < end - it) [[likely]] {
  ------------------
  |  Branch (38:17): [True: 29.3k, False: 11.4k]
  |  Branch (38:28): [True: 27.7k, False: 1.53k]
  ------------------
   39|  27.7k|               skip_matching_ws(ws_start, it, ws_size);
   40|  27.7k|            }
   41|       |
   42|       |            if constexpr (Opts.null_terminated) {
   43|       |               while (whitespace_table[uint8_t(*it)]) {
   44|       |                  ++it;
   45|       |               }
   46|       |            }
   47|  40.7k|            else {
   48|  36.6M|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (48:23): [True: 36.6M, False: 621]
  |  Branch (48:37): [True: 36.6M, False: 40.1k]
  ------------------
   49|  36.6M|                  ++it;
   50|  36.6M|               }
   51|  40.7k|            }
   52|  40.7k|            ws_start = new_ws_start;
   53|  40.7k|            ws_size = size_t(it - new_ws_start);
   54|  40.7k|         };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA5_cEEDaSS_:
   31|  2.80k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA6_cEEDaSS_:
   31|  1.18k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZN3glz12minify_jsoncITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_9resizableENSt3__16vectorIcNS2_9allocatorIcEEEEEENS2_12basic_stringIcNS2_11char_traitsIcEES5_EERT0_:
  308|  3.44k|   {
  309|  3.44k|      context ctx{};
  310|  3.44k|      std::string out{};
  311|  3.44k|      detail::minify_json<opt_true<Opts, &opts::comments>>(ctx, in, out);
  312|  3.44k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (312:11): [True: 2.27k, False: 1.16k]
  ------------------
  313|  2.27k|         return {}; // an incomplete result is not a document; see above
  314|  2.27k|      }
  315|  1.16k|      return out;
  316|  3.44k|   }
_ZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEERNSt3__16vectorIcNS3_9allocatorIcEEEETkNS_13output_bufferERNS3_12basic_stringIcNS3_11char_traitsIcEES6_EETkNS_10is_contextERNS_7contextEQaa10contiguousIT0_E9resizableISG_EEEmOT2_OSG_OT1_:
  230|  3.44k|      {
  231|  3.44k|         if (in.size() == 0) {
  ------------------
  |  Branch (231:14): [True: 0, False: 3.44k]
  ------------------
  232|      0|            return 0;
  233|      0|         }
  234|       |
  235|  3.44k|         if constexpr (resizable<Out>) {
  236|       |            // Minifying only ever removes bytes, so this is room enough for whatever comes out.
  237|       |            // A bounded output is checked per write instead; see the scan above for why.
  238|  3.44k|            out.resize(in.size() + 2 * padding_bytes);
  239|  3.44k|         }
  240|  3.44k|         size_t ix = 0;
  241|  3.44k|         auto [it, end] = read_iterators<Opts>(in);
  242|  3.44k|         if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (242:14): [True: 0, False: 3.44k]
  ------------------
  243|      0|            return 0;
  244|      0|         }
  245|       |
  246|       |         // The input is no longer grown and shrunk around this: everything the scan below reads
  247|       |         // through -- read_json_string, read_json_number, skip_matching_ws -- bounds its own loads
  248|       |         // against `end`, so there is nothing left for the padding to protect.
  249|       |         if constexpr (self_terminating<In>) {
  250|       |            minify_json<opt_true<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  251|       |         }
  252|  3.44k|         else {
  253|  3.44k|            minify_json<opt_false<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  254|  3.44k|         }
  255|       |
  256|  3.44k|         if constexpr (resizable<Out>) {
  257|  3.44k|            out.resize(ix);
  258|  3.44k|         }
  259|  3.44k|         return ix;
  260|  3.44k|      }
_ZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_:
   18|  3.44k|      {
   19|  3.44k|         using enum json_type;
   20|       |
   21|       |         // Every write below goes through this, and the dump it makes is unchecked: the caller's
   22|       |         // one-shot sizing covers a resizable destination, because minifying only ever removes
   23|       |         // bytes, so the input's length is room enough.
   24|       |         //
   25|       |         // A bounded destination cannot be grown, and asking it for the input's length up front
   26|       |         // refuses a buffer that fits the result -- sizing the output to the minified length is the
   27|       |         // obvious thing to do, and `{ "a" : 1 }` into a 7 byte buffer has to work. So each write
   28|       |         // asks for exactly what it stores instead; see emit_bytes for where that count comes from.
   29|       |         // None of it survives for a resizable destination, which keeps the unchecked dumps and
   30|       |         // nothing more.
   31|  3.44k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
   32|       |
   33|  3.44k|         auto ws_start = it;
   34|  3.44k|         uint64_t ws_size{};
   35|       |
   36|  3.44k|         auto skip_expected_whitespace = [&] {
   37|  3.44k|            auto new_ws_start = it;
   38|  3.44k|            if (ws_size && std::ptrdiff_t(ws_size) < end - it) [[likely]] {
   39|  3.44k|               skip_matching_ws(ws_start, it, ws_size);
   40|  3.44k|            }
   41|       |
   42|  3.44k|            if constexpr (Opts.null_terminated) {
   43|  3.44k|               while (whitespace_table[uint8_t(*it)]) {
   44|  3.44k|                  ++it;
   45|  3.44k|               }
   46|  3.44k|            }
   47|  3.44k|            else {
   48|  3.44k|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
   49|  3.44k|                  ++it;
   50|  3.44k|               }
   51|  3.44k|            }
   52|  3.44k|            ws_start = new_ws_start;
   53|  3.44k|            ws_size = size_t(it - new_ws_start);
   54|  3.44k|         };
   55|       |
   56|  3.44k|         auto skip_whitespace = [&] {
   57|  3.44k|            if constexpr (Opts.null_terminated) {
   58|  3.44k|               while (whitespace_table[uint8_t(*it)]) {
   59|  3.44k|                  ++it;
   60|  3.44k|               }
   61|  3.44k|            }
   62|  3.44k|            else {
   63|  3.44k|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
   64|  3.44k|                  ++it;
   65|  3.44k|               }
   66|  3.44k|            }
   67|  3.44k|         };
   68|       |
   69|  3.44k|         skip_whitespace();
   70|       |
   71|  36.0k|         while ([&]() -> bool {
  ------------------
  |  Branch (71:17): [True: 34.9k, False: 1.16k]
  ------------------
   72|  36.0k|            if constexpr (Opts.null_terminated) {
   73|  36.0k|               return true;
   74|  36.0k|            }
   75|  36.0k|            else {
   76|  36.0k|               return it < end;
   77|  36.0k|            }
   78|  36.0k|         }()) {
   79|  34.9k|            switch (json_types[uint8_t(*it)]) {
   80|  1.50k|            case String: {
  ------------------
  |  Branch (80:13): [True: 1.50k, False: 33.4k]
  ------------------
   81|  1.50k|               const auto value = read_json_string(ctx, it, end);
   82|  1.50k|               if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (82:20): [True: 113, False: 1.39k]
  ------------------
   83|    113|                  return;
   84|    113|               }
   85|       |               // non-empty: the scanner reports an empty view as an error
   86|  1.39k|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (86:20): [True: 0, False: 1.39k]
  ------------------
   87|      0|                  return;
   88|      0|               }
   89|  1.39k|               skip_whitespace();
   90|  1.39k|               break;
   91|  1.39k|            }
   92|  7.33k|            case Comma: {
  ------------------
  |  Branch (92:13): [True: 7.33k, False: 27.5k]
  ------------------
   93|  7.33k|               if (not put(',')) [[unlikely]] {
  ------------------
  |  Branch (93:20): [True: 0, False: 7.33k]
  ------------------
   94|      0|                  return;
   95|      0|               }
   96|  7.33k|               ++it;
   97|  7.33k|               skip_expected_whitespace();
   98|  7.33k|               break;
   99|  7.33k|            }
  100|  1.54k|            case Number: {
  ------------------
  |  Branch (100:13): [True: 1.54k, False: 33.3k]
  ------------------
  101|  1.54k|               const auto value = read_json_number<Opts.null_terminated>(it, end);
  102|       |               // non-empty: a Number match is one valid character
  103|  1.54k|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (103:20): [True: 0, False: 1.54k]
  ------------------
  104|      0|                  return;
  105|      0|               }
  106|  1.54k|               skip_whitespace();
  107|  1.54k|               break;
  108|  1.54k|            }
  109|  1.58k|            case Colon: {
  ------------------
  |  Branch (109:13): [True: 1.58k, False: 33.3k]
  ------------------
  110|  1.58k|               if (not put(':')) [[unlikely]] {
  ------------------
  |  Branch (110:20): [True: 0, False: 1.58k]
  ------------------
  111|      0|                  return;
  112|      0|               }
  113|  1.58k|               ++it;
  114|  1.58k|               skip_whitespace();
  115|  1.58k|               break;
  116|  1.58k|            }
  117|  6.56k|            case Array_Start: {
  ------------------
  |  Branch (117:13): [True: 6.56k, False: 28.3k]
  ------------------
  118|  6.56k|               if (not put('[')) [[unlikely]] {
  ------------------
  |  Branch (118:20): [True: 0, False: 6.56k]
  ------------------
  119|      0|                  return;
  120|      0|               }
  121|  6.56k|               ++it;
  122|  6.56k|               skip_expected_whitespace();
  123|  6.56k|               break;
  124|  6.56k|            }
  125|  1.53k|            case Array_End: {
  ------------------
  |  Branch (125:13): [True: 1.53k, False: 33.3k]
  ------------------
  126|  1.53k|               if (not put(']')) [[unlikely]] {
  ------------------
  |  Branch (126:20): [True: 0, False: 1.53k]
  ------------------
  127|      0|                  return;
  128|      0|               }
  129|  1.53k|               ++it;
  130|  1.53k|               skip_whitespace();
  131|  1.53k|               break;
  132|  1.53k|            }
  133|    755|            case Null: {
  ------------------
  |  Branch (133:13): [True: 755, False: 34.1k]
  ------------------
  134|       |               // The type table matched on the first byte alone; see match_literal for why writing
  135|       |               // the literal from the writer's own spelling needs the rest of it checked. Stepping
  136|       |               // over it unchecked also puts `it` past `end`, and from there the loop goes on
  137|       |               // minifying whatever follows the document into an output sized for the document.
  138|    755|               if (not match_literal<"null">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (138:20): [True: 118, False: 637]
  ------------------
  139|    118|                  return;
  140|    118|               }
  141|    637|               if (not put("null")) [[unlikely]] {
  ------------------
  |  Branch (141:20): [True: 0, False: 637]
  ------------------
  142|      0|                  return;
  143|      0|               }
  144|    637|               skip_whitespace();
  145|    637|               break;
  146|    637|            }
  147|  1.61k|            case Bool: {
  ------------------
  |  Branch (147:13): [True: 1.61k, False: 33.2k]
  ------------------
  148|  1.61k|               if (*it == 't') {
  ------------------
  |  Branch (148:20): [True: 897, False: 721]
  ------------------
  149|    897|                  if (not match_literal<"true">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (149:23): [True: 111, False: 786]
  ------------------
  150|    111|                     return;
  151|    111|                  }
  152|    786|                  if (not put("true")) [[unlikely]] {
  ------------------
  |  Branch (152:23): [True: 0, False: 786]
  ------------------
  153|      0|                     return;
  154|      0|                  }
  155|    786|                  skip_whitespace();
  156|    786|                  break;
  157|    786|               }
  158|    721|               else {
  159|    721|                  if (not match_literal<"false">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (159:23): [True: 128, False: 593]
  ------------------
  160|    128|                     return;
  161|    128|                  }
  162|    593|                  if (not put("false")) [[unlikely]] {
  ------------------
  |  Branch (162:23): [True: 0, False: 593]
  ------------------
  163|      0|                     return;
  164|      0|                  }
  165|    593|                  skip_whitespace();
  166|    593|                  break;
  167|    593|               }
  168|  1.61k|            }
  169|  6.74k|            case Object_Start: {
  ------------------
  |  Branch (169:13): [True: 6.74k, False: 28.1k]
  ------------------
  170|  6.74k|               if (not put('{')) [[unlikely]] {
  ------------------
  |  Branch (170:20): [True: 0, False: 6.74k]
  ------------------
  171|      0|                  return;
  172|      0|               }
  173|  6.74k|               ++it;
  174|  6.74k|               skip_expected_whitespace();
  175|  6.74k|               break;
  176|  6.74k|            }
  177|  1.40k|            case Object_End: {
  ------------------
  |  Branch (177:13): [True: 1.40k, False: 33.5k]
  ------------------
  178|  1.40k|               if (not put('}')) [[unlikely]] {
  ------------------
  |  Branch (178:20): [True: 0, False: 1.40k]
  ------------------
  179|      0|                  return;
  180|      0|               }
  181|  1.40k|               ++it;
  182|  1.40k|               skip_whitespace();
  183|  1.40k|               break;
  184|  1.40k|            }
  185|  2.67k|            case Comment: {
  ------------------
  |  Branch (185:13): [True: 2.67k, False: 32.2k]
  ------------------
  186|  2.67k|               if constexpr (Opts.comments) {
  187|  2.67k|                  const auto comment = read_jsonc_comment(ctx, it, end);
  188|  2.67k|                  if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (188:23): [True: 141, False: 2.53k]
  ------------------
  189|    141|                     return;
  190|    141|                  }
  191|       |                  // A line comment is dropped rather than written out. Minifying is what removes
  192|       |                  // the newline that ends it, and a line comment with no line break behind it
  193|       |                  // comments out the whole rest of the output.
  194|  2.53k|                  if (not comment.line) {
  ------------------
  |  Branch (194:23): [True: 1.27k, False: 1.25k]
  ------------------
  195|       |                     // non-empty: an empty view comes with an error
  196|  1.27k|                     if (not put(comment.text)) [[unlikely]] {
  ------------------
  |  Branch (196:26): [True: 0, False: 1.27k]
  ------------------
  197|      0|                        return;
  198|      0|                     }
  199|  1.27k|                  }
  200|  2.53k|                  skip_whitespace();
  201|  2.53k|                  break;
  202|       |               }
  203|       |               else {
  204|       |                  [[fallthrough]];
  205|       |               }
  206|  2.67k|            }
  207|  4.33k|            [[unlikely]] default: {
  ------------------
  |  Branch (207:26): [True: 1.66k, False: 33.2k]
  ------------------
  208|       |               // A null terminated run carries no bound in its loop condition, so it ends here, on
  209|       |               // the terminator, which is not a JSON token. Reaching it is the end of the document
  210|       |               // rather than an error -- unclassified is how the type table reports both, and
  211|       |               // without this the minifier left syntax_error behind on every input it was ever
  212|       |               // given, valid or not, which is what made its error not worth returning.
  213|       |               if constexpr (Opts.null_terminated) {
  214|       |                  if (it >= end) {
  215|       |                     return;
  216|       |                  }
  217|       |               }
  218|  4.33k|               ctx.error = error_code::syntax_error;
  219|  4.33k|               return;
  220|  2.67k|            }
  221|  34.9k|            }
  222|  34.9k|         }
  223|  3.44k|      }
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE0_clEv:
   56|  15.4k|         auto skip_whitespace = [&] {
   57|       |            if constexpr (Opts.null_terminated) {
   58|       |               while (whitespace_table[uint8_t(*it)]) {
   59|       |                  ++it;
   60|       |               }
   61|       |            }
   62|  15.4k|            else {
   63|   124k|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (63:23): [True: 123k, False: 543]
  |  Branch (63:37): [True: 109k, False: 14.8k]
  ------------------
   64|   109k|                  ++it;
   65|   109k|               }
   66|  15.4k|            }
   67|  15.4k|         };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE1_clEv:
   71|  36.0k|         while ([&]() -> bool {
   72|       |            if constexpr (Opts.null_terminated) {
   73|       |               return true;
   74|       |            }
   75|  36.0k|            else {
   76|  36.0k|               return it < end;
   77|  36.0k|            }
   78|  36.0k|         }()) {
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clINS8_17basic_string_viewIcSB_EEEEDaSS_:
   31|  4.20k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIcEEDaSS_:
   31|  25.1k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE_clEv:
   36|  20.6k|         auto skip_expected_whitespace = [&] {
   37|  20.6k|            auto new_ws_start = it;
   38|  20.6k|            if (ws_size && std::ptrdiff_t(ws_size) < end - it) [[likely]] {
  ------------------
  |  Branch (38:17): [True: 14.6k, False: 5.96k]
  |  Branch (38:28): [True: 13.4k, False: 1.22k]
  ------------------
   39|  13.4k|               skip_matching_ws(ws_start, it, ws_size);
   40|  13.4k|            }
   41|       |
   42|       |            if constexpr (Opts.null_terminated) {
   43|       |               while (whitespace_table[uint8_t(*it)]) {
   44|       |                  ++it;
   45|       |               }
   46|       |            }
   47|  20.6k|            else {
   48|  18.3M|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (48:23): [True: 18.3M, False: 622]
  |  Branch (48:37): [True: 18.3M, False: 20.0k]
  ------------------
   49|  18.3M|                  ++it;
   50|  18.3M|               }
   51|  20.6k|            }
   52|  20.6k|            ws_start = new_ws_start;
   53|  20.6k|            ws_size = size_t(it - new_ws_start);
   54|  20.6k|         };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA5_cEEDaSS_:
   31|  1.42k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA6_cEEDaSS_:
   31|    593|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZN3glz12minify_jsoncITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_9resizableENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEEES8_RT0_:
  308|  3.44k|   {
  309|  3.44k|      context ctx{};
  310|  3.44k|      std::string out{};
  311|  3.44k|      detail::minify_json<opt_true<Opts, &opts::comments>>(ctx, in, out);
  312|  3.44k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (312:11): [True: 2.27k, False: 1.16k]
  ------------------
  313|  2.27k|         return {}; // an incomplete result is not a document; see above
  314|  2.27k|      }
  315|  1.16k|      return out;
  316|  3.44k|   }
_ZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEERNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEETkNS_13output_bufferESA_TkNS_10is_contextERNS_7contextEQaa10contiguousIT0_E9resizableISD_EEEmOT2_OSD_OT1_:
  230|  3.44k|      {
  231|  3.44k|         if (in.size() == 0) {
  ------------------
  |  Branch (231:14): [True: 0, False: 3.44k]
  ------------------
  232|      0|            return 0;
  233|      0|         }
  234|       |
  235|  3.44k|         if constexpr (resizable<Out>) {
  236|       |            // Minifying only ever removes bytes, so this is room enough for whatever comes out.
  237|       |            // A bounded output is checked per write instead; see the scan above for why.
  238|  3.44k|            out.resize(in.size() + 2 * padding_bytes);
  239|  3.44k|         }
  240|  3.44k|         size_t ix = 0;
  241|  3.44k|         auto [it, end] = read_iterators<Opts>(in);
  242|  3.44k|         if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (242:14): [True: 0, False: 3.44k]
  ------------------
  243|      0|            return 0;
  244|      0|         }
  245|       |
  246|       |         // The input is no longer grown and shrunk around this: everything the scan below reads
  247|       |         // through -- read_json_string, read_json_number, skip_matching_ws -- bounds its own loads
  248|       |         // against `end`, so there is nothing left for the padding to protect.
  249|  3.44k|         if constexpr (self_terminating<In>) {
  250|  3.44k|            minify_json<opt_true<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  251|       |         }
  252|       |         else {
  253|       |            minify_json<opt_false<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  254|       |         }
  255|       |
  256|  3.44k|         if constexpr (resizable<Out>) {
  257|  3.44k|            out.resize(ix);
  258|  3.44k|         }
  259|  3.44k|         return ix;
  260|  3.44k|      }
_ZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_:
   18|  3.44k|      {
   19|  3.44k|         using enum json_type;
   20|       |
   21|       |         // Every write below goes through this, and the dump it makes is unchecked: the caller's
   22|       |         // one-shot sizing covers a resizable destination, because minifying only ever removes
   23|       |         // bytes, so the input's length is room enough.
   24|       |         //
   25|       |         // A bounded destination cannot be grown, and asking it for the input's length up front
   26|       |         // refuses a buffer that fits the result -- sizing the output to the minified length is the
   27|       |         // obvious thing to do, and `{ "a" : 1 }` into a 7 byte buffer has to work. So each write
   28|       |         // asks for exactly what it stores instead; see emit_bytes for where that count comes from.
   29|       |         // None of it survives for a resizable destination, which keeps the unchecked dumps and
   30|       |         // nothing more.
   31|  3.44k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
   32|       |
   33|  3.44k|         auto ws_start = it;
   34|  3.44k|         uint64_t ws_size{};
   35|       |
   36|  3.44k|         auto skip_expected_whitespace = [&] {
   37|  3.44k|            auto new_ws_start = it;
   38|  3.44k|            if (ws_size && std::ptrdiff_t(ws_size) < end - it) [[likely]] {
   39|  3.44k|               skip_matching_ws(ws_start, it, ws_size);
   40|  3.44k|            }
   41|       |
   42|  3.44k|            if constexpr (Opts.null_terminated) {
   43|  3.44k|               while (whitespace_table[uint8_t(*it)]) {
   44|  3.44k|                  ++it;
   45|  3.44k|               }
   46|  3.44k|            }
   47|  3.44k|            else {
   48|  3.44k|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
   49|  3.44k|                  ++it;
   50|  3.44k|               }
   51|  3.44k|            }
   52|  3.44k|            ws_start = new_ws_start;
   53|  3.44k|            ws_size = size_t(it - new_ws_start);
   54|  3.44k|         };
   55|       |
   56|  3.44k|         auto skip_whitespace = [&] {
   57|  3.44k|            if constexpr (Opts.null_terminated) {
   58|  3.44k|               while (whitespace_table[uint8_t(*it)]) {
   59|  3.44k|                  ++it;
   60|  3.44k|               }
   61|  3.44k|            }
   62|  3.44k|            else {
   63|  3.44k|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
   64|  3.44k|                  ++it;
   65|  3.44k|               }
   66|  3.44k|            }
   67|  3.44k|         };
   68|       |
   69|  3.44k|         skip_whitespace();
   70|       |
   71|  36.0k|         while ([&]() -> bool {
  ------------------
  |  Branch (71:17): [True: 36.0k, Folded]
  ------------------
   72|  36.0k|            if constexpr (Opts.null_terminated) {
   73|  36.0k|               return true;
   74|  36.0k|            }
   75|  36.0k|            else {
   76|  36.0k|               return it < end;
   77|  36.0k|            }
   78|  36.0k|         }()) {
   79|  36.0k|            switch (json_types[uint8_t(*it)]) {
   80|  1.50k|            case String: {
  ------------------
  |  Branch (80:13): [True: 1.50k, False: 34.5k]
  ------------------
   81|  1.50k|               const auto value = read_json_string(ctx, it, end);
   82|  1.50k|               if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (82:20): [True: 113, False: 1.39k]
  ------------------
   83|    113|                  return;
   84|    113|               }
   85|       |               // non-empty: the scanner reports an empty view as an error
   86|  1.39k|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (86:20): [True: 0, False: 1.39k]
  ------------------
   87|      0|                  return;
   88|      0|               }
   89|  1.39k|               skip_whitespace();
   90|  1.39k|               break;
   91|  1.39k|            }
   92|  7.33k|            case Comma: {
  ------------------
  |  Branch (92:13): [True: 7.33k, False: 28.7k]
  ------------------
   93|  7.33k|               if (not put(',')) [[unlikely]] {
  ------------------
  |  Branch (93:20): [True: 0, False: 7.33k]
  ------------------
   94|      0|                  return;
   95|      0|               }
   96|  7.33k|               ++it;
   97|  7.33k|               skip_expected_whitespace();
   98|  7.33k|               break;
   99|  7.33k|            }
  100|  1.54k|            case Number: {
  ------------------
  |  Branch (100:13): [True: 1.54k, False: 34.5k]
  ------------------
  101|  1.54k|               const auto value = read_json_number<Opts.null_terminated>(it, end);
  102|       |               // non-empty: a Number match is one valid character
  103|  1.54k|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (103:20): [True: 0, False: 1.54k]
  ------------------
  104|      0|                  return;
  105|      0|               }
  106|  1.54k|               skip_whitespace();
  107|  1.54k|               break;
  108|  1.54k|            }
  109|  1.58k|            case Colon: {
  ------------------
  |  Branch (109:13): [True: 1.58k, False: 34.4k]
  ------------------
  110|  1.58k|               if (not put(':')) [[unlikely]] {
  ------------------
  |  Branch (110:20): [True: 0, False: 1.58k]
  ------------------
  111|      0|                  return;
  112|      0|               }
  113|  1.58k|               ++it;
  114|  1.58k|               skip_whitespace();
  115|  1.58k|               break;
  116|  1.58k|            }
  117|  6.56k|            case Array_Start: {
  ------------------
  |  Branch (117:13): [True: 6.56k, False: 29.5k]
  ------------------
  118|  6.56k|               if (not put('[')) [[unlikely]] {
  ------------------
  |  Branch (118:20): [True: 0, False: 6.56k]
  ------------------
  119|      0|                  return;
  120|      0|               }
  121|  6.56k|               ++it;
  122|  6.56k|               skip_expected_whitespace();
  123|  6.56k|               break;
  124|  6.56k|            }
  125|  1.53k|            case Array_End: {
  ------------------
  |  Branch (125:13): [True: 1.53k, False: 34.5k]
  ------------------
  126|  1.53k|               if (not put(']')) [[unlikely]] {
  ------------------
  |  Branch (126:20): [True: 0, False: 1.53k]
  ------------------
  127|      0|                  return;
  128|      0|               }
  129|  1.53k|               ++it;
  130|  1.53k|               skip_whitespace();
  131|  1.53k|               break;
  132|  1.53k|            }
  133|    755|            case Null: {
  ------------------
  |  Branch (133:13): [True: 755, False: 35.3k]
  ------------------
  134|       |               // The type table matched on the first byte alone; see match_literal for why writing
  135|       |               // the literal from the writer's own spelling needs the rest of it checked. Stepping
  136|       |               // over it unchecked also puts `it` past `end`, and from there the loop goes on
  137|       |               // minifying whatever follows the document into an output sized for the document.
  138|    755|               if (not match_literal<"null">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (138:20): [True: 118, False: 637]
  ------------------
  139|    118|                  return;
  140|    118|               }
  141|    637|               if (not put("null")) [[unlikely]] {
  ------------------
  |  Branch (141:20): [True: 0, False: 637]
  ------------------
  142|      0|                  return;
  143|      0|               }
  144|    637|               skip_whitespace();
  145|    637|               break;
  146|    637|            }
  147|  1.61k|            case Bool: {
  ------------------
  |  Branch (147:13): [True: 1.61k, False: 34.4k]
  ------------------
  148|  1.61k|               if (*it == 't') {
  ------------------
  |  Branch (148:20): [True: 897, False: 721]
  ------------------
  149|    897|                  if (not match_literal<"true">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (149:23): [True: 111, False: 786]
  ------------------
  150|    111|                     return;
  151|    111|                  }
  152|    786|                  if (not put("true")) [[unlikely]] {
  ------------------
  |  Branch (152:23): [True: 0, False: 786]
  ------------------
  153|      0|                     return;
  154|      0|                  }
  155|    786|                  skip_whitespace();
  156|    786|                  break;
  157|    786|               }
  158|    721|               else {
  159|    721|                  if (not match_literal<"false">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (159:23): [True: 128, False: 593]
  ------------------
  160|    128|                     return;
  161|    128|                  }
  162|    593|                  if (not put("false")) [[unlikely]] {
  ------------------
  |  Branch (162:23): [True: 0, False: 593]
  ------------------
  163|      0|                     return;
  164|      0|                  }
  165|    593|                  skip_whitespace();
  166|    593|                  break;
  167|    593|               }
  168|  1.61k|            }
  169|  6.74k|            case Object_Start: {
  ------------------
  |  Branch (169:13): [True: 6.74k, False: 29.3k]
  ------------------
  170|  6.74k|               if (not put('{')) [[unlikely]] {
  ------------------
  |  Branch (170:20): [True: 0, False: 6.74k]
  ------------------
  171|      0|                  return;
  172|      0|               }
  173|  6.74k|               ++it;
  174|  6.74k|               skip_expected_whitespace();
  175|  6.74k|               break;
  176|  6.74k|            }
  177|  1.40k|            case Object_End: {
  ------------------
  |  Branch (177:13): [True: 1.40k, False: 34.6k]
  ------------------
  178|  1.40k|               if (not put('}')) [[unlikely]] {
  ------------------
  |  Branch (178:20): [True: 0, False: 1.40k]
  ------------------
  179|      0|                  return;
  180|      0|               }
  181|  1.40k|               ++it;
  182|  1.40k|               skip_whitespace();
  183|  1.40k|               break;
  184|  1.40k|            }
  185|  2.67k|            case Comment: {
  ------------------
  |  Branch (185:13): [True: 2.67k, False: 33.4k]
  ------------------
  186|  2.67k|               if constexpr (Opts.comments) {
  187|  2.67k|                  const auto comment = read_jsonc_comment(ctx, it, end);
  188|  2.67k|                  if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (188:23): [True: 141, False: 2.53k]
  ------------------
  189|    141|                     return;
  190|    141|                  }
  191|       |                  // A line comment is dropped rather than written out. Minifying is what removes
  192|       |                  // the newline that ends it, and a line comment with no line break behind it
  193|       |                  // comments out the whole rest of the output.
  194|  2.53k|                  if (not comment.line) {
  ------------------
  |  Branch (194:23): [True: 1.27k, False: 1.25k]
  ------------------
  195|       |                     // non-empty: an empty view comes with an error
  196|  1.27k|                     if (not put(comment.text)) [[unlikely]] {
  ------------------
  |  Branch (196:26): [True: 0, False: 1.27k]
  ------------------
  197|      0|                        return;
  198|      0|                     }
  199|  1.27k|                  }
  200|  2.53k|                  skip_whitespace();
  201|  2.53k|                  break;
  202|       |               }
  203|       |               else {
  204|       |                  [[fallthrough]];
  205|       |               }
  206|  2.67k|            }
  207|  5.50k|            [[unlikely]] default: {
  ------------------
  |  Branch (207:26): [True: 2.82k, False: 33.2k]
  ------------------
  208|       |               // A null terminated run carries no bound in its loop condition, so it ends here, on
  209|       |               // the terminator, which is not a JSON token. Reaching it is the end of the document
  210|       |               // rather than an error -- unclassified is how the type table reports both, and
  211|       |               // without this the minifier left syntax_error behind on every input it was ever
  212|       |               // given, valid or not, which is what made its error not worth returning.
  213|  5.50k|               if constexpr (Opts.null_terminated) {
  214|  5.50k|                  if (it >= end) {
  ------------------
  |  Branch (214:23): [True: 1.16k, False: 4.33k]
  ------------------
  215|  1.16k|                     return;
  216|  1.16k|                  }
  217|  5.50k|               }
  218|  4.33k|               ctx.error = error_code::syntax_error;
  219|  5.50k|               return;
  220|  2.67k|            }
  221|  36.0k|            }
  222|  36.0k|         }
  223|  3.44k|      }
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE0_clEv:
   56|  15.4k|         auto skip_whitespace = [&] {
   57|  15.4k|            if constexpr (Opts.null_terminated) {
   58|   124k|               while (whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (58:23): [True: 109k, False: 15.4k]
  ------------------
   59|   109k|                  ++it;
   60|   109k|               }
   61|       |            }
   62|       |            else {
   63|       |               while ((it < end) && whitespace_table[uint8_t(*it)]) {
   64|       |                  ++it;
   65|       |               }
   66|       |            }
   67|  15.4k|         };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE1_clEv:
   71|  36.0k|         while ([&]() -> bool {
   72|  36.0k|            if constexpr (Opts.null_terminated) {
   73|  36.0k|               return true;
   74|       |            }
   75|       |            else {
   76|       |               return it < end;
   77|       |            }
   78|  36.0k|         }()) {
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clINS8_17basic_string_viewIcSB_EEEEDaSS_:
   31|  4.20k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIcEEDaSS_:
   31|  25.1k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE_clEv:
   36|  20.6k|         auto skip_expected_whitespace = [&] {
   37|  20.6k|            auto new_ws_start = it;
   38|  20.6k|            if (ws_size && std::ptrdiff_t(ws_size) < end - it) [[likely]] {
  ------------------
  |  Branch (38:17): [True: 14.6k, False: 5.96k]
  |  Branch (38:28): [True: 13.4k, False: 1.22k]
  ------------------
   39|  13.4k|               skip_matching_ws(ws_start, it, ws_size);
   40|  13.4k|            }
   41|       |
   42|  20.6k|            if constexpr (Opts.null_terminated) {
   43|  18.3M|               while (whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (43:23): [True: 18.3M, False: 20.6k]
  ------------------
   44|  18.3M|                  ++it;
   45|  18.3M|               }
   46|       |            }
   47|       |            else {
   48|       |               while ((it < end) && whitespace_table[uint8_t(*it)]) {
   49|       |                  ++it;
   50|       |               }
   51|       |            }
   52|  20.6k|            ws_start = new_ws_start;
   53|  20.6k|            ws_size = size_t(it - new_ws_start);
   54|  20.6k|         };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA5_cEEDaSS_:
   31|  1.42k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA6_cEEDaSS_:
   31|    593|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZN3glz12minify_jsoncITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_9resizableENSt3__16vectorIcNS2_9allocatorIcEEEENS2_5arrayIcLm64EEEEENS_9error_ctxERT0_RT1_:
  300|  3.44k|   {
  301|  3.44k|      context ctx{};
  302|  3.44k|      const auto n = detail::minify_json<opt_true<Opts, &opts::comments>>(ctx, in, out);
  303|  3.44k|      return {n, ctx.error, ctx.custom_error_message};
  304|  3.44k|   }
_ZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb1ELb1ELb1ELb1EEERNSt3__16vectorIcNS3_9allocatorIcEEEETkNS_13output_bufferERNS3_5arrayIcLm64EEETkNS_10is_contextERNS_7contextEQaa10contiguousIT0_E9resizableISE_EEEmOT2_OSE_OT1_:
  230|  3.44k|      {
  231|  3.44k|         if (in.size() == 0) {
  ------------------
  |  Branch (231:14): [True: 0, False: 3.44k]
  ------------------
  232|      0|            return 0;
  233|      0|         }
  234|       |
  235|       |         if constexpr (resizable<Out>) {
  236|       |            // Minifying only ever removes bytes, so this is room enough for whatever comes out.
  237|       |            // A bounded output is checked per write instead; see the scan above for why.
  238|       |            out.resize(in.size() + 2 * padding_bytes);
  239|       |         }
  240|  3.44k|         size_t ix = 0;
  241|  3.44k|         auto [it, end] = read_iterators<Opts>(in);
  242|  3.44k|         if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (242:14): [True: 0, False: 3.44k]
  ------------------
  243|      0|            return 0;
  244|      0|         }
  245|       |
  246|       |         // The input is no longer grown and shrunk around this: everything the scan below reads
  247|       |         // through -- read_json_string, read_json_number, skip_matching_ws -- bounds its own loads
  248|       |         // against `end`, so there is nothing left for the padding to protect.
  249|       |         if constexpr (self_terminating<In>) {
  250|       |            minify_json<opt_true<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  251|       |         }
  252|  3.44k|         else {
  253|  3.44k|            minify_json<opt_false<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  254|  3.44k|         }
  255|       |
  256|       |         if constexpr (resizable<Out>) {
  257|       |            out.resize(ix);
  258|       |         }
  259|  3.44k|         return ix;
  260|  3.44k|      }
_ZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__15arrayIcLm64EEEmEEvOT0_OT1_OT2_OT3_RT4_:
   18|  3.44k|      {
   19|  3.44k|         using enum json_type;
   20|       |
   21|       |         // Every write below goes through this, and the dump it makes is unchecked: the caller's
   22|       |         // one-shot sizing covers a resizable destination, because minifying only ever removes
   23|       |         // bytes, so the input's length is room enough.
   24|       |         //
   25|       |         // A bounded destination cannot be grown, and asking it for the input's length up front
   26|       |         // refuses a buffer that fits the result -- sizing the output to the minified length is the
   27|       |         // obvious thing to do, and `{ "a" : 1 }` into a 7 byte buffer has to work. So each write
   28|       |         // asks for exactly what it stores instead; see emit_bytes for where that count comes from.
   29|       |         // None of it survives for a resizable destination, which keeps the unchecked dumps and
   30|       |         // nothing more.
   31|  3.44k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
   32|       |
   33|  3.44k|         auto ws_start = it;
   34|  3.44k|         uint64_t ws_size{};
   35|       |
   36|  3.44k|         auto skip_expected_whitespace = [&] {
   37|  3.44k|            auto new_ws_start = it;
   38|  3.44k|            if (ws_size && std::ptrdiff_t(ws_size) < end - it) [[likely]] {
   39|  3.44k|               skip_matching_ws(ws_start, it, ws_size);
   40|  3.44k|            }
   41|       |
   42|  3.44k|            if constexpr (Opts.null_terminated) {
   43|  3.44k|               while (whitespace_table[uint8_t(*it)]) {
   44|  3.44k|                  ++it;
   45|  3.44k|               }
   46|  3.44k|            }
   47|  3.44k|            else {
   48|  3.44k|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
   49|  3.44k|                  ++it;
   50|  3.44k|               }
   51|  3.44k|            }
   52|  3.44k|            ws_start = new_ws_start;
   53|  3.44k|            ws_size = size_t(it - new_ws_start);
   54|  3.44k|         };
   55|       |
   56|  3.44k|         auto skip_whitespace = [&] {
   57|  3.44k|            if constexpr (Opts.null_terminated) {
   58|  3.44k|               while (whitespace_table[uint8_t(*it)]) {
   59|  3.44k|                  ++it;
   60|  3.44k|               }
   61|  3.44k|            }
   62|  3.44k|            else {
   63|  3.44k|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
   64|  3.44k|                  ++it;
   65|  3.44k|               }
   66|  3.44k|            }
   67|  3.44k|         };
   68|       |
   69|  3.44k|         skip_whitespace();
   70|       |
   71|  25.4k|         while ([&]() -> bool {
  ------------------
  |  Branch (71:17): [True: 24.4k, False: 1.00k]
  ------------------
   72|  25.4k|            if constexpr (Opts.null_terminated) {
   73|  25.4k|               return true;
   74|  25.4k|            }
   75|  25.4k|            else {
   76|  25.4k|               return it < end;
   77|  25.4k|            }
   78|  25.4k|         }()) {
   79|  24.4k|            switch (json_types[uint8_t(*it)]) {
   80|    870|            case String: {
  ------------------
  |  Branch (80:13): [True: 870, False: 23.5k]
  ------------------
   81|    870|               const auto value = read_json_string(ctx, it, end);
   82|    870|               if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (82:20): [True: 98, False: 772]
  ------------------
   83|     98|                  return;
   84|     98|               }
   85|       |               // non-empty: the scanner reports an empty view as an error
   86|    772|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (86:20): [True: 57, False: 715]
  ------------------
   87|     57|                  return;
   88|     57|               }
   89|    715|               skip_whitespace();
   90|    715|               break;
   91|    772|            }
   92|  5.29k|            case Comma: {
  ------------------
  |  Branch (92:13): [True: 5.29k, False: 19.1k]
  ------------------
   93|  5.29k|               if (not put(',')) [[unlikely]] {
  ------------------
  |  Branch (93:20): [True: 36, False: 5.25k]
  ------------------
   94|     36|                  return;
   95|     36|               }
   96|  5.25k|               ++it;
   97|  5.25k|               skip_expected_whitespace();
   98|  5.25k|               break;
   99|  5.29k|            }
  100|    927|            case Number: {
  ------------------
  |  Branch (100:13): [True: 927, False: 23.5k]
  ------------------
  101|    927|               const auto value = read_json_number<Opts.null_terminated>(it, end);
  102|       |               // non-empty: a Number match is one valid character
  103|    927|               if (not put(value)) [[unlikely]] {
  ------------------
  |  Branch (103:20): [True: 34, False: 893]
  ------------------
  104|     34|                  return;
  105|     34|               }
  106|    893|               skip_whitespace();
  107|    893|               break;
  108|    927|            }
  109|  1.18k|            case Colon: {
  ------------------
  |  Branch (109:13): [True: 1.18k, False: 23.2k]
  ------------------
  110|  1.18k|               if (not put(':')) [[unlikely]] {
  ------------------
  |  Branch (110:20): [True: 6, False: 1.17k]
  ------------------
  111|      6|                  return;
  112|      6|               }
  113|  1.17k|               ++it;
  114|  1.17k|               skip_whitespace();
  115|  1.17k|               break;
  116|  1.18k|            }
  117|  4.82k|            case Array_Start: {
  ------------------
  |  Branch (117:13): [True: 4.82k, False: 19.6k]
  ------------------
  118|  4.82k|               if (not put('[')) [[unlikely]] {
  ------------------
  |  Branch (118:20): [True: 35, False: 4.78k]
  ------------------
  119|     35|                  return;
  120|     35|               }
  121|  4.78k|               ++it;
  122|  4.78k|               skip_expected_whitespace();
  123|  4.78k|               break;
  124|  4.82k|            }
  125|    949|            case Array_End: {
  ------------------
  |  Branch (125:13): [True: 949, False: 23.5k]
  ------------------
  126|    949|               if (not put(']')) [[unlikely]] {
  ------------------
  |  Branch (126:20): [True: 12, False: 937]
  ------------------
  127|     12|                  return;
  128|     12|               }
  129|    937|               ++it;
  130|    937|               skip_whitespace();
  131|    937|               break;
  132|    949|            }
  133|    384|            case Null: {
  ------------------
  |  Branch (133:13): [True: 384, False: 24.0k]
  ------------------
  134|       |               // The type table matched on the first byte alone; see match_literal for why writing
  135|       |               // the literal from the writer's own spelling needs the rest of it checked. Stepping
  136|       |               // over it unchecked also puts `it` past `end`, and from there the loop goes on
  137|       |               // minifying whatever follows the document into an output sized for the document.
  138|    384|               if (not match_literal<"null">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (138:20): [True: 109, False: 275]
  ------------------
  139|    109|                  return;
  140|    109|               }
  141|    275|               if (not put("null")) [[unlikely]] {
  ------------------
  |  Branch (141:20): [True: 11, False: 264]
  ------------------
  142|     11|                  return;
  143|     11|               }
  144|    264|               skip_whitespace();
  145|    264|               break;
  146|    275|            }
  147|    798|            case Bool: {
  ------------------
  |  Branch (147:13): [True: 798, False: 23.6k]
  ------------------
  148|    798|               if (*it == 't') {
  ------------------
  |  Branch (148:20): [True: 457, False: 341]
  ------------------
  149|    457|                  if (not match_literal<"true">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (149:23): [True: 101, False: 356]
  ------------------
  150|    101|                     return;
  151|    101|                  }
  152|    356|                  if (not put("true")) [[unlikely]] {
  ------------------
  |  Branch (152:23): [True: 11, False: 345]
  ------------------
  153|     11|                     return;
  154|     11|                  }
  155|    345|                  skip_whitespace();
  156|    345|                  break;
  157|    356|               }
  158|    341|               else {
  159|    341|                  if (not match_literal<"false">(ctx, it, end)) [[unlikely]] {
  ------------------
  |  Branch (159:23): [True: 123, False: 218]
  ------------------
  160|    123|                     return;
  161|    123|                  }
  162|    218|                  if (not put("false")) [[unlikely]] {
  ------------------
  |  Branch (162:23): [True: 11, False: 207]
  ------------------
  163|     11|                     return;
  164|     11|                  }
  165|    207|                  skip_whitespace();
  166|    207|                  break;
  167|    218|               }
  168|    798|            }
  169|  5.12k|            case Object_Start: {
  ------------------
  |  Branch (169:13): [True: 5.12k, False: 19.3k]
  ------------------
  170|  5.12k|               if (not put('{')) [[unlikely]] {
  ------------------
  |  Branch (170:20): [True: 31, False: 5.09k]
  ------------------
  171|     31|                  return;
  172|     31|               }
  173|  5.09k|               ++it;
  174|  5.09k|               skip_expected_whitespace();
  175|  5.09k|               break;
  176|  5.12k|            }
  177|    903|            case Object_End: {
  ------------------
  |  Branch (177:13): [True: 903, False: 23.5k]
  ------------------
  178|    903|               if (not put('}')) [[unlikely]] {
  ------------------
  |  Branch (178:20): [True: 7, False: 896]
  ------------------
  179|      7|                  return;
  180|      7|               }
  181|    896|               ++it;
  182|    896|               skip_whitespace();
  183|    896|               break;
  184|    903|            }
  185|  1.63k|            case Comment: {
  ------------------
  |  Branch (185:13): [True: 1.63k, False: 22.8k]
  ------------------
  186|  1.63k|               if constexpr (Opts.comments) {
  187|  1.63k|                  const auto comment = read_jsonc_comment(ctx, it, end);
  188|  1.63k|                  if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (188:23): [True: 126, False: 1.50k]
  ------------------
  189|    126|                     return;
  190|    126|                  }
  191|       |                  // A line comment is dropped rather than written out. Minifying is what removes
  192|       |                  // the newline that ends it, and a line comment with no line break behind it
  193|       |                  // comments out the whole rest of the output.
  194|  1.50k|                  if (not comment.line) {
  ------------------
  |  Branch (194:23): [True: 456, False: 1.05k]
  ------------------
  195|       |                     // non-empty: an empty view comes with an error
  196|    456|                     if (not put(comment.text)) [[unlikely]] {
  ------------------
  |  Branch (196:26): [True: 53, False: 403]
  ------------------
  197|     53|                        return;
  198|     53|                     }
  199|    456|                  }
  200|  1.45k|                  skip_whitespace();
  201|  1.45k|                  break;
  202|       |               }
  203|       |               else {
  204|       |                  [[fallthrough]];
  205|       |               }
  206|  1.63k|            }
  207|  3.20k|            [[unlikely]] default: {
  ------------------
  |  Branch (207:26): [True: 1.57k, False: 22.8k]
  ------------------
  208|       |               // A null terminated run carries no bound in its loop condition, so it ends here, on
  209|       |               // the terminator, which is not a JSON token. Reaching it is the end of the document
  210|       |               // rather than an error -- unclassified is how the type table reports both, and
  211|       |               // without this the minifier left syntax_error behind on every input it was ever
  212|       |               // given, valid or not, which is what made its error not worth returning.
  213|       |               if constexpr (Opts.null_terminated) {
  214|       |                  if (it >= end) {
  215|       |                     return;
  216|       |                  }
  217|       |               }
  218|  3.20k|               ctx.error = error_code::syntax_error;
  219|  3.20k|               return;
  220|  1.63k|            }
  221|  24.4k|            }
  222|  24.4k|         }
  223|  3.44k|      }
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__15arrayIcLm64EEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE0_clEv:
   56|  10.3k|         auto skip_whitespace = [&] {
   57|       |            if constexpr (Opts.null_terminated) {
   58|       |               while (whitespace_table[uint8_t(*it)]) {
   59|       |                  ++it;
   60|       |               }
   61|       |            }
   62|  10.3k|            else {
   63|   103k|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (63:23): [True: 103k, False: 440]
  |  Branch (63:37): [True: 93.2k, False: 9.88k]
  ------------------
   64|  93.2k|                  ++it;
   65|  93.2k|               }
   66|  10.3k|            }
   67|  10.3k|         };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__15arrayIcLm64EEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE1_clEv:
   71|  25.4k|         while ([&]() -> bool {
   72|       |            if constexpr (Opts.null_terminated) {
   73|       |               return true;
   74|       |            }
   75|  25.4k|            else {
   76|  25.4k|               return it < end;
   77|  25.4k|            }
   78|  25.4k|         }()) {
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__15arrayIcLm64EEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clINS8_17basic_string_viewIcNS8_11char_traitsIcEEEEEEDaSO_:
   31|  2.15k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__15arrayIcLm64EEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIcEEDaSO_:
   31|  18.2k|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__15arrayIcLm64EEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlvE_clEv:
   36|  15.1k|         auto skip_expected_whitespace = [&] {
   37|  15.1k|            auto new_ws_start = it;
   38|  15.1k|            if (ws_size && std::ptrdiff_t(ws_size) < end - it) [[likely]] {
  ------------------
  |  Branch (38:17): [True: 10.3k, False: 4.81k]
  |  Branch (38:28): [True: 9.14k, False: 1.18k]
  ------------------
   39|  9.14k|               skip_matching_ws(ws_start, it, ws_size);
   40|  9.14k|            }
   41|       |
   42|       |            if constexpr (Opts.null_terminated) {
   43|       |               while (whitespace_table[uint8_t(*it)]) {
   44|       |                  ++it;
   45|       |               }
   46|       |            }
   47|  15.1k|            else {
   48|  18.2M|               while ((it < end) && whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (48:23): [True: 18.2M, False: 562]
  |  Branch (48:37): [True: 18.2M, False: 14.5k]
  ------------------
   49|  18.2M|                  ++it;
   50|  18.2M|               }
   51|  15.1k|            }
   52|  15.1k|            ws_start = new_ws_start;
   53|  15.1k|            ws_size = size_t(it - new_ws_start);
   54|  15.1k|         };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__15arrayIcLm64EEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA5_cEEDaSO_:
   31|    631|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };
_ZZN3glz6detail11minify_jsonITnDaXtlNS_4optsELj10ELb0ELb1ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__15arrayIcLm64EEEmEEvOT0_OT1_OT2_OT3_RT4_ENKUlRKT_E_clIA6_cEEDaSO_:
   31|    218|         const auto put = [&](const auto& x) { return emit_bytes<false>(ctx, b, ix, x); };

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

_ZN3glz10comparitorIL_ZZNS_6detail13match_literalITnNS_14string_literalEXtlNS3_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETkNS_10is_contextERNS_7contextERPKcS9_EEbOT0_OT1_T2_E1sELm4EcEEbPKSD_:
  245|  3.31k|   {
  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|  3.31k|      else if constexpr (N == 4) {
  286|  3.31k|         static constexpr auto packed = pack<Str, 4>();
  287|  3.31k|         uint32_t in;
  288|  3.31k|         std::memcpy(&in, other, 4);
  289|       |         if constexpr (std::endian::native == std::endian::big) {
  290|       |            in = std::byteswap(in);
  291|       |         }
  292|  3.31k|         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|  3.31k|   }
_ZN3glz10comparitorIL_ZZNS_6detail13match_literalITnNS_14string_literalEXtlNS3_ILm5EEEtlA5_cLc116ELc114ELc117ELc101EEEETkNS_10is_contextERNS_7contextERPKcS9_EEbOT0_OT1_T2_E1sELm4EcEEbPKSD_:
  245|  3.88k|   {
  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|  3.88k|      else if constexpr (N == 4) {
  286|  3.88k|         static constexpr auto packed = pack<Str, 4>();
  287|  3.88k|         uint32_t in;
  288|  3.88k|         std::memcpy(&in, other, 4);
  289|       |         if constexpr (std::endian::native == std::endian::big) {
  290|       |            in = std::byteswap(in);
  291|       |         }
  292|  3.88k|         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|  3.88k|   }
_ZN3glz10comparitorIL_ZZNS_6detail13match_literalITnNS_14string_literalEXtlNS3_ILm6EEEtlA6_cLc102ELc97ELc108ELc115ELc101EEEETkNS_10is_contextERNS_7contextERPKcS9_EEbOT0_OT1_T2_E1sELm5EcEEbPKSD_:
  245|  3.04k|   {
  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|  3.04k|      else if constexpr (N == 5) {
  277|  3.04k|         static constexpr auto packed = pack<Str, 4>();
  278|  3.04k|         uint32_t in;
  279|  3.04k|         std::memcpy(&in, other, 4);
  280|       |         if constexpr (std::endian::native == std::endian::big) {
  281|       |            in = std::byteswap(in);
  282|       |         }
  283|  3.04k|         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|  3.04k|   }

_ZN3glz4dumpILb0ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvNS1_17basic_string_viewIcS4_EERT0_Rm:
  192|  22.1k|   {
  193|  22.1k|      const auto n = str.size();
  194|  22.1k|      if constexpr (vector_like<B>) {
  195|       |         if constexpr (Checked) {
  196|       |            const auto k = ix + n;
  197|       |            if (ix + n > b.size()) [[unlikely]] {
  198|       |               grow_buffer(b, k);
  199|       |            }
  200|       |         }
  201|  22.1k|      }
  202|  22.1k|      std::memcpy(&b[ix], str.data(), n);
  203|  22.1k|      ix += n;
  204|  22.1k|   }
_ZN3glz4dumpILb0ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEETkNS_10byte_sizedEcEEvT1_RT0_Rm:
  150|   100k|   {
  151|       |      if constexpr (Checked && vector_like<B>) {
  152|       |         if (ix == b.size()) [[unlikely]] {
  153|       |            grow_buffer(b, b.size() == 0 ? 64 : ix + 1);
  154|       |         }
  155|       |      }
  156|   100k|      assign_maybe_cast(c, b, ix);
  157|   100k|      ++ix;
  158|   100k|   }
_ZN3glz17assign_maybe_castITkNS_10byte_sizedEcNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvT_RT0_Rm:
   95|   100k|   {
   96|   100k|      using V = std::decay_t<decltype(b[0])>;
   97|   100k|      using C = std::decay_t<decltype(c)>;
   98|   100k|      if constexpr (std::same_as<V, C>) {
   99|   100k|         b[ix] = c;
  100|       |      }
  101|       |      else {
  102|       |         b[ix] = static_cast<V>(c);
  103|       |      }
  104|   100k|   }
_ZN3glz4dumpILb0ENSt3__15arrayIcLm64EEEEEvNS1_17basic_string_viewIcNS1_11char_traitsIcEEEERT0_Rm:
  192|  2.82k|   {
  193|  2.82k|      const auto n = str.size();
  194|       |      if constexpr (vector_like<B>) {
  195|       |         if constexpr (Checked) {
  196|       |            const auto k = ix + n;
  197|       |            if (ix + n > b.size()) [[unlikely]] {
  198|       |               grow_buffer(b, k);
  199|       |            }
  200|       |         }
  201|       |      }
  202|  2.82k|      std::memcpy(&b[ix], str.data(), n);
  203|  2.82k|      ix += n;
  204|  2.82k|   }
_ZN3glz4dumpILb0ENSt3__15arrayIcLm64EEETkNS_10byte_sizedEcEEvT1_RT0_Rm:
  150|  18.1k|   {
  151|       |      if constexpr (Checked && vector_like<B>) {
  152|       |         if (ix == b.size()) [[unlikely]] {
  153|       |            grow_buffer(b, b.size() == 0 ? 64 : ix + 1);
  154|       |         }
  155|       |      }
  156|  18.1k|      assign_maybe_cast(c, b, ix);
  157|  18.1k|      ++ix;
  158|  18.1k|   }
_ZN3glz17assign_maybe_castITkNS_10byte_sizedEcNSt3__15arrayIcLm64EEEEEvT_RT0_Rm:
   95|  18.1k|   {
   96|  18.1k|      using V = std::decay_t<decltype(b[0])>;
   97|  18.1k|      using C = std::decay_t<decltype(c)>;
   98|  18.1k|      if constexpr (std::same_as<V, C>) {
   99|  18.1k|         b[ix] = c;
  100|       |      }
  101|       |      else {
  102|       |         b[ix] = static_cast<V>(c);
  103|       |      }
  104|  18.1k|   }

_ZN3glz16skip_matching_wsIcRPKcEEvPKT_OT0_m:
  730|  63.8k|   {
  731|  63.8k|      if (length > 7) {
  ------------------
  |  Branch (731:11): [True: 30.7k, False: 33.1k]
  ------------------
  732|  30.7k|         uint64_t v[2];
  733|  54.5k|         while (length > 8) {
  ------------------
  |  Branch (733:17): [True: 35.8k, False: 18.7k]
  ------------------
  734|  35.8k|            std::memcpy(v, ws, 8);
  735|  35.8k|            std::memcpy(v + 1, it, 8);
  736|  35.8k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (736:17): [True: 11.9k, False: 23.8k]
  ------------------
  737|  11.9k|               return;
  738|  11.9k|            }
  739|  23.8k|            length -= 8;
  740|  23.8k|            ws += 8;
  741|  23.8k|            it += 8;
  742|  23.8k|         }
  743|       |
  744|  18.7k|         const auto shift = 8 - length;
  745|  18.7k|         ws -= shift;
  746|  18.7k|         it -= shift;
  747|       |
  748|  18.7k|         std::memcpy(v, ws, 8);
  749|  18.7k|         std::memcpy(v + 1, it, 8);
  750|  18.7k|         if (v[0] != v[1]) {
  ------------------
  |  Branch (750:14): [True: 8.63k, False: 10.1k]
  ------------------
  751|  8.63k|            return;
  752|  8.63k|         }
  753|  10.1k|         it += 8;
  754|  10.1k|         return;
  755|  18.7k|      }
  756|  33.1k|      {
  757|  33.1k|         constexpr uint64_t n{sizeof(uint32_t)};
  758|  33.1k|         if (length >= n) {
  ------------------
  |  Branch (758:14): [True: 14.7k, False: 18.4k]
  ------------------
  759|  14.7k|            uint32_t v[2];
  760|  14.7k|            std::memcpy(v, ws, n);
  761|  14.7k|            std::memcpy(v + 1, it, n);
  762|  14.7k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (762:17): [True: 8.37k, False: 6.33k]
  ------------------
  763|  8.37k|               return;
  764|  8.37k|            }
  765|  6.33k|            length -= n;
  766|  6.33k|            ws += n;
  767|  6.33k|            it += n;
  768|  6.33k|         }
  769|  33.1k|      }
  770|  24.7k|      {
  771|  24.7k|         constexpr uint64_t n{sizeof(uint16_t)};
  772|  24.7k|         if (length >= n) {
  ------------------
  |  Branch (772:14): [True: 11.9k, False: 12.8k]
  ------------------
  773|  11.9k|            uint16_t v[2];
  774|  11.9k|            std::memcpy(v, ws, n);
  775|  11.9k|            std::memcpy(v + 1, it, n);
  776|  11.9k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (776:17): [True: 6.55k, False: 5.35k]
  ------------------
  777|  6.55k|               return;
  778|  6.55k|            }
  779|       |            // length -= n;
  780|       |            // ws += n;
  781|  5.35k|            it += n;
  782|  5.35k|         }
  783|  24.7k|      }
  784|       |      // We have to call a whitespace check after this function
  785|       |      // in case the whitespace is mismatching.
  786|       |      // So, we forgo this check as to not duplicate.
  787|       |      /*if (length && *ws == *it) {
  788|       |         ++it;
  789|       |      }*/
  790|  24.7k|   }

