LLVMFuzzerTestOneInput:
    7|  11.0k|{
    8|       |   // non-null terminated
    9|  11.0k|   {
   10|  11.0k|      const std::vector<char> buffer{Data, Data + Size};
   11|       |
   12|  11.0k|      static constexpr glz::opts opts{.null_terminated = false};
   13|  11.0k|      glz::generic json{};
   14|  11.0k|      auto ec = glz::read<opts>(json, buffer);
   15|  11.0k|      if (!ec) {
  ------------------
  |  Branch (15:11): [True: 2.71k, False: 8.36k]
  ------------------
   16|  2.71k|         [[maybe_unused]] auto s = json.size();
   17|  2.71k|      }
   18|  11.0k|   }
   19|       |
   20|       |   // use a vector with null termination instead of a std::string to avoid
   21|       |   // small string optimization to hide bounds problems
   22|  11.0k|   std::vector<char> buffer{Data, Data + Size};
   23|  11.0k|   buffer.push_back('\0');
   24|       |
   25|       |   // const qualified input buffer
   26|  11.0k|   {
   27|  11.0k|      const auto& input = buffer;
   28|  11.0k|      glz::generic json{};
   29|  11.0k|      auto ec = glz::read_json(json, input);
   30|  11.0k|      if (!ec) {
  ------------------
  |  Branch (30:11): [True: 2.71k, False: 8.36k]
  ------------------
   31|  2.71k|         [[maybe_unused]] auto s = json.size();
   32|  2.71k|      }
   33|  11.0k|   }
   34|       |
   35|       |   // non-const input buffer
   36|  11.0k|   {
   37|  11.0k|      glz::generic json{};
   38|  11.0k|      auto ec = glz::read_json(json, buffer);
   39|  11.0k|      if (!ec) {
  ------------------
  |  Branch (39:11): [True: 2.71k, False: 8.36k]
  ------------------
   40|  2.71k|         [[maybe_unused]] auto s = json.size();
   41|  2.71k|      }
   42|  11.0k|   }
   43|       |
   44|  11.0k|   return 0;
   45|  11.0k|}

_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEED2Ev:
  569|   156k|      {
  570|   156k|         free_data();
  571|   156k|         free_index();
  572|   156k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE9free_dataEv:
  266|   156k|      {
  267|   156k|         destroy_all();
  268|   156k|         ::operator delete(data_);
  269|   156k|         data_ = nullptr;
  270|   156k|         size_ = 0;
  271|   156k|         capacity_ = 0;
  272|   156k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE11destroy_allEv:
  259|   385k|      {
  260|  5.18M|         for (uint32_t i = 0; i < size_; ++i) {
  ------------------
  |  Branch (260:31): [True: 4.80M, False: 385k]
  ------------------
  261|  4.80M|            std::destroy_at(data_ + i);
  262|  4.80M|         }
  263|   385k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE10free_indexEv:
  308|   156k|      {
  309|   156k|         std::free(index_);
  310|   156k|         index_ = nullptr;
  311|   156k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEC2Ev:
  566|  74.6k|      ordered_small_map() = default;
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEC2EOS4_:
  610|  81.9k|         : data_(other.data_), size_(other.size_), capacity_(other.capacity_), index_(other.index_)
  611|  81.9k|      {
  612|  81.9k|         other.data_ = nullptr;
  613|  81.9k|         other.size_ = 0;
  614|  81.9k|         other.capacity_ = 0;
  615|  81.9k|         other.index_ = nullptr;
  616|  81.9k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEixERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE:
  932|  2.60M|      {
  933|  2.60M|         return subscript_or_insert(key, [&] { emplace_back_impl(key, mapped_type{}); });
  934|  2.60M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE19subscript_or_insertINSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEZNS4_ixERKSC_EUlvE_EERS3_RKT_OT0_:
  491|  2.60M|      {
  492|  2.60M|         if (size_ <= linear_search_threshold) {
  ------------------
  |  Branch (492:14): [True: 470k, False: 2.13M]
  ------------------
  493|   470k|            auto it = linear_find(key);
  494|   470k|            if (it != end()) return it->second;
  ------------------
  |  Branch (494:17): [True: 23.9k, False: 446k]
  ------------------
  495|   446k|            append_fn();
  496|   446k|            return data_[size_ - 1].second;
  497|   470k|         }
  498|       |
  499|  2.13M|         const uint32_t h = hash_key(key);
  500|  2.13M|         if (try_bloom_insert(h, append_fn)) {
  ------------------
  |  Branch (500:14): [True: 1.41M, False: 722k]
  ------------------
  501|  1.41M|            return data_[size_ - 1].second;
  502|  1.41M|         }
  503|       |
  504|   722k|         auto [it, pos, _] = index_find_or_pos(key, h);
  505|   722k|         if (it != end()) return it->second;
  ------------------
  |  Branch (505:14): [True: 594k, False: 128k]
  ------------------
  506|       |
  507|   128k|         append_fn();
  508|   128k|         bloom_set(h);
  509|   128k|         if (index_size() > 0) {
  ------------------
  |  Branch (509:14): [True: 128k, False: 0]
  ------------------
  510|   128k|            const uint32_t n = index_->size;
  511|   128k|            ensure_index_capacity(static_cast<size_type>(n) + 1);
  512|   128k|            auto* entries = index_entries();
  513|   128k|            if (pos < n) {
  ------------------
  |  Branch (513:17): [True: 123k, False: 4.84k]
  ------------------
  514|   123k|               std::memmove(entries + pos + 1, entries + pos, (n - pos) * sizeof(hash_index_entry));
  515|   123k|            }
  516|   128k|            entries[pos] = {h, size_ - 1};
  517|   128k|            index_->size = size_;
  518|   128k|         }
  519|   128k|         return data_[size_ - 1].second;
  520|   722k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE11linear_findINSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEEEPNS6_4pairISC_S3_EERKT_:
  421|   470k|      {
  422|  2.18M|         for (uint32_t i = 0; i < size_; ++i) {
  ------------------
  |  Branch (422:31): [True: 1.74M, False: 446k]
  ------------------
  423|  1.74M|            if (data_[i].first == key) return data_ + i;
  ------------------
  |  Branch (423:17): [True: 23.9k, False: 1.71M]
  ------------------
  424|  1.74M|         }
  425|   446k|         return data_ + size_;
  426|   470k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE3endEv:
  649|  1.19M|      iterator end() noexcept { return data_ + size_; }
_ZZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEixERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEENKUlvE_clEv:
  933|  1.98M|         return subscript_or_insert(key, [&] { emplace_back_impl(key, mapped_type{}); });
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE17emplace_back_implIJRKNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEES3_EEEvDpOT_:
  243|  1.98M|      {
  244|  1.98M|         grow_if_needed();
  245|  1.98M|         std::construct_at(data_ + size_, std::forward<Args>(args)...);
  246|  1.98M|         ++size_;
  247|  1.98M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE14grow_if_neededEv:
  217|  1.98M|      {
  218|  1.98M|         if (size_ == capacity_) {
  ------------------
  |  Branch (218:14): [True: 228k, False: 1.75M]
  ------------------
  219|   228k|            if (size_ == max_u32) {
  ------------------
  |  Branch (219:17): [True: 0, False: 228k]
  ------------------
  220|      0|               throw_capacity_overflow();
  221|      0|            }
  222|   228k|            const uint32_t new_cap = next_data_capacity(capacity_);
  223|   228k|            reallocate_data(new_cap);
  224|   228k|         }
  225|  1.98M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE18next_data_capacityEj:
  120|   228k|      {
  121|   228k|         if (current == 0) return 4;
  ------------------
  |  Branch (121:14): [True: 66.8k, False: 162k]
  ------------------
  122|   162k|         if (current > (max_u32 / 2)) return max_u32;
  ------------------
  |  Branch (122:14): [True: 0, False: 162k]
  ------------------
  123|   162k|         return current * 2;
  124|   162k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE15reallocate_dataEj:
  205|   228k|      {
  206|   228k|         if (new_cap < size_) {
  ------------------
  |  Branch (206:14): [True: 0, False: 228k]
  ------------------
  207|      0|            throw_capacity_overflow();
  208|      0|         }
  209|   228k|         auto* new_data = allocate_and_relocate(new_cap);
  210|   228k|         destroy_all();
  211|   228k|         ::operator delete(data_);
  212|   228k|         data_ = new_data;
  213|   228k|         capacity_ = new_cap;
  214|   228k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE21allocate_and_relocateEj:
  159|   228k|      {
  160|   228k|         auto* new_data = static_cast<value_type*>(::operator new(checked_data_allocation_bytes(new_cap)));
  161|   228k|#if __cpp_exceptions
  162|   228k|         uint32_t constructed = 0;
  163|   228k|         try {
  164|  3.04M|            for (; constructed < size_; ++constructed) {
  ------------------
  |  Branch (164:20): [True: 2.81M, False: 228k]
  ------------------
  165|  2.81M|               std::construct_at(new_data + constructed, std::move_if_noexcept(data_[constructed]));
  166|  2.81M|            }
  167|   228k|         }
  168|   228k|         catch (...) {
  169|      0|            destroy_range(new_data, constructed);
  170|      0|            ::operator delete(new_data);
  171|      0|            throw;
  172|      0|         }
  173|       |#else
  174|       |         for (uint32_t i = 0; i < size_; ++i) {
  175|       |            std::construct_at(new_data + i, std::move_if_noexcept(data_[i]));
  176|       |         }
  177|       |#endif
  178|   228k|         return new_data;
  179|   228k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE29checked_data_allocation_bytesEj:
  134|   228k|      {
  135|   228k|         if (count > ((std::numeric_limits<size_t>::max)() / sizeof(value_type))) {
  ------------------
  |  Branch (135:14): [True: 0, False: 228k]
  ------------------
  136|      0|            GLZ_THROW_OR_ABORT(std::bad_alloc{});
  ------------------
  |  |    8|      0|#define GLZ_THROW_OR_ABORT(EXC) (throw(EXC))
  ------------------
  137|      0|         }
  138|   228k|         return static_cast<size_t>(count) * sizeof(value_type);
  139|   228k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE8hash_keyENSt3__117basic_string_viewIcNS5_11char_traitsIcEEEE:
   97|  6.28M|      static uint32_t hash_key(std::string_view key) noexcept { return sweethash::sweet32(key); }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE16try_bloom_insertIRZNS4_ixERKNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEEUlvE_EEbjOT_:
  529|  2.13M|      {
  530|  2.13M|         if (index_ && size_ <= bloom_threshold && !bloom_maybe_contains(h)) {
  ------------------
  |  Branch (530:14): [True: 2.08M, False: 44.8k]
  |  Branch (530:24): [True: 1.96M, False: 126k]
  |  Branch (530:52): [True: 1.41M, False: 551k]
  ------------------
  531|       |            // Definitely not present — skip the search
  532|  1.41M|            append_fn();
  533|  1.41M|            bloom_set(h);
  534|       |            // Index is now stale (index_->size < size_), will rebuild on next lookup or false positive
  535|  1.41M|            return true;
  536|  1.41M|         }
  537|   722k|         return false;
  538|  2.13M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE20bloom_maybe_containsEj:
  285|  1.96M|      {
  286|  1.96M|         const uint32_t a = h & bloom_mask;
  287|  1.96M|         const uint32_t b = (h >> 10) & bloom_mask;
  288|  1.96M|         return (index_->bloom[a >> 3] & (uint8_t(1) << (a & 7))) && (index_->bloom[b >> 3] & (uint8_t(1) << (b & 7)));
  ------------------
  |  Branch (288:17): [True: 646k, False: 1.31M]
  |  Branch (288:70): [True: 551k, False: 95.1k]
  ------------------
  289|  1.96M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE17index_find_or_posINSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEEENS4_17index_find_resultERKT_j:
  400|   722k|      {
  401|   722k|         ensure_index();
  402|       |
  403|   722k|         const auto* base = index_entries();
  404|   722k|         const auto* idx_end = base + index_->size;
  405|   722k|         const auto* p = branchless_lower_bound(base, index_->size, h);
  406|   722k|         const size_t pos = static_cast<size_t>(p - base);
  407|       |
  408|       |         // Scan adjacent entries with matching hash
  409|   726k|         for (auto* scan = p; scan != idx_end && scan->key_hash == h; ++scan) {
  ------------------
  |  Branch (409:31): [True: 721k, False: 4.84k]
  |  Branch (409:50): [True: 598k, False: 123k]
  ------------------
  410|   598k|            if (data_[scan->index].first == key) {
  ------------------
  |  Branch (410:17): [True: 594k, False: 3.87k]
  ------------------
  411|   594k|               return {data_ + scan->index, pos, h};
  412|   594k|            }
  413|   598k|         }
  414|       |
  415|   128k|         return {data_ + size_, pos, h};
  416|   722k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE12ensure_indexEv:
  360|   722k|      {
  361|   722k|         if (size_ <= linear_search_threshold) return;
  ------------------
  |  Branch (361:14): [True: 0, False: 722k]
  ------------------
  362|   722k|         const auto current = index_size();
  363|   722k|         if (current == size_) return; // fully current
  ------------------
  |  Branch (363:14): [True: 466k, False: 256k]
  ------------------
  364|       |
  365|   256k|         if (current == 0 || (size_ - current) > linear_search_threshold) {
  ------------------
  |  Branch (365:14): [True: 44.8k, False: 211k]
  |  Branch (365:30): [True: 67.9k, False: 143k]
  ------------------
  366|   112k|            rebuild_index(); // full rebuild
  367|   112k|            return;
  368|   112k|         }
  369|       |
  370|       |         // Incrementally insert-sort the few new entries
  371|   498k|         for (uint32_t i = current; i < size_; ++i) {
  ------------------
  |  Branch (371:37): [True: 354k, False: 143k]
  ------------------
  372|   354k|            const hash_index_entry entry{hash_key(data_[i].first), i};
  373|   354k|            const auto* base = index_entries();
  374|   354k|            const auto* p = branchless_lower_bound(base, index_->size, entry.key_hash);
  375|   354k|            auto pos = static_cast<size_t>(p - base);
  376|       |
  377|   354k|            const uint32_t m = index_->size;
  378|   354k|            ensure_index_capacity(static_cast<size_type>(m) + 1);
  379|   354k|            auto* entries = index_entries();
  380|   354k|            if (pos < m) {
  ------------------
  |  Branch (380:17): [True: 334k, False: 20.0k]
  ------------------
  381|   334k|               std::memmove(entries + pos + 1, entries + pos, (m - pos) * sizeof(hash_index_entry));
  382|   334k|            }
  383|   354k|            entries[pos] = entry;
  384|   354k|            index_->size = i + 1;
  385|   354k|         }
  386|   143k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE13rebuild_indexEv:
  343|   112k|      {
  344|   112k|         ensure_index_capacity(static_cast<size_type>(size_));
  345|   112k|         bloom_clear();
  346|   112k|         auto* entries = index_entries();
  347|  3.91M|         for (uint32_t i = 0; i < size_; ++i) {
  ------------------
  |  Branch (347:31): [True: 3.79M, False: 112k]
  ------------------
  348|  3.79M|            const uint32_t h = hash_key(data_[i].first);
  349|  3.79M|            entries[i] = {h, i};
  350|  3.79M|            bloom_set(h);
  351|  3.79M|         }
  352|   112k|         std::sort(entries, entries + size_, [](const auto& a, const auto& b) { return a.key_hash < b.key_hash; });
  353|   112k|         index_->size = size_;
  354|   112k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE11bloom_clearEv:
  291|   112k|      void bloom_clear() const noexcept { std::memset(index_->bloom, 0, bloom_bytes); }
_ZZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE13rebuild_indexEvENKUlRKT_RKT0_E_clINS4_16hash_index_entryESD_EEDaS7_SA_:
  352|  25.1M|         std::sort(entries, entries + size_, [](const auto& a, const auto& b) { return a.key_hash < b.key_hash; });
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE22branchless_lower_boundEPKNS4_16hash_index_entryEmj:
  440|  1.07M|      {
  441|  7.76M|         while (len > 1) {
  ------------------
  |  Branch (441:17): [True: 6.68M, False: 1.07M]
  ------------------
  442|  6.68M|            size_t half = len / 2;
  443|  6.68M|            p += (p[half - 1].key_hash < target) * half;
  444|  6.68M|            len -= half;
  445|  6.68M|         }
  446|       |         // Final element check: advance past it if it's less than target
  447|  1.07M|         p += (len == 1 && p->key_hash < target);
  ------------------
  |  Branch (447:16): [True: 1.07M, False: 0]
  |  Branch (447:28): [True: 24.9k, False: 1.05M]
  ------------------
  448|  1.07M|         return p;
  449|  1.07M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE9bloom_setEj:
  277|  5.33M|      {
  278|  5.33M|         const uint32_t a = h & bloom_mask;
  279|  5.33M|         const uint32_t b = (h >> 10) & bloom_mask;
  280|  5.33M|         index_->bloom[a >> 3] |= uint8_t(1) << (a & 7);
  281|  5.33M|         index_->bloom[b >> 3] |= uint8_t(1) << (b & 7);
  282|  5.33M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE10index_sizeEv:
  300|   851k|      uint32_t index_size() const noexcept { return index_ ? index_->size : 0; }
  ------------------
  |  Branch (300:53): [True: 806k, False: 44.8k]
  ------------------
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE21ensure_index_capacityEm:
  314|   595k|      {
  315|   595k|         if (needed == 0) return;
  ------------------
  |  Branch (315:14): [True: 0, False: 595k]
  ------------------
  316|   595k|         if (needed > static_cast<size_type>(max_u32)) {
  ------------------
  |  Branch (316:14): [True: 0, False: 595k]
  ------------------
  317|      0|            throw_index_overflow();
  318|      0|         }
  319|   595k|         const auto needed_u32 = static_cast<uint32_t>(needed);
  320|   595k|         if (index_ && index_->capacity >= needed_u32) return;
  ------------------
  |  Branch (320:14): [True: 551k, False: 44.8k]
  |  Branch (320:24): [True: 486k, False: 64.5k]
  ------------------
  321|   109k|         uint32_t cap = index_ ? index_->capacity : 0;
  ------------------
  |  Branch (321:25): [True: 64.5k, False: 44.8k]
  ------------------
  322|   221k|         while (cap < needed_u32) {
  ------------------
  |  Branch (322:17): [True: 112k, False: 109k]
  ------------------
  323|   112k|            const uint32_t next = next_index_capacity(cap);
  324|   112k|            if (next <= cap) {
  ------------------
  |  Branch (324:17): [True: 0, False: 112k]
  ------------------
  325|      0|               throw_index_overflow();
  326|      0|            }
  327|   112k|            cap = next;
  328|   112k|         }
  329|   109k|         auto* block = static_cast<index_header*>(std::realloc(index_, checked_index_allocation_bytes(cap)));
  330|   109k|         if (!block) GLZ_THROW_OR_ABORT(std::bad_alloc{});
  ------------------
  |  |    8|      0|#define GLZ_THROW_OR_ABORT(EXC) (throw(EXC))
  ------------------
  |  Branch (330:14): [True: 0, False: 109k]
  ------------------
  331|   109k|         if (!index_) {
  ------------------
  |  Branch (331:14): [True: 44.8k, False: 64.5k]
  ------------------
  332|  44.8k|            block->size = 0;
  333|  44.8k|            std::memset(block->bloom, 0, bloom_bytes);
  334|  44.8k|         }
  335|   109k|         block->capacity = cap;
  336|   109k|         index_ = block;
  337|   109k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE19next_index_capacityEj:
  127|   112k|      {
  128|   112k|         if (current == 0) return 16;
  ------------------
  |  Branch (128:14): [True: 44.8k, False: 67.6k]
  ------------------
  129|  67.6k|         if (current > (max_u32 / 2)) return max_u32;
  ------------------
  |  Branch (129:14): [True: 0, False: 67.6k]
  ------------------
  130|  67.6k|         return current * 2;
  131|  67.6k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE30checked_index_allocation_bytesEj:
  142|   109k|      {
  143|   109k|         constexpr size_t header = sizeof(index_header);
  144|   109k|         constexpr size_t entry = sizeof(hash_index_entry);
  145|   109k|         if (count > (((std::numeric_limits<size_t>::max)() - header) / entry)) {
  ------------------
  |  Branch (145:14): [True: 0, False: 109k]
  ------------------
  146|      0|            GLZ_THROW_OR_ABORT(std::bad_alloc{});
  ------------------
  |  |    8|      0|#define GLZ_THROW_OR_ABORT(EXC) (throw(EXC))
  ------------------
  147|      0|         }
  148|   109k|         return header + static_cast<size_t>(count) * entry;
  149|   109k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE13index_entriesEv:
  296|  1.67M|      {
  297|  1.67M|         return static_cast<hash_index_entry*>(static_cast<void*>(index_ + 1));
  298|  1.67M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE4sizeEv:
  663|     12|      size_type size() const noexcept { return size_; }

_ZN3glz10get_memberIRNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEERKMS4_NSt3__17variantIJDndNS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEbNS6_6vectorIS4_NSB_IS4_EEEENS3_IS4_EEEEEEEDcOT_OT0_:
  616|  7.81M|   {
  617|  7.81M|      using V = std::decay_t<decltype(element)>;
  618|  7.81M|      if constexpr (std::is_member_object_pointer_v<V>) {
  619|  7.81M|         return value.*element;
  620|       |      }
  621|       |      else if constexpr (std::is_member_function_pointer_v<V>) {
  622|       |         return element;
  623|       |      }
  624|       |      else if constexpr (std::invocable<Element, Value> && not eigen_t<Element>) {
  625|       |         // Eigen places a static_assert inside of the operator()(), so we must target
  626|       |         // matrix types and reject them from the invocable check
  627|       |         // Eigen ought to put the check in the `enable_if` for operator()()
  628|       |         return std::invoke(std::forward<Element>(element), std::forward<Value>(value));
  629|       |      }
  630|       |      else if constexpr (std::is_pointer_v<V> && !std::is_reference_v<Element>) {
  631|       |         if constexpr (std::invocable<decltype(*element), Value>) {
  632|       |            return std::invoke(*element, std::forward<Value>(value));
  633|       |         }
  634|       |         else {
  635|       |            return *element;
  636|       |         }
  637|       |      }
  638|       |      else {
  639|       |         return element;
  640|       |      }
  641|  7.81M|   }

_ZNK3glz9error_ctxcvbEv:
  136|  33.2k|      operator bool() const noexcept { return ec != error_code::none; }
_ZN3glz11enter_depthITkNS_10is_contextENS_7contextEEEbRT_:
  281|  1.92M|   {
  282|  1.92M|      if (ctx.depth >= max_recursive_depth_limit) [[unlikely]] {
  ------------------
  |  Branch (282:11): [True: 35, False: 1.92M]
  ------------------
  283|     35|         ctx.error = error_code::exceeded_max_recursive_depth;
  284|     35|         return true;
  285|     35|      }
  286|  1.92M|      ++ctx.depth;
  287|  1.92M|      return false;
  288|  1.92M|   }
_ZN3glz18charge_speculationITkNS_10is_contextENS_7contextEEEbRT_m:
  249|  52.0k|   {
  250|  52.0k|      if constexpr (requires { ctx.speculation_budget; }) {
  251|  52.0k|         if (ctx.speculation_budget == 0) {
  ------------------
  |  Branch (251:14): [True: 0, False: 52.0k]
  ------------------
  252|      0|            return true;
  253|      0|         }
  254|  52.0k|         ctx.speculation_budget = consumed >= ctx.speculation_budget ? 1 : ctx.speculation_budget - consumed;
  ------------------
  |  Branch (254:35): [True: 0, False: 52.0k]
  ------------------
  255|  52.0k|         return ctx.speculation_budget > 1;
  256|       |      }
  257|       |      else {
  258|       |         return true;
  259|       |      }
  260|  52.0k|   }
_ZN3glz21speculation_exhaustedITkNS_10is_contextENS_7contextEEEbRT_:
  266|  2.92k|   {
  267|  2.92k|      if constexpr (requires { ctx.speculation_budget; }) {
  268|  2.92k|         return ctx.speculation_budget == 1; // the latched floor; 0 means unbudgeted
  269|       |      }
  270|       |      else {
  271|       |         return false;
  272|       |      }
  273|  2.92k|   }

_ZN3glz4readITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10contiguousERKNSt3__16vectorIcNS6_9allocatorIcEEEEQaa14read_supportedIT0_XdtT_6formatEEnt18is_input_streamingIT1_EEENS_9error_ctxERSD_OSE_:
  219|  11.0k|   {
  220|  11.0k|      format_context_t<Opts.format> ctx{};
  221|  11.0k|      return read<Opts>(value, buffer, ctx);
  222|  11.0k|   }
_ZN3glz4readITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10contiguousERKNSt3__16vectorIcNS6_9allocatorIcEEEETkNS_10is_contextERNS_7contextEQaa14read_supportedIT0_XdtT_6formatEEnt18is_input_streamingIT1_EEENS_9error_ctxERSF_OSG_OT2_:
  136|  11.0k|   {
  137|  11.0k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
  138|  11.0k|      using Buffer = std::remove_reference_t<decltype(buffer)>;
  139|       |
  140|  11.0k|      if constexpr (Opts.format != NDJSON) {
  141|  11.0k|         if (buffer.empty()) [[unlikely]] {
  ------------------
  |  Branch (141:14): [True: 0, False: 11.0k]
  ------------------
  142|      0|            ctx.error = error_code::no_read_input;
  143|      0|            return {0, ctx.error, ctx.custom_error_message};
  144|      0|         }
  145|  11.0k|      }
  146|       |
  147|  11.0k|      constexpr bool use_padded = resizable<Buffer> && non_const_buffer<Buffer> && !check_disable_padding(Opts);
  ------------------
  |  Branch (147:35): [Folded, False: 11.0k]
  |  Branch (147:56): [Folded, False: 0]
  |  Branch (147:84): [True: 0, Folded]
  ------------------
  148|       |
  149|  11.0k|      [[maybe_unused]] size_t original_size{};
  150|       |      if constexpr (use_padded) {
  151|       |         // Pad the buffer for SWAR
  152|       |         original_size = buffer.size();
  153|       |         buffer.resize(original_size + padding_bytes);
  154|       |      }
  155|       |
  156|  11.0k|      auto [it, end] = read_iterators<Opts, use_padded>(buffer);
  157|  11.0k|      auto start = it;
  158|  11.0k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (158:11): [True: 0, False: 11.0k]
  ------------------
  159|      0|         goto finish;
  160|      0|      }
  161|       |
  162|       |      // Bound the speculative re-parsing a variant resolution may do, in bytes, relative to this
  163|       |      // input. Seeded per read so a reused context starts fresh. See charge_speculation.
  164|  11.0k|      if constexpr (requires { ctx.speculation_budget; }) {
  165|  11.0k|         const size_t proportional = max_speculative_parse_factor * size_t(end - it);
  166|  11.0k|         ctx.speculation_budget =
  167|  11.0k|            (proportional > min_speculative_parse_bytes ? proportional : min_speculative_parse_bytes) + 2;
  ------------------
  |  Branch (167:14): [True: 296, False: 10.7k]
  ------------------
  168|  11.0k|      }
  169|       |
  170|       |      // A YAML context marks its outermost parse with stream_begin and seeds its expansion budgets
  171|       |      // there, so clearing it here is what makes those budgets per-read like the one above. A
  172|       |      // reused context would otherwise carry a spent budget into the next document and reject a
  173|       |      // valid one, and would leave stream_begin pointing into the buffer of the previous read.
  174|       |      // Nested YAML parses do not route through glz::read, so they still cannot reseed themselves.
  175|       |      if constexpr (requires { ctx.stream_begin; }) {
  176|       |         ctx.stream_begin = nullptr;
  177|       |      }
  178|       |
  179|       |      if constexpr (use_padded) {
  180|       |         parse<Opts.format>::template op<is_padded_on<Opts>()>(value, ctx, it, end);
  181|       |      }
  182|  11.0k|      else {
  183|  11.0k|         parse<Opts.format>::template op<is_padded_off<Opts>()>(value, ctx, it, end);
  184|  11.0k|      }
  185|       |
  186|  11.0k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (186:11): [True: 8.36k, False: 2.71k]
  ------------------
  187|  8.36k|         goto finish;
  188|  8.36k|      }
  189|       |
  190|       |      // The JSON RFC 8259 defines: JSON-text = ws value ws
  191|       |      // So, trailing whitespace is permitted and sometimes we want to
  192|       |      // validate this, even though this memory will not affect Glaze.
  193|       |      if constexpr (check_validate_trailing_whitespace(Opts)) {
  194|       |         if (it < end) {
  195|       |            skip_ws<Opts>(ctx, it, end);
  196|       |            if (bool(ctx.error)) [[unlikely]] {
  197|       |               goto finish;
  198|       |            }
  199|       |            if (it != end) [[unlikely]] {
  200|       |               ctx.error = error_code::syntax_error;
  201|       |            }
  202|       |         }
  203|       |      }
  204|       |
  205|  11.0k|   finish:
  206|  11.0k|      finalize_top_level_read<Opts>(ctx, start, it, end);
  207|       |
  208|       |      if constexpr (use_padded) {
  209|       |         // Restore the original buffer state
  210|       |         buffer.resize(original_size);
  211|       |      }
  212|       |
  213|  11.0k|      return {size_t(it - start), ctx.error, ctx.custom_error_message};
  214|  2.71k|   }
_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEELb0ETkNS_10contiguousERKNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT1_:
   40|  11.0k|   {
   41|  11.0k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  11.0k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  11.0k|      auto end = reinterpret_cast<const char*>(buffer.data()); // to be incremented
   45|       |
   46|       |      if constexpr (Padded) {
   47|       |         end += buffer.size() - padding_bytes;
   48|       |      }
   49|  11.0k|      else {
   50|  11.0k|         end += buffer.size();
   51|  11.0k|      }
   52|       |
   53|  11.0k|      return std::pair{it, end};
   54|  11.0k|   }
_ZN3glz23finalize_top_level_readITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEEEvOT0_PKcS7_S7_:
  115|  11.0k|   {
  116|  11.0k|      if constexpr (Opts.format == JSON && !check_null_terminated(Opts)) {
  117|       |         // Deliberately not [[unlikely]]: a body that ends with the buffer lands here on every
  118|       |         // successful read, which is the ordinary case for a registry parsing a wire span.
  119|       |         // start < it, not !=, because a streaming origin can be empty or overshoot on an error
  120|       |         // path; neither is an absent value.
  121|  11.0k|         if (ctx.error == error_code::end_reached && ctx.depth == 0 && it == end && start < it) {
  ------------------
  |  Branch (121:14): [True: 1.59k, False: 9.48k]
  |  Branch (121:54): [True: 15, False: 1.58k]
  |  Branch (121:72): [True: 15, False: 0]
  |  Branch (121:85): [True: 15, False: 0]
  ------------------
  122|     15|            context ws_ctx{}; // only written to when skip_ws parses a comment; the result is unused
  123|     15|            const char* consumed = start;
  124|     15|            skip_ws<Opts>(ws_ctx, consumed, it);
  125|     15|            if (consumed == it) {
  ------------------
  |  Branch (125:17): [True: 13, False: 2]
  ------------------
  126|     13|               ctx.error = error_code::no_read_input;
  127|     13|            }
  128|     15|         }
  129|  11.0k|      }
  130|  11.0k|      finalize_read_context<Opts>(ctx);
  131|  11.0k|   }
_ZN3glz21finalize_read_contextITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEEEvOT0_:
   76|  11.0k|   {
   77|       |      // A partial read stops as soon as it has the fields it was asked for, so it unwinds through
   78|       |      // its enclosing containers on an error code rather than through their closing braces, and
   79|       |      // none of them decrement depth on the way out. Depth is left standing at whatever nesting the
   80|       |      // last field sat at.
   81|       |      //
   82|       |      // That has to be cleared here rather than left for the next read to trip over. This is the
   83|       |      // one path that reports success with depth still raised, and depth is what settle_end_reached
   84|       |      // reads to tell a completed parse from a truncated one -- so a context reused after a partial
   85|       |      // read would see a later well-formed buffer settle to unexpected_end. Reads that end any
   86|       |      // other way either return depth to zero themselves or carry an error, and a context holding
   87|       |      // an error short-circuits the next read before it parses anything.
   88|       |      if constexpr (check_partial_read(Opts)) {
   89|       |         if (ctx.error == error_code::partial_read_complete) [[likely]] {
   90|       |            ctx.error = error_code::none;
   91|       |            ctx.depth = 0;
   92|       |            return;
   93|       |         }
   94|       |      }
   95|  11.0k|      settle_end_reached(ctx);
   96|  11.0k|   }
_ZN3glz18settle_end_reachedITkNS_10is_contextERNS_7contextEEEvOT_:
   68|  33.2k|   {
   69|  33.2k|      if (ctx.error == error_code::end_reached) {
  ------------------
  |  Branch (69:11): [True: 1.58k, False: 31.6k]
  ------------------
   70|  1.58k|         ctx.error = (ctx.depth == 0) ? error_code::none : error_code::unexpected_end;
  ------------------
  |  Branch (70:22): [True: 2, False: 1.58k]
  ------------------
   71|  1.58k|      }
   72|  33.2k|   }
_ZN3glz4readITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10contiguousERKNSt3__16vectorIcNS6_9allocatorIcEEEETkNS_10is_contextERNS_7contextEQaa14read_supportedIT0_XdtT_6formatEEnt18is_input_streamingIT1_EEENS_9error_ctxERSF_OSG_OT2_:
  136|  11.0k|   {
  137|  11.0k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
  138|  11.0k|      using Buffer = std::remove_reference_t<decltype(buffer)>;
  139|       |
  140|  11.0k|      if constexpr (Opts.format != NDJSON) {
  141|  11.0k|         if (buffer.empty()) [[unlikely]] {
  ------------------
  |  Branch (141:14): [True: 0, False: 11.0k]
  ------------------
  142|      0|            ctx.error = error_code::no_read_input;
  143|      0|            return {0, ctx.error, ctx.custom_error_message};
  144|      0|         }
  145|  11.0k|      }
  146|       |
  147|  11.0k|      constexpr bool use_padded = resizable<Buffer> && non_const_buffer<Buffer> && !check_disable_padding(Opts);
  ------------------
  |  Branch (147:35): [Folded, False: 11.0k]
  |  Branch (147:56): [Folded, False: 0]
  |  Branch (147:84): [True: 0, Folded]
  ------------------
  148|       |
  149|  11.0k|      [[maybe_unused]] size_t original_size{};
  150|       |      if constexpr (use_padded) {
  151|       |         // Pad the buffer for SWAR
  152|       |         original_size = buffer.size();
  153|       |         buffer.resize(original_size + padding_bytes);
  154|       |      }
  155|       |
  156|  11.0k|      auto [it, end] = read_iterators<Opts, use_padded>(buffer);
  157|  11.0k|      auto start = it;
  158|  11.0k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (158:11): [True: 0, False: 11.0k]
  ------------------
  159|      0|         goto finish;
  160|      0|      }
  161|       |
  162|       |      // Bound the speculative re-parsing a variant resolution may do, in bytes, relative to this
  163|       |      // input. Seeded per read so a reused context starts fresh. See charge_speculation.
  164|  11.0k|      if constexpr (requires { ctx.speculation_budget; }) {
  165|  11.0k|         const size_t proportional = max_speculative_parse_factor * size_t(end - it);
  166|  11.0k|         ctx.speculation_budget =
  167|  11.0k|            (proportional > min_speculative_parse_bytes ? proportional : min_speculative_parse_bytes) + 2;
  ------------------
  |  Branch (167:14): [True: 299, False: 10.7k]
  ------------------
  168|  11.0k|      }
  169|       |
  170|       |      // A YAML context marks its outermost parse with stream_begin and seeds its expansion budgets
  171|       |      // there, so clearing it here is what makes those budgets per-read like the one above. A
  172|       |      // reused context would otherwise carry a spent budget into the next document and reject a
  173|       |      // valid one, and would leave stream_begin pointing into the buffer of the previous read.
  174|       |      // Nested YAML parses do not route through glz::read, so they still cannot reseed themselves.
  175|       |      if constexpr (requires { ctx.stream_begin; }) {
  176|       |         ctx.stream_begin = nullptr;
  177|       |      }
  178|       |
  179|       |      if constexpr (use_padded) {
  180|       |         parse<Opts.format>::template op<is_padded_on<Opts>()>(value, ctx, it, end);
  181|       |      }
  182|  11.0k|      else {
  183|  11.0k|         parse<Opts.format>::template op<is_padded_off<Opts>()>(value, ctx, it, end);
  184|  11.0k|      }
  185|       |
  186|  11.0k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (186:11): [True: 8.36k, False: 2.71k]
  ------------------
  187|  8.36k|         goto finish;
  188|  8.36k|      }
  189|       |
  190|       |      // The JSON RFC 8259 defines: JSON-text = ws value ws
  191|       |      // So, trailing whitespace is permitted and sometimes we want to
  192|       |      // validate this, even though this memory will not affect Glaze.
  193|       |      if constexpr (check_validate_trailing_whitespace(Opts)) {
  194|       |         if (it < end) {
  195|       |            skip_ws<Opts>(ctx, it, end);
  196|       |            if (bool(ctx.error)) [[unlikely]] {
  197|       |               goto finish;
  198|       |            }
  199|       |            if (it != end) [[unlikely]] {
  200|       |               ctx.error = error_code::syntax_error;
  201|       |            }
  202|       |         }
  203|       |      }
  204|       |
  205|  11.0k|   finish:
  206|  11.0k|      finalize_top_level_read<Opts>(ctx, start, it, end);
  207|       |
  208|       |      if constexpr (use_padded) {
  209|       |         // Restore the original buffer state
  210|       |         buffer.resize(original_size);
  211|       |      }
  212|       |
  213|  11.0k|      return {size_t(it - start), ctx.error, ctx.custom_error_message};
  214|  2.71k|   }
_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEELb0ETkNS_10contiguousERKNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT1_:
   40|  11.0k|   {
   41|  11.0k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  11.0k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  11.0k|      auto end = reinterpret_cast<const char*>(buffer.data()); // to be incremented
   45|       |
   46|       |      if constexpr (Padded) {
   47|       |         end += buffer.size() - padding_bytes;
   48|       |      }
   49|  11.0k|      else {
   50|  11.0k|         end += buffer.size();
   51|  11.0k|      }
   52|       |
   53|  11.0k|      return std::pair{it, end};
   54|  11.0k|   }
_ZN3glz23finalize_top_level_readITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEEEvOT0_PKcS7_S7_:
  115|  22.1k|   {
  116|       |      if constexpr (Opts.format == JSON && !check_null_terminated(Opts)) {
  117|       |         // Deliberately not [[unlikely]]: a body that ends with the buffer lands here on every
  118|       |         // successful read, which is the ordinary case for a registry parsing a wire span.
  119|       |         // start < it, not !=, because a streaming origin can be empty or overshoot on an error
  120|       |         // path; neither is an absent value.
  121|       |         if (ctx.error == error_code::end_reached && ctx.depth == 0 && it == end && start < it) {
  122|       |            context ws_ctx{}; // only written to when skip_ws parses a comment; the result is unused
  123|       |            const char* consumed = start;
  124|       |            skip_ws<Opts>(ws_ctx, consumed, it);
  125|       |            if (consumed == it) {
  126|       |               ctx.error = error_code::no_read_input;
  127|       |            }
  128|       |         }
  129|       |      }
  130|  22.1k|      finalize_read_context<Opts>(ctx);
  131|  22.1k|   }
_ZN3glz21finalize_read_contextITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEEEvOT0_:
   76|  22.1k|   {
   77|       |      // A partial read stops as soon as it has the fields it was asked for, so it unwinds through
   78|       |      // its enclosing containers on an error code rather than through their closing braces, and
   79|       |      // none of them decrement depth on the way out. Depth is left standing at whatever nesting the
   80|       |      // last field sat at.
   81|       |      //
   82|       |      // That has to be cleared here rather than left for the next read to trip over. This is the
   83|       |      // one path that reports success with depth still raised, and depth is what settle_end_reached
   84|       |      // reads to tell a completed parse from a truncated one -- so a context reused after a partial
   85|       |      // read would see a later well-formed buffer settle to unexpected_end. Reads that end any
   86|       |      // other way either return depth to zero themselves or carry an error, and a context holding
   87|       |      // an error short-circuits the next read before it parses anything.
   88|       |      if constexpr (check_partial_read(Opts)) {
   89|       |         if (ctx.error == error_code::partial_read_complete) [[likely]] {
   90|       |            ctx.error = error_code::none;
   91|       |            ctx.depth = 0;
   92|       |            return;
   93|       |         }
   94|       |      }
   95|  22.1k|      settle_end_reached(ctx);
   96|  22.1k|   }
_ZN3glz4readITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10contiguousERNSt3__16vectorIcNS6_9allocatorIcEEEETkNS_10is_contextERNS_7contextEQaa14read_supportedIT0_XdtT_6formatEEnt18is_input_streamingIT1_EEENS_9error_ctxERSE_OSF_OT2_:
  136|  11.0k|   {
  137|  11.0k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
  138|  11.0k|      using Buffer = std::remove_reference_t<decltype(buffer)>;
  139|       |
  140|  11.0k|      if constexpr (Opts.format != NDJSON) {
  141|  11.0k|         if (buffer.empty()) [[unlikely]] {
  ------------------
  |  Branch (141:14): [True: 0, False: 11.0k]
  ------------------
  142|      0|            ctx.error = error_code::no_read_input;
  143|      0|            return {0, ctx.error, ctx.custom_error_message};
  144|      0|         }
  145|  11.0k|      }
  146|       |
  147|  11.0k|      constexpr bool use_padded = resizable<Buffer> && non_const_buffer<Buffer> && !check_disable_padding(Opts);
  ------------------
  |  Branch (147:35): [True: 0, Folded]
  |  Branch (147:56): [True: 0, Folded]
  |  Branch (147:84): [True: 0, Folded]
  ------------------
  148|       |
  149|  11.0k|      [[maybe_unused]] size_t original_size{};
  150|  11.0k|      if constexpr (use_padded) {
  151|       |         // Pad the buffer for SWAR
  152|  11.0k|         original_size = buffer.size();
  153|  11.0k|         buffer.resize(original_size + padding_bytes);
  154|  11.0k|      }
  155|       |
  156|  11.0k|      auto [it, end] = read_iterators<Opts, use_padded>(buffer);
  157|  11.0k|      auto start = it;
  158|  11.0k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (158:11): [True: 0, False: 11.0k]
  ------------------
  159|      0|         goto finish;
  160|      0|      }
  161|       |
  162|       |      // Bound the speculative re-parsing a variant resolution may do, in bytes, relative to this
  163|       |      // input. Seeded per read so a reused context starts fresh. See charge_speculation.
  164|  11.0k|      if constexpr (requires { ctx.speculation_budget; }) {
  165|  11.0k|         const size_t proportional = max_speculative_parse_factor * size_t(end - it);
  166|  11.0k|         ctx.speculation_budget =
  167|  11.0k|            (proportional > min_speculative_parse_bytes ? proportional : min_speculative_parse_bytes) + 2;
  ------------------
  |  Branch (167:14): [True: 299, False: 10.7k]
  ------------------
  168|  11.0k|      }
  169|       |
  170|       |      // A YAML context marks its outermost parse with stream_begin and seeds its expansion budgets
  171|       |      // there, so clearing it here is what makes those budgets per-read like the one above. A
  172|       |      // reused context would otherwise carry a spent budget into the next document and reject a
  173|       |      // valid one, and would leave stream_begin pointing into the buffer of the previous read.
  174|       |      // Nested YAML parses do not route through glz::read, so they still cannot reseed themselves.
  175|       |      if constexpr (requires { ctx.stream_begin; }) {
  176|       |         ctx.stream_begin = nullptr;
  177|       |      }
  178|       |
  179|  11.0k|      if constexpr (use_padded) {
  180|  11.0k|         parse<Opts.format>::template op<is_padded_on<Opts>()>(value, ctx, it, end);
  181|       |      }
  182|       |      else {
  183|       |         parse<Opts.format>::template op<is_padded_off<Opts>()>(value, ctx, it, end);
  184|       |      }
  185|       |
  186|  11.0k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (186:11): [True: 8.36k, False: 2.71k]
  ------------------
  187|  8.36k|         goto finish;
  188|  8.36k|      }
  189|       |
  190|       |      // The JSON RFC 8259 defines: JSON-text = ws value ws
  191|       |      // So, trailing whitespace is permitted and sometimes we want to
  192|       |      // validate this, even though this memory will not affect Glaze.
  193|       |      if constexpr (check_validate_trailing_whitespace(Opts)) {
  194|       |         if (it < end) {
  195|       |            skip_ws<Opts>(ctx, it, end);
  196|       |            if (bool(ctx.error)) [[unlikely]] {
  197|       |               goto finish;
  198|       |            }
  199|       |            if (it != end) [[unlikely]] {
  200|       |               ctx.error = error_code::syntax_error;
  201|       |            }
  202|       |         }
  203|       |      }
  204|       |
  205|  11.0k|   finish:
  206|  11.0k|      finalize_top_level_read<Opts>(ctx, start, it, end);
  207|       |
  208|  11.0k|      if constexpr (use_padded) {
  209|       |         // Restore the original buffer state
  210|  11.0k|         buffer.resize(original_size);
  211|  11.0k|      }
  212|       |
  213|  11.0k|      return {size_t(it - start), ctx.error, ctx.custom_error_message};
  214|  2.71k|   }
_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEELb1ETkNS_10contiguousERNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT1_:
   40|  11.0k|   {
   41|  11.0k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  11.0k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  11.0k|      auto end = reinterpret_cast<const char*>(buffer.data()); // to be incremented
   45|       |
   46|  11.0k|      if constexpr (Padded) {
   47|  11.0k|         end += buffer.size() - padding_bytes;
   48|       |      }
   49|       |      else {
   50|       |         end += buffer.size();
   51|       |      }
   52|       |
   53|  11.0k|      return std::pair{it, end};
   54|  11.0k|   }

_ZN3glz9sweethash7sweet32ITkNS0_16contiguous_rangeENSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEEjRKT_j:
  270|  6.28M|   {
  271|  6.28M|      return sweet32(static_cast<const void*>(s.data()), s.size(), seed);
  272|  6.28M|   }
_ZN3glz9sweethash7sweet32EPKvmj:
  154|  6.28M|   {
  155|  6.28M|      const uint8_t* p = static_cast<const uint8_t*>(data);
  156|       |
  157|       |      // For inputs <= 8 bytes, use simple hash (tail handler requires len >= 9)
  158|  6.28M|      if (len <= 8) {
  ------------------
  |  Branch (158:11): [True: 3.60M, False: 2.68M]
  ------------------
  159|  3.60M|         uint64_t v = 0;
  160|  3.60M|         switch (len) {
  161|   245k|         case 8:
  ------------------
  |  Branch (161:10): [True: 245k, False: 3.36M]
  ------------------
  162|   245k|            std::memcpy(&v, p, 8);
  163|   245k|            break;
  164|   324k|         case 7:
  ------------------
  |  Branch (164:10): [True: 324k, False: 3.28M]
  ------------------
  165|   324k|            std::memcpy(&v, p, 7);
  166|   324k|            break;
  167|   206k|         case 6:
  ------------------
  |  Branch (167:10): [True: 206k, False: 3.39M]
  ------------------
  168|   206k|            std::memcpy(&v, p, 6);
  169|   206k|            break;
  170|  50.9k|         case 5:
  ------------------
  |  Branch (170:10): [True: 50.9k, False: 3.55M]
  ------------------
  171|  50.9k|            std::memcpy(&v, p, 5);
  172|  50.9k|            break;
  173|   412k|         case 4:
  ------------------
  |  Branch (173:10): [True: 412k, False: 3.19M]
  ------------------
  174|   412k|            std::memcpy(&v, p, 4);
  175|   412k|            break;
  176|   139k|         case 3:
  ------------------
  |  Branch (176:10): [True: 139k, False: 3.46M]
  ------------------
  177|   139k|            std::memcpy(&v, p, 3);
  178|   139k|            break;
  179|  1.24M|         case 2:
  ------------------
  |  Branch (179:10): [True: 1.24M, False: 2.36M]
  ------------------
  180|  1.24M|            std::memcpy(&v, p, 2);
  181|  1.24M|            break;
  182|   931k|         case 1:
  ------------------
  |  Branch (182:10): [True: 931k, False: 2.67M]
  ------------------
  183|   931k|            v = p[0];
  184|   931k|            break;
  185|  52.4k|         default:
  ------------------
  |  Branch (185:10): [True: 52.4k, False: 3.55M]
  ------------------
  186|  52.4k|            break;
  187|  3.60M|         }
  188|  3.60M|         v = v ^ seed ^ (len + 1);
  189|  3.60M|         return static_cast<uint32_t>(v) ^ static_cast<uint32_t>(v >> 32);
  190|  3.60M|      }
  191|       |
  192|       |      // Full hash for inputs > 8 bytes
  193|  2.68M|      uint64_t seed64 = (static_cast<uint64_t>(seed) << 32) | static_cast<uint64_t>(seed);
  194|  2.68M|      uint64_t h = (seed64 ^ prime4) + (len * prime1);
  195|  2.68M|      const uint8_t* const end = p + len;
  196|       |
  197|  2.68M|      if (len >= 32) {
  ------------------
  |  Branch (197:11): [True: 1.30M, False: 1.37M]
  ------------------
  198|  1.30M|         uint64_t h1 = h;
  199|  1.30M|         uint64_t h2 = (seed64 * prime2) ^ prime3;
  200|  1.30M|         uint64_t h3 = (seed64 * prime3) ^ prime4;
  201|  1.30M|         uint64_t h4 = (seed64 * prime4) ^ prime5;
  202|       |
  203|  3.91M|         do {
  204|  3.91M|            uint64_t k1, k2, k3, k4;
  205|  3.91M|            std::memcpy(&k1, p, 8);
  206|  3.91M|            std::memcpy(&k2, p + 8, 8);
  207|  3.91M|            std::memcpy(&k3, p + 16, 8);
  208|  3.91M|            std::memcpy(&k4, p + 24, 8);
  209|       |
  210|  3.91M|            k1 = k1 * prime2;
  211|  3.91M|            k1 = k1 ^ (k1 >> 47);
  212|  3.91M|            h1 = h1 ^ k1;
  213|  3.91M|            h1 = h1 * prime1;
  214|       |
  215|  3.91M|            k2 = k2 * prime3;
  216|  3.91M|            k2 = k2 ^ (k2 >> 47);
  217|  3.91M|            h2 = h2 ^ k2;
  218|  3.91M|            h2 = h2 * prime2;
  219|       |
  220|  3.91M|            k3 = k3 * prime4;
  221|  3.91M|            k3 = k3 ^ (k3 >> 47);
  222|  3.91M|            h3 = h3 ^ k3;
  223|  3.91M|            h3 = h3 * prime3;
  224|       |
  225|  3.91M|            k4 = k4 * prime5;
  226|  3.91M|            k4 = k4 ^ (k4 >> 47);
  227|  3.91M|            h4 = h4 ^ k4;
  228|  3.91M|            h4 = h4 * prime4;
  229|       |
  230|  3.91M|            p = p + 32;
  231|  3.91M|            len = len - 32;
  232|  3.91M|         } while (len >= 32);
  ------------------
  |  Branch (232:19): [True: 2.60M, False: 1.30M]
  ------------------
  233|       |
  234|  1.30M|         h = h1 + h2 + h3 + h4;
  235|  1.30M|      }
  236|       |
  237|  6.89M|      while (len >= 8) {
  ------------------
  |  Branch (237:14): [True: 4.21M, False: 2.68M]
  ------------------
  238|  4.21M|         uint64_t k;
  239|  4.21M|         std::memcpy(&k, p, 8);
  240|  4.21M|         k = k * prime2;
  241|  4.21M|         k = k ^ (k >> 47);
  242|  4.21M|         h = h ^ k;
  243|  4.21M|         h = h * prime1;
  244|  4.21M|         p = p + 8;
  245|  4.21M|         len = len - 8;
  246|  4.21M|      }
  247|       |
  248|  2.68M|      if (len > 0) {
  ------------------
  |  Branch (248:11): [True: 2.27M, False: 411k]
  ------------------
  249|  2.27M|         uint64_t k;
  250|  2.27M|         std::memcpy(&k, end - 8, 8);
  251|  2.27M|         k = k * prime2;
  252|  2.27M|         k = k ^ (k >> 47);
  253|  2.27M|         k = k * prime3;
  254|  2.27M|         h = h ^ k;
  255|  2.27M|      }
  256|       |
  257|  2.68M|      h = mix64(h);
  258|  2.68M|      return static_cast<uint32_t>(h) ^ static_cast<uint32_t>(h >> 32);
  259|  6.28M|   }
_ZN3glz9sweethash5mix64Em:
   33|  2.68M|   {
   34|  2.68M|      v = v ^ (v >> 33);
   35|  2.68M|      v = v * prime2;
   36|  2.68M|      v = v ^ (v >> 29);
   37|  2.68M|      v = v * prime3;
   38|  2.68M|      return v;
   39|  2.68M|   }

_ZN3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEC2Ev:
  338|  6.78M|      generic_json() = default;
_ZN3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEED2Ev:
  114|  16.5M|      ~generic_json() = default;
_ZN3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEC2EOS3_:
  341|  9.76M|      generic_json(generic_json&& other) noexcept : data(std::move(other.data)) {}
_ZNK3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEE4sizeEv:
  534|  8.14k|      {
  535|  8.14k|         if (auto* v = get_if<object_t>()) {
  ------------------
  |  Branch (535:20): [True: 12, False: 8.13k]
  ------------------
  536|     12|            return v->size();
  537|     12|         }
  538|  8.13k|         else if (auto* v = get_if<array_t>()) {
  ------------------
  |  Branch (538:25): [True: 48, False: 8.08k]
  ------------------
  539|     48|            return v->size();
  540|     48|         }
  541|  8.08k|         else if (auto* v = get_if<std::string>()) {
  ------------------
  |  Branch (541:25): [True: 1.35k, False: 6.72k]
  ------------------
  542|  1.35k|            return v->size();
  543|  1.35k|         }
  544|  6.72k|         else {
  545|  6.72k|            return 0;
  546|  6.72k|         }
  547|  8.14k|      }
_ZNK3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEE6get_ifINS2_IS3_EEEEPKT_v:
  159|  8.14k|      {
  160|  8.14k|         return std::get_if<T>(&data);
  161|  8.14k|      }
_ZNK3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEE6get_ifINSt3__16vectorIS3_NS5_9allocatorIS3_EEEEEEPKT_v:
  159|  8.13k|      {
  160|  8.13k|         return std::get_if<T>(&data);
  161|  8.13k|      }
_ZNK3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEE6get_ifINSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEEEPKT_v:
  159|  8.08k|      {
  160|  8.08k|         return std::get_if<T>(&data);
  161|  8.08k|      }

_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  11.0k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  11.0k|         else {
   60|  11.0k|            using V = std::remove_cvref_t<T>;
   61|  11.0k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  11.0k|                                             end);
   63|  11.0k|         }
   64|  11.0k|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  11.0k|      {
  151|  11.0k|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  11.0k|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  11.0k|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  11.0k|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 4065|  11.0k|      {
 4066|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 4067|       |            read_adjacent<Options>(value, ctx, it, end);
 4068|       |         }
 4069|  11.0k|         else {
 4070|  11.0k|            read_deduced<Options>(value, ctx, it, end);
 4071|  11.0k|         }
 4072|  11.0k|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE12read_deducedITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 4076|  11.0k|      {
 4077|  11.0k|         constexpr auto Opts = ws_handled_off<Options>();
 4078|  11.0k|         if constexpr (variant_is_auto_deducible<T>()) {
 4079|  11.0k|            if constexpr (not check_ws_handled(Options)) {
 4080|  11.0k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (4080:20): [True: 13, False: 11.0k]
  ------------------
 4081|     13|                  return;
 4082|     13|               }
 4083|  11.0k|            }
 4084|       |
 4085|  11.0k|            switch (*it) {
 4086|      2|            case '\0':
  ------------------
  |  Branch (4086:13): [True: 2, False: 11.0k]
  ------------------
 4087|      2|               ctx.error = error_code::unexpected_end;
 4088|      2|               return;
 4089|  5.03k|            case '{': {
  ------------------
  |  Branch (4089:13): [True: 5.03k, False: 6.03k]
  ------------------
 4090|       |               // This branch consumes the brace itself and hands the object to a reader with
 4091|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 4092|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 4093|       |               // the reader below.
 4094|  5.03k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (4094:20): [True: 0, False: 5.03k]
  ------------------
 4095|      0|                  return;
 4096|      0|               }
 4097|       |
 4098|  5.03k|               ++it;
 4099|  5.03k|               if constexpr (not Opts.null_terminated) {
 4100|  5.03k|                  if (it == end) [[unlikely]] {
  ------------------
  |  Branch (4100:23): [True: 1, False: 5.03k]
  ------------------
 4101|      1|                     ctx.error = error_code::unexpected_end;
 4102|      1|                     return;
 4103|      1|                  }
 4104|  5.03k|               }
 4105|  5.03k|               using type_counts = variant_type_count<T>;
 4106|  5.03k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 4107|       |               if constexpr (n_object_candidates < 1) {
 4108|       |                  ctx.error = error_code::no_matching_variant_type;
 4109|       |                  return;
 4110|       |               }
 4111|  5.03k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 4112|  5.03k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 4113|  5.03k|                  using V = std::variant_alternative_t<first_idx, T>;
 4114|  5.03k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4114:23): [True: 5.03k, False: 1]
  ------------------
 4115|  5.03k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 4116|  5.03k|                  return;
 4117|       |               }
 4118|       |               else {
 4119|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 4120|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 4121|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 4122|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 4123|       |
 4124|       |                  // Track if we've encountered a tag and what value it had
 4125|       |                  std::optional<size_t> tag_specified_index{};
 4126|       |
 4127|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 4128|       |                     return;
 4129|       |                  }
 4130|       |                  // Once the reader knows which alternative this object holds it may have to read
 4131|       |                  // it again from here. Anchor the position rather than keep the pointer: the scan
 4132|       |                  // below skips values, and a streaming skip refills, which moves the window out
 4133|       |                  // from under a raw pointer (see rewind_anchor).
 4134|       |                  auto start = make_rewind_anchor(ctx, it);
 4135|       |                  bool first_key = true;
 4136|       |                  // Parse bifurcation for tagged variants:
 4137|       |                  //
 4138|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 4139|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 4140|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 4141|       |                  //
 4142|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 4143|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 4144|       |                  // it advances past the trailing comma so the object parser picks up at the
 4145|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 4146|       |                  //
 4147|       |                  // One exception: if the tag name is also a field on the resolved struct
 4148|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 4149|       |                  // the struct field. This override is applied inside each std::visit lambda.
 4150|       |                  //
 4151|       |                  // Either way the rewind can fail under a streaming read: the window only holds so
 4152|       |                  // much, and an object wider than it has no start left to return to.
 4153|       |                  auto position_after_tag = [&] {
 4154|       |                     if (first_key) {
 4155|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 4156|       |                        return true;
 4157|       |                     }
 4158|       |                     return start.rewind(ctx, it, end); // tag came later, re-parse from the beginning
 4159|       |                  };
 4160|       |                  // `first_key` also answers "were we reset to the object start", which is what
 4161|       |                  // position_after_tag does for every key but the first.
 4162|       |                  for (; *it != '}'; first_key = false) {
 4163|       |                     if (!first_key) {
 4164|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 4165|       |                           return;
 4166|       |                        }
 4167|       |                     }
 4168|       |
 4169|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4170|       |                        return;
 4171|       |                     }
 4172|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4173|       |                        return;
 4174|       |                     }
 4175|       |
 4176|       |                     auto* key_start = it;
 4177|       |                     skip_string_view(ctx, it, end);
 4178|       |                     if (bool(ctx.error)) [[unlikely]]
 4179|       |                        return;
 4180|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 4181|       |                        return;
 4182|       |                     const sv key = {key_start, size_t(it - key_start)};
 4183|       |
 4184|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4185|       |                        return;
 4186|       |                     }
 4187|       |
 4188|       |                     if constexpr (deduction_key_count > 0) {
 4189|       |                        // We first check if a tag is defined and see if the key matches the tag
 4190|       |                        if constexpr (not tag_v<T>.empty()) {
 4191|       |                           if (key == tag_v<T>) {
 4192|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 4193|       |                                 return;
 4194|       |                              }
 4195|       |
 4196|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 4197|       |
 4198|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 4199|       |                              if constexpr (std::integral<id_type>) {
 4200|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4201|       |                              }
 4202|       |                              else {
 4203|       |                                 // The id is turned into an index below and never leaves this
 4204|       |                                 // reader, so the view of the window it borrows cannot outlive it.
 4205|       |                                 parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4206|       |                              }
 4207|       |                              if (bool(ctx.error)) [[unlikely]]
 4208|       |                                 return;
 4209|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4210|       |                                 return;
 4211|       |                              }
 4212|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4213|       |                                 ctx.error = error_code::syntax_error;
 4214|       |                                 return;
 4215|       |                              }
 4216|       |
 4217|       |                              size_t type_index;
 4218|       |                              if constexpr (std::integral<id_type>) {
 4219|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4220|       |                              }
 4221|       |                              else {
 4222|       |                                 type_index = variant_id_to_index<T>::op(
 4223|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4224|       |                              }
 4225|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4226|       |                                 // Check if the deduced types include the tag-specified type
 4227|       |                                 // If not, the tag doesn't match the fields
 4228|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4229|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4230|       |                                 // Check if the tag-specified type is still possible
 4231|       |                                 const bool type_is_possible = possible_types[type_index];
 4232|       |                                 if (!type_is_possible) {
 4233|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4234|       |                                    ctx.error = error_code::no_matching_variant_type;
 4235|       |                                    return;
 4236|       |                                 }
 4237|       |
 4238|       |                                 if (!position_after_tag()) return;
 4239|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4240|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4241|       |                                 std::visit(
 4242|       |                                    [&](auto&& v) {
 4243|       |                                       using V = std::decay_t<decltype(v)>;
 4244|       |                                       constexpr bool is_object =
 4245|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4246|       |                                       if constexpr (variant_unit_alternative<V>) {
 4247|       |                                          // A unit alternative carries no data; its object holds only the
 4248|       |                                          // discriminator. Consume that body through an empty reflected object so
 4249|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4250|       |                                          detail::variant_unit_body unit_body{};
 4251|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4252|       |                                                                                             tag_literal>(unit_body,
 4253|       |                                                                                                          ctx, it, end);
 4254|       |                                       }
 4255|       |                                       else if constexpr (is_object) {
 4256|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4257|       |                                             // tag is a struct field, must re-parse
 4258|       |                                             if (!start.rewind(ctx, it, end)) return;
 4259|       |                                          }
 4260|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4261|       |                                                                                                           end);
 4262|       |                                       }
 4263|       |                                       else if constexpr (is_memory_object<V>) {
 4264|       |                                          if (!v) {
 4265|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4266|       |                                                if constexpr (requires { v.emplace(); }) {
 4267|       |                                                   v.emplace();
 4268|       |                                                }
 4269|       |                                                else {
 4270|       |                                                   v = typename V::value_type{};
 4271|       |                                                }
 4272|       |                                             }
 4273|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4274|       |                                                v = std::make_unique<typename V::element_type>();
 4275|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4276|       |                                                v = std::make_shared<typename V::element_type>();
 4277|       |                                             else if constexpr (constructible<V>) {
 4278|       |                                                v = meta_construct_v<V>();
 4279|       |                                             }
 4280|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4281|       |                                                                can_allocate_raw_pointer<Opts,
 4282|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4283|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4284|       |                                                   return;
 4285|       |                                                }
 4286|       |                                             }
 4287|       |                                             else {
 4288|       |                                                ctx.error = error_code::invalid_nullable_read;
 4289|       |                                                return;
 4290|       |                                                // Cannot read into unset nullable that is not std::optional,
 4291|       |                                                // std::unique_ptr, or std::shared_ptr
 4292|       |                                             }
 4293|       |                                          }
 4294|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4295|       |                                             // tag is a struct field, must re-parse
 4296|       |                                             if (!start.rewind(ctx, it, end)) return;
 4297|       |                                          }
 4298|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4299|       |                                             *v, ctx, it, end);
 4300|       |                                       }
 4301|       |                                       else if constexpr (custom_read<V>) {
 4302|       |                                          // Custom handlers parse the remaining body themselves and do not
 4303|       |                                          // accept the tag template parameter; the tag was already consumed.
 4304|       |                                          // This only works when the tag was the first key. If it came later,
 4305|       |                                          // we were reset to the object start and the custom handler would
 4306|       |                                          // absorb the tag, so error rather than corrupt the value.
 4307|       |                                          if (!first_key) {
 4308|       |                                             ctx.error = error_code::feature_not_supported;
 4309|       |                                             ctx.custom_error_message =
 4310|       |                                                "the tag must be the first key for a custom variant alternative";
 4311|       |                                             return;
 4312|       |                                          }
 4313|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4314|       |                                       }
 4315|       |                                    },
 4316|       |                                    value);
 4317|       |
 4318|       |                                 return; // we've decoded our target type
 4319|       |                              }
 4320|       |                              else [[unlikely]] {
 4321|       |                                 // Check if we have a default type (ids array shorter than variant)
 4322|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4323|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4324|       |                                 if constexpr (ids_size < variant_size) {
 4325|       |                                    // Use the first unlabeled type as the default
 4326|       |                                    const auto default_type_index = ids_size;
 4327|       |
 4328|       |                                    if (!position_after_tag()) return;
 4329|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4330|       |                                    if (value.index() != default_type_index)
 4331|       |                                       emplace_runtime_variant(value, default_type_index);
 4332|       |                                    std::visit(
 4333|       |                                       [&](auto&& v) {
 4334|       |                                          using V = std::decay_t<decltype(v)>;
 4335|       |                                          constexpr bool is_object =
 4336|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4337|       |                                          if constexpr (variant_unit_alternative<V>) {
 4338|       |                                             // A unit alternative carries no data; its object holds only the
 4339|       |                                             // discriminator. Consume that body through an empty reflected object so
 4340|       |                                             // unknown-key policy and terminator handling match every other
 4341|       |                                             // alternative.
 4342|       |                                             detail::variant_unit_body unit_body{};
 4343|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4344|       |                                                                                                tag_literal>(
 4345|       |                                                unit_body, ctx, it, end);
 4346|       |                                          }
 4347|       |                                          else if constexpr (is_object) {
 4348|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4349|       |                                                // tag is a struct field, must re-parse
 4350|       |                                                if (!start.rewind(ctx, it, end)) return;
 4351|       |                                             }
 4352|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4353|       |                                          }
 4354|       |                                          else if constexpr (is_memory_object<V>) {
 4355|       |                                             if (!v) {
 4356|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4357|       |                                                   if constexpr (requires { v.emplace(); }) {
 4358|       |                                                      v.emplace();
 4359|       |                                                   }
 4360|       |                                                   else {
 4361|       |                                                      v = typename V::value_type{};
 4362|       |                                                   }
 4363|       |                                                }
 4364|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4365|       |                                                   v = std::make_unique<typename V::element_type>();
 4366|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4367|       |                                                   v = std::make_shared<typename V::element_type>();
 4368|       |                                                else if constexpr (constructible<V>) {
 4369|       |                                                   v = meta_construct_v<V>();
 4370|       |                                                }
 4371|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4372|       |                                                                   can_allocate_raw_pointer<
 4373|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4374|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4375|       |                                                      return;
 4376|       |                                                   }
 4377|       |                                                }
 4378|       |                                                else {
 4379|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4380|       |                                                   return;
 4381|       |                                                }
 4382|       |                                             }
 4383|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4384|       |                                                // tag is a struct field, must re-parse
 4385|       |                                                if (!start.rewind(ctx, it, end)) return;
 4386|       |                                             }
 4387|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4388|       |                                                                                                              it, end);
 4389|       |                                          }
 4390|       |                                          else if constexpr (custom_read<V>) {
 4391|       |                                             // Custom handlers parse the remaining body themselves; this only
 4392|       |                                             // works when the tag was the first key (see above). If it came
 4393|       |                                             // later we were reset to the object start, so error rather than
 4394|       |                                             // let the custom handler absorb the tag.
 4395|       |                                             if (!first_key) {
 4396|       |                                                ctx.error = error_code::feature_not_supported;
 4397|       |                                                ctx.custom_error_message =
 4398|       |                                                   "the tag must be the first key for a custom variant alternative";
 4399|       |                                                return;
 4400|       |                                             }
 4401|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4402|       |                                          }
 4403|       |                                       },
 4404|       |                                       value);
 4405|       |
 4406|       |                                    return;
 4407|       |                                 }
 4408|       |                                 else {
 4409|       |                                    ctx.error = error_code::no_matching_variant_type;
 4410|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4411|       |                                    return;
 4412|       |                                 }
 4413|       |                              }
 4414|       |                           }
 4415|       |                        }
 4416|       |
 4417|       |                        // Inline decode_hash lookup for variant deduction
 4418|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4419|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4420|       |                        const auto deduction_index =
 4421|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4422|       |                              key.data(), key.data() + key.size(), key.size());
 4423|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4424|       |                           [[likely]] {
 4425|       |                           possible_types &= deduction_bits[deduction_index];
 4426|       |                        }
 4427|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4428|       |                           ctx.error = error_code::unknown_key;
 4429|       |                           return;
 4430|       |                        }
 4431|       |                     }
 4432|       |                     else if constexpr (not tag_v<T>.empty()) {
 4433|       |                        // empty object case for variant, if there are no normal elements
 4434|       |                        if (key == tag_v<T>) {
 4435|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4436|       |                              return;
 4437|       |                           }
 4438|       |
 4439|       |                           // The id is turned into an index below and never leaves this reader,
 4440|       |                           // so the view of the window it borrows cannot outlive that window.
 4441|       |                           std::string_view type_id{};
 4442|       |                           parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4443|       |                           if (bool(ctx.error)) [[unlikely]]
 4444|       |                              return;
 4445|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4446|       |                              return;
 4447|       |                           }
 4448|       |
 4449|       |                           const auto type_index = variant_id_to_index<T>::op(
 4450|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4451|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4452|       |                              if (!position_after_tag()) return;
 4453|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4454|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4455|       |                           }
 4456|       |                           else {
 4457|       |                              // Check if we have a default type (ids array shorter than variant)
 4458|       |                              constexpr auto ids_size = ids_v<T>.size();
 4459|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4460|       |                              if constexpr (ids_size < variant_size) {
 4461|       |                                 // Use the first unlabeled type as the default
 4462|       |                                 if (!position_after_tag()) return;
 4463|       |                                 const auto default_index = ids_size;
 4464|       |                                 tag_specified_index = default_index; // Store the default type index
 4465|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4466|       |                              }
 4467|       |                              else {
 4468|       |                                 ctx.error = error_code::no_matching_variant_type;
 4469|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4470|       |                                 return;
 4471|       |                              }
 4472|       |                           }
 4473|       |                           // Parse the type (handles tag skipping and unknown keys)
 4474|       |                           std::visit(
 4475|       |                              [&](auto&& v) {
 4476|       |                                 using V = std::decay_t<decltype(v)>;
 4477|       |                                 if constexpr (custom_read<V>) {
 4478|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4479|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4480|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4481|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4482|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4483|       |                                    // into its value, so error here rather than corrupt the result.
 4484|       |                                    if (!first_key) {
 4485|       |                                       ctx.error = error_code::feature_not_supported;
 4486|       |                                       ctx.custom_error_message =
 4487|       |                                          "the tag must be the first key for a custom variant alternative";
 4488|       |                                       return;
 4489|       |                                    }
 4490|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4491|       |                                 }
 4492|       |                                 else {
 4493|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4494|       |                                       // tag is a struct field, must re-parse
 4495|       |                                       if (!start.rewind(ctx, it, end)) return;
 4496|       |                                    }
 4497|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4498|       |                                 }
 4499|       |                              },
 4500|       |                              value);
 4501|       |                           return;
 4502|       |                        }
 4503|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4504|       |                           ctx.error = error_code::unknown_key;
 4505|       |                           return;
 4506|       |                        }
 4507|       |                        else {
 4508|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4509|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4510|       |                              return;
 4511|       |                           }
 4512|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4513|       |                           if (bool(ctx.error)) [[unlikely]]
 4514|       |                              return;
 4515|       |                           resync_window_end(ctx, end); // a streaming skip refills
 4516|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4517|       |                              return;
 4518|       |                           }
 4519|       |                           continue; // Continue loop to find the tag
 4520|       |                        }
 4521|       |                     }
 4522|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4523|       |                        ctx.error = error_code::unknown_key;
 4524|       |                        return;
 4525|       |                     }
 4526|       |
 4527|       |                     auto matching_types = possible_types.popcount();
 4528|       |                     if (matching_types == 0) {
 4529|       |                        ctx.error = error_code::no_matching_variant_type;
 4530|       |                        return;
 4531|       |                     }
 4532|       |                     // Only short-circuit for variants without tags
 4533|       |                     else if constexpr (tag_v<T>.empty()) {
 4534|       |                        if (matching_types == 1) {
 4535|       |                           if (!start.rewind(ctx, it, end)) return;
 4536|       |                           const auto type_index = possible_types.countr_zero();
 4537|       |
 4538|       |                           if (value.index() != static_cast<size_t>(type_index))
 4539|       |                              emplace_runtime_variant(value, type_index);
 4540|       |                           std::visit(
 4541|       |                              [&](auto&& v) {
 4542|       |                                 using V = std::decay_t<decltype(v)>;
 4543|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4544|       |                                 if constexpr (variant_unit_alternative<V>) {
 4545|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4546|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4547|       |                                    // terminator handling match every other alternative.
 4548|       |                                    detail::variant_unit_body unit_body{};
 4549|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4550|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4551|       |                                                                                                    end);
 4552|       |                                 }
 4553|       |                                 else if constexpr (is_object) {
 4554|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4555|       |                                 }
 4556|       |                                 else if constexpr (is_memory_object<V>) {
 4557|       |                                    if (!v) {
 4558|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4559|       |                                          if constexpr (requires { v.emplace(); }) {
 4560|       |                                             v.emplace();
 4561|       |                                          }
 4562|       |                                          else {
 4563|       |                                             v = typename V::value_type{};
 4564|       |                                          }
 4565|       |                                       }
 4566|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4567|       |                                          v = std::make_unique<typename V::element_type>();
 4568|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4569|       |                                          v = std::make_shared<typename V::element_type>();
 4570|       |                                       else if constexpr (constructible<V>) {
 4571|       |                                          v = meta_construct_v<V>();
 4572|       |                                       }
 4573|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4574|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4575|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4576|       |                                             return;
 4577|       |                                          }
 4578|       |                                       }
 4579|       |                                       else {
 4580|       |                                          ctx.error = error_code::invalid_nullable_read;
 4581|       |                                          return;
 4582|       |                                          // Cannot read into unset nullable that is not std::optional,
 4583|       |                                          // std::unique_ptr, or std::shared_ptr
 4584|       |                                       }
 4585|       |                                    }
 4586|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4587|       |                                       *v, ctx, it, end);
 4588|       |                                 }
 4589|       |                                 else if constexpr (custom_read<V>) {
 4590|       |                                    // Custom handlers parse the remaining body themselves.
 4591|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4592|       |                                 }
 4593|       |                              },
 4594|       |                              value);
 4595|       |
 4596|       |                           return; // we've decoded our target type
 4597|       |                        }
 4598|       |                     }
 4599|       |                     // For tagged variants, continue processing to validate tags
 4600|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4601|       |                        return;
 4602|       |                     }
 4603|       |
 4604|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4605|       |                     if (bool(ctx.error)) [[unlikely]]
 4606|       |                        return;
 4607|       |                     resync_window_end(ctx, end); // a streaming skip refills
 4608|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4609|       |                        return;
 4610|       |                     }
 4611|       |                  }
 4612|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4613|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4614|       |                     // After parsing all keys, check if we have multiple matching types
 4615|       |                     // If so, choose the one with the fewest fields
 4616|       |                     auto final_matching = possible_types.popcount();
 4617|       |                     if (final_matching == 0) {
 4618|       |                        ctx.error = error_code::no_matching_variant_type;
 4619|       |                     }
 4620|       |                     else if (final_matching == 1) {
 4621|       |                        // Single type remains after field deduction
 4622|       |                        const auto type_index = possible_types.countr_zero();
 4623|       |
 4624|       |                        // Validate against tag if one was specified
 4625|       |                        if (tag_specified_index.has_value() &&
 4626|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4627|       |                           ctx.error = error_code::no_matching_variant_type;
 4628|       |                           return;
 4629|       |                        }
 4630|       |
 4631|       |                        if (!start.rewind(ctx, it, end)) return;
 4632|       |                        if (value.index() != static_cast<size_t>(type_index))
 4633|       |                           emplace_runtime_variant(value, type_index);
 4634|       |                        std::visit(
 4635|       |                           [&](auto&& v) {
 4636|       |                              using V = std::decay_t<decltype(v)>;
 4637|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4638|       |                              if constexpr (variant_unit_alternative<V>) {
 4639|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4640|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4641|       |                                 // terminator handling match every other alternative.
 4642|       |                                 detail::variant_unit_body unit_body{};
 4643|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4644|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4645|       |                                                                                                 end);
 4646|       |                              }
 4647|       |                              else if constexpr (is_object) {
 4648|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4649|       |                              }
 4650|       |                              else if constexpr (is_memory_object<V>) {
 4651|       |                                 if (!v) {
 4652|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4653|       |                                       if constexpr (requires { v.emplace(); }) {
 4654|       |                                          v.emplace();
 4655|       |                                       }
 4656|       |                                       else {
 4657|       |                                          v = typename V::value_type{};
 4658|       |                                       }
 4659|       |                                    }
 4660|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4661|       |                                       v = std::make_unique<typename V::element_type>();
 4662|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4663|       |                                       v = std::make_shared<typename V::element_type>();
 4664|       |                                    else if constexpr (constructible<V>) {
 4665|       |                                       v = meta_construct_v<V>();
 4666|       |                                    }
 4667|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4668|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4669|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4670|       |                                          return;
 4671|       |                                       }
 4672|       |                                    }
 4673|       |                                    else {
 4674|       |                                       ctx.error = error_code::invalid_nullable_read;
 4675|       |                                       return;
 4676|       |                                    }
 4677|       |                                 }
 4678|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4679|       |                                                                                                               it, end);
 4680|       |                              }
 4681|       |                              else if constexpr (custom_read<V>) {
 4682|       |                                 // Custom handlers parse the remaining body themselves.
 4683|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4684|       |                              }
 4685|       |                           },
 4686|       |                           value);
 4687|       |                     }
 4688|       |                     else if (final_matching > 1) {
 4689|       |                        constexpr auto N = std::variant_size_v<T>;
 4690|       |
 4691|       |                        // Compile-time array of field counts for each variant type
 4692|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4693|       |                           return std::array<size_t, N> {
 4694|       |                              ([]<size_t J = I>() -> size_t {
 4695|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4696|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4697|       |                                    return reflect<V>::size;
 4698|       |                                 }
 4699|       |                                 else if constexpr (is_memory_object<V>) {
 4700|       |                                    using X = memory_type<V>;
 4701|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4702|       |                                       return reflect<X>::size;
 4703|       |                                    }
 4704|       |                                    else {
 4705|       |                                       return (std::numeric_limits<size_t>::max)();
 4706|       |                                    }
 4707|       |                                 }
 4708|       |                                 else {
 4709|       |                                    return (std::numeric_limits<size_t>::max)();
 4710|       |                                 }
 4711|       |                              }.template operator()<I>())...
 4712|       |                           };
 4713|       |                        }(std::make_index_sequence<N>{});
 4714|       |
 4715|       |                        // Find the type with minimum field count among the possible types
 4716|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4717|       |                        size_t chosen_index = N; // Invalid index initially
 4718|       |
 4719|       |                        for (size_t i = 0; i < N; ++i) {
 4720|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4721|       |                              min_fields = field_counts[i];
 4722|       |                              chosen_index = i;
 4723|       |                           }
 4724|       |                        }
 4725|       |
 4726|       |                        if (chosen_index < N) {
 4727|       |                           // Validate against tag if one was specified
 4728|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4729|       |                              ctx.error = error_code::no_matching_variant_type;
 4730|       |                              return;
 4731|       |                           }
 4732|       |
 4733|       |                           if (!start.rewind(ctx, it, end)) return;
 4734|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4735|       |                           std::visit(
 4736|       |                              [&](auto&& v) {
 4737|       |                                 using V = std::decay_t<decltype(v)>;
 4738|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4739|       |                                 if constexpr (variant_unit_alternative<V>) {
 4740|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4741|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4742|       |                                    // terminator handling match every other alternative.
 4743|       |                                    detail::variant_unit_body unit_body{};
 4744|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4745|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4746|       |                                                                                                    end);
 4747|       |                                 }
 4748|       |                                 else if constexpr (is_object) {
 4749|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4750|       |                                 }
 4751|       |                                 else if constexpr (is_memory_object<V>) {
 4752|       |                                    if (!v) {
 4753|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4754|       |                                          if constexpr (requires { v.emplace(); }) {
 4755|       |                                             v.emplace();
 4756|       |                                          }
 4757|       |                                          else {
 4758|       |                                             v = typename V::value_type{};
 4759|       |                                          }
 4760|       |                                       }
 4761|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4762|       |                                          v = std::make_unique<typename V::element_type>();
 4763|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4764|       |                                          v = std::make_shared<typename V::element_type>();
 4765|       |                                       else if constexpr (constructible<V>) {
 4766|       |                                          v = meta_construct_v<V>();
 4767|       |                                       }
 4768|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4769|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4770|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4771|       |                                             return;
 4772|       |                                          }
 4773|       |                                       }
 4774|       |                                       else {
 4775|       |                                          ctx.error = error_code::invalid_nullable_read;
 4776|       |                                          return;
 4777|       |                                       }
 4778|       |                                    }
 4779|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4780|       |                                       *v, ctx, it, end);
 4781|       |                                 }
 4782|       |                                 else if constexpr (custom_read<V>) {
 4783|       |                                    // Custom handlers parse the remaining body themselves.
 4784|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4785|       |                                 }
 4786|       |                              },
 4787|       |                              value);
 4788|       |                        }
 4789|       |                        else {
 4790|       |                           ctx.error = error_code::no_matching_variant_type;
 4791|       |                        }
 4792|       |                     }
 4793|       |                  }
 4794|       |                  else {
 4795|       |                     // For variants with 0 or 1 object types, use the original error handling
 4796|       |                     ctx.error = error_code::no_matching_variant_type;
 4797|       |                  }
 4798|       |               }
 4799|      0|               break;
 4800|  5.03k|            }
 4801|  2.14k|            case '[':
  ------------------
  |  Branch (4801:13): [True: 2.14k, False: 8.93k]
  ------------------
 4802|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4803|  2.14k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4804|  2.14k|               break;
 4805|  1.11k|            case '"': {
  ------------------
  |  Branch (4805:13): [True: 1.11k, False: 9.95k]
  ------------------
 4806|  1.11k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4807|  1.11k|               break;
 4808|  5.03k|            }
 4809|     82|            case 't':
  ------------------
  |  Branch (4809:13): [True: 82, False: 10.9k]
  ------------------
 4810|    188|            case 'f': {
  ------------------
  |  Branch (4810:13): [True: 106, False: 10.9k]
  ------------------
 4811|    188|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4812|    188|               break;
 4813|     82|            }
 4814|     72|            case 'n':
  ------------------
  |  Branch (4814:13): [True: 72, False: 11.0k]
  ------------------
 4815|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4816|       |                  ctx.error = error_code::no_matching_variant_type;
 4817|       |               }
 4818|     72|               else {
 4819|     72|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4820|     72|                  using V = std::variant_alternative_t<first_idx, T>;
 4821|     72|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4821:23): [True: 0, False: 72]
  ------------------
 4822|     72|                  match<"null", Opts>(ctx, it, end);
 4823|     72|               }
 4824|     72|               break;
 4825|  2.50k|            default: {
  ------------------
  |  Branch (4825:13): [True: 2.50k, False: 8.57k]
  ------------------
 4826|       |               // Not bool, string, object, or array so must be number or null
 4827|  2.50k|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4828|  2.50k|            }
 4829|  11.0k|            }
 4830|       |         }
 4831|       |         else {
 4832|       |            // For non-auto-deducible variants, try each type until one succeeds
 4833|       |            constexpr auto N = std::variant_size_v<T>;
 4834|       |            bool parsed = false;
 4835|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4836|       |
 4837|       |            for_each<N>([&]<size_t I>() {
 4838|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4839|       |
 4840|       |               auto copy_it = it;
 4841|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4842|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4843|       |               const auto copy_depth = ctx.depth;
 4844|       |
 4845|       |               // Try parsing as this type
 4846|       |               if (value.index() != I) {
 4847|       |                  emplace_runtime_variant(value, I);
 4848|       |               }
 4849|       |
 4850|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4851|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4852|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4853|       |               }
 4854|       |
 4855|       |               if (!bool(ctx.error)) {
 4856|       |                  parsed = true;
 4857|       |               }
 4858|       |               else if constexpr (not Options.null_terminated) {
 4859|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4860|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4861|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4862|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4863|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4864|       |                     parsed = true;
 4865|       |                     ctx.error = error_code::none;
 4866|       |                  }
 4867|       |                  else {
 4868|       |                     // Reset for next attempt (unless this is the last type)
 4869|       |                     it = copy_it;
 4870|       |                     rewind_depth<Options>(ctx, copy_depth);
 4871|       |                     if constexpr (I + 1 < N) {
 4872|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4873|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4874|       |                        }
 4875|       |                     }
 4876|       |                  }
 4877|       |               }
 4878|       |               else {
 4879|       |                  // Reset for next attempt (unless this is the last type)
 4880|       |                  it = copy_it;
 4881|       |                  rewind_depth<Options>(ctx, copy_depth);
 4882|       |                  if constexpr (I + 1 < N) {
 4883|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4884|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4885|       |                     }
 4886|       |                  }
 4887|       |               }
 4888|       |            });
 4889|       |         }
 4890|  11.0k|      }
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEERNS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES4_EEEETkNS_10is_contextERNS_7contextERPKcSD_EEvOT0_OT1_OT2_T3_:
   49|  25.2k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  25.2k|         else {
   60|  25.2k|            using V = std::remove_cvref_t<T>;
   61|  25.2k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  25.2k|                                             end);
   63|  25.2k|         }
   64|  25.2k|      }
_ZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_:
 3044|  25.2k|      {
 3045|  25.2k|         static constexpr auto num_members = reflect<T>::size;
 3046|       |
 3047|  25.2k|         static constexpr auto Opts = opening_handled_off<ws_handled_off<Options>()>();
 3048|       |         if constexpr (!check_opening_handled(Options)) {
 3049|       |            if constexpr (!check_ws_handled(Options)) {
 3050|       |               if (skip_ws<Opts>(ctx, it, end)) {
 3051|       |                  return;
 3052|       |               }
 3053|       |            }
 3054|       |            if (match_invalid_end<'{', Opts>(ctx, it, end)) {
 3055|       |               return;
 3056|       |            }
 3057|       |            if constexpr (not Opts.null_terminated) {
 3058|       |               if (it == end) [[unlikely]] {
 3059|       |                  ctx.error = error_code::unexpected_end;
 3060|       |                  return;
 3061|       |               }
 3062|       |            }
 3063|       |            // one nesting level (see enter_depth): counted in both modes so the limit binds,
 3064|       |            // released at each syntactic close below
 3065|       |            if (enter_depth(ctx)) [[unlikely]] {
 3066|       |               return;
 3067|       |            }
 3068|       |         }
 3069|  25.2k|         const auto ws_start = it;
 3070|  25.2k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3070:14): [True: 22, False: 25.2k]
  ------------------
 3071|     22|            return;
 3072|     22|         }
 3073|  25.2k|         const size_t ws_size = size_t(it - ws_start);
 3074|       |
 3075|       |         if constexpr ((glaze_object_t<T> || reflectable<T>) && num_members == 0 && Opts.error_on_unknown_keys) {
 3076|       |            if constexpr (not tag.sv().empty()) {
 3077|       |               if (*it == '"') {
 3078|       |                  ++it;
 3079|       |                  if constexpr (not Opts.null_terminated) {
 3080|       |                     if (it == end) [[unlikely]] {
 3081|       |                        ctx.error = error_code::unexpected_end;
 3082|       |                        return;
 3083|       |                     }
 3084|       |                  }
 3085|       |
 3086|       |                  const auto start = it;
 3087|       |                  skip_string_view(ctx, it, end);
 3088|       |                  if (bool(ctx.error)) [[unlikely]]
 3089|       |                     return;
 3090|       |                  if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3091|       |                     return;
 3092|       |                  const sv key{start, size_t(it - start)};
 3093|       |                  ++it;
 3094|       |                  if constexpr (not Opts.null_terminated) {
 3095|       |                     if (it == end) [[unlikely]] {
 3096|       |                        ctx.error = error_code::unexpected_end;
 3097|       |                        return;
 3098|       |                     }
 3099|       |                  }
 3100|       |
 3101|       |                  if (key == tag.sv()) {
 3102|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3103|       |                        return;
 3104|       |                     }
 3105|       |
 3106|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3107|       |                     if (bool(ctx.error)) [[unlikely]]
 3108|       |                        return;
 3109|       |
 3110|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3111|       |                        return;
 3112|       |                     }
 3113|       |                  }
 3114|       |                  else {
 3115|       |                     ctx.error = error_code::unknown_key;
 3116|       |                     return;
 3117|       |                  }
 3118|       |               }
 3119|       |            }
 3120|       |
 3121|       |            if (*it == '}') [[likely]] {
 3122|       |               --ctx.depth;
 3123|       |               if constexpr (glaze_object_t<T> || reflectable<T>) {
 3124|       |                  if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 3125|       |                     auto wrapper = self_constraint_v<T>(value);
 3126|       |                     from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 3127|       |                     if (bool(ctx.error)) {
 3128|       |                        return;
 3129|       |                     }
 3130|       |                  }
 3131|       |               }
 3132|       |               ++it;
 3133|       |               if constexpr (not Opts.null_terminated) {
 3134|       |                  if (it == end) {
 3135|       |                     ctx.error = error_code::end_reached;
 3136|       |                     return;
 3137|       |                  }
 3138|       |               }
 3139|       |               if constexpr (Opts.partial_read) {
 3140|       |                  ctx.error = error_code::partial_read_complete;
 3141|       |               }
 3142|       |               return;
 3143|       |            }
 3144|       |            ctx.error = error_code::unknown_key;
 3145|       |            return;
 3146|       |         }
 3147|  25.2k|         else {
 3148|  25.2k|            decltype(auto) fields = [&]() -> decltype(auto) {
 3149|  25.2k|               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 3150|  25.2k|                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 3151|  25.2k|                  return bit_array<num_members>{};
 3152|  25.2k|               }
 3153|  25.2k|               else {
 3154|  25.2k|                  return nullptr;
 3155|  25.2k|               }
 3156|  25.2k|            }();
 3157|       |
 3158|  25.2k|            size_t read_count{}; // for partial_read
 3159|       |
 3160|  25.2k|            bool first = true;
 3161|   895k|            while (true) {
  ------------------
  |  Branch (3161:20): [True: 873k, Folded]
  ------------------
 3162|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.partial_read) {
 3163|       |                  static constexpr bit_array<num_members> all_fields = [] {
 3164|       |                     bit_array<num_members> arr{};
 3165|       |                     for (size_t i = 0; i < num_members; ++i) {
 3166|       |                        arr[i] = true;
 3167|       |                     }
 3168|       |                     return arr;
 3169|       |                  }();
 3170|       |
 3171|       |                  if ((all_fields & fields) == all_fields) {
 3172|       |                     ctx.error = error_code::partial_read_complete;
 3173|       |                     --ctx.depth; // as above: an early success still closes this level
 3174|       |                     return;
 3175|       |                  }
 3176|       |               }
 3177|       |
 3178|       |               // Streaming refill point: at start of each iteration, ensure buffer has data
 3179|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 3180|       |                  if (ctx.stream.enabled()) {
 3181|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 3182|       |                     const size_t remaining = ctx.stream.size() - consumed;
 3183|       |                     // Refill when less than half of buffer remains to ensure space for next key-value pair
 3184|       |                     if (remaining <= ctx.stream.size() / 2 || it >= end) {
 3185|       |                        const char* new_it;
 3186|       |                        const char* new_end;
 3187|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 3188|       |                        it = new_it;
 3189|       |                        end = new_end;
 3190|       |                        if (it >= end && ctx.stream.at_eof()) {
 3191|       |                           ctx.error = error_code::unexpected_end;
 3192|       |                           return;
 3193|       |                        }
 3194|       |                     }
 3195|       |                  }
 3196|       |               }
 3197|       |
 3198|   873k|               if (*it == '}') {
  ------------------
  |  Branch (3198:20): [True: 2.10k, False: 871k]
  ------------------
 3199|  2.10k|                  --ctx.depth;
 3200|       |                  if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.error_on_missing_keys) {
 3201|       |                     constexpr auto req_fields = required_fields<T, Opts>();
 3202|       |                     if ((req_fields & fields) != req_fields) {
 3203|       |                        for (size_t i = 0; i < num_members; ++i) {
 3204|       |                           if (not fields[i] && req_fields[i]) {
 3205|       |                              ctx.custom_error_message = reflect<T>::keys[i];
 3206|       |                              // We just return the first missing key in order to avoid heap allocations
 3207|       |                              break;
 3208|       |                           }
 3209|       |                        }
 3210|       |
 3211|       |                        ctx.error = error_code::missing_key;
 3212|       |                        return;
 3213|       |                     }
 3214|       |                  }
 3215|       |                  if constexpr (glaze_object_t<T> || reflectable<T>) {
 3216|       |                     if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 3217|       |                        auto wrapper = self_constraint_v<T>(value);
 3218|       |                        from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 3219|       |                        if (bool(ctx.error)) {
 3220|       |                           return;
 3221|       |                        }
 3222|       |                     }
 3223|       |                  }
 3224|  2.10k|                  ++it; // Increment after checking for missing keys so errors are within buffer bounds
 3225|  2.10k|                  if constexpr (not Opts.null_terminated) {
 3226|  2.10k|                     if (it == end) {
  ------------------
  |  Branch (3226:26): [True: 12, False: 2.09k]
  ------------------
 3227|     12|                        ctx.error = error_code::end_reached;
 3228|     12|                        return;
 3229|     12|                     }
 3230|  2.10k|                  }
 3231|  2.09k|                  return;
 3232|  2.10k|               }
 3233|   871k|               else if (first) {
  ------------------
  |  Branch (3233:25): [True: 23.4k, False: 847k]
  ------------------
 3234|  23.4k|                  first = false;
 3235|  23.4k|               }
 3236|   847k|               else {
 3237|   847k|                  if (match_invalid_end<',', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3237:23): [True: 396, False: 847k]
  ------------------
 3238|    396|                     return;
 3239|    396|                  }
 3240|   847k|                  if constexpr (not Opts.null_terminated) {
 3241|   847k|                     if (it == end) [[unlikely]] {
  ------------------
  |  Branch (3241:26): [True: 0, False: 847k]
  ------------------
 3242|      0|                        ctx.error = error_code::unexpected_end;
 3243|      0|                        return;
 3244|      0|                     }
 3245|   847k|                  }
 3246|       |
 3247|       |                  if constexpr ((not Opts.minified) && (num_members > 1 || not Opts.error_on_unknown_keys) &&
 3248|       |                                (!Opts.comments)) {
 3249|       |                     if (ws_size && ws_size < size_t(end - it)) {
 3250|       |                        skip_matching_ws(ws_start, it, ws_size);
 3251|       |                     }
 3252|       |                  }
 3253|       |
 3254|   847k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3254:23): [True: 20, False: 847k]
  ------------------
 3255|     20|                     return;
 3256|     20|                  }
 3257|   847k|               }
 3258|       |
 3259|   870k|               constexpr auto reflection_type = glaze_object_t<T> || reflectable<T>;
  ------------------
  |  Branch (3259:49): [Folded, False: 0]
  |  Branch (3259:70): [Folded, False: 0]
  ------------------
 3260|       |
 3261|       |               if constexpr (reflection_type && (num_members == 0)) {
 3262|       |                  if constexpr (Opts.error_on_unknown_keys) {
 3263|       |                     static_assert(false_v<T>, "This should be unreachable");
 3264|       |                  }
 3265|       |                  else {
 3266|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 3267|       |                        return;
 3268|       |                     }
 3269|       |
 3270|       |                     // parsing to an empty object, but at this point the JSON presents keys
 3271|       |
 3272|       |                     // Unknown key handler does not unescape keys. Unknown escaped keys are
 3273|       |                     // handled by the user.
 3274|       |
 3275|       |                     const auto start = it;
 3276|       |                     skip_string_view(ctx, it, end);
 3277|       |                     if (bool(ctx.error)) [[unlikely]]
 3278|       |                        return;
 3279|       |                     if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3280|       |                        return;
 3281|       |                     const sv key{start, size_t(it - start)};
 3282|       |                     ++it;
 3283|       |                     if constexpr (not Opts.null_terminated) {
 3284|       |                        if (it == end) [[unlikely]] {
 3285|       |                           ctx.error = error_code::unexpected_end;
 3286|       |                           return;
 3287|       |                        }
 3288|       |                     }
 3289|       |
 3290|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3291|       |                        return;
 3292|       |                     }
 3293|       |
 3294|       |                     // Check if this key is the variant tag that should be skipped
 3295|       |                     if constexpr (not tag.sv().empty()) {
 3296|       |                        if (key == tag.sv()) {
 3297|       |                           // Skip the tag value
 3298|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3299|       |                           if (bool(ctx.error)) [[unlikely]]
 3300|       |                              return;
 3301|       |                           resync_window_end(ctx, end); // a streaming skip refills
 3302|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 3303|       |                              return;
 3304|       |                           }
 3305|       |                           continue;
 3306|       |                        }
 3307|       |                     }
 3308|       |
 3309|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3310|       |                     if (bool(ctx.error)) [[unlikely]]
 3311|       |                        return;
 3312|       |                     if constexpr (not Opts.null_terminated) {
 3313|       |                        if (it == end) [[unlikely]] {
 3314|       |                           ctx.error = error_code::unexpected_end;
 3315|       |                           return;
 3316|       |                        }
 3317|       |                     }
 3318|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3319|       |                        return;
 3320|       |                     }
 3321|       |                  }
 3322|       |               }
 3323|       |               else if constexpr (reflection_type) {
 3324|       |                  static_assert(bool(hash_info<T>.type));
 3325|       |
 3326|       |                  if (*it != '"') [[unlikely]] {
 3327|       |                     ctx.error = error_code::expected_quote;
 3328|       |                     return;
 3329|       |                  }
 3330|       |                  ++it;
 3331|       |                  if constexpr (not Opts.null_terminated) {
 3332|       |                     if (it == end) [[unlikely]] {
 3333|       |                        ctx.error = error_code::unexpected_end;
 3334|       |                        return;
 3335|       |                     }
 3336|       |                  }
 3337|       |
 3338|       |                  if constexpr (not tag.sv().empty() && not contains_tag<T, tag>()) {
 3339|       |                     // For tagged variants we first check to see if the key matches the tag
 3340|       |                     // We only need to do this if the tag is not part of the keys
 3341|       |
 3342|       |                     const auto start = it;
 3343|       |                     skip_string_view(ctx, it, end);
 3344|       |                     if (bool(ctx.error)) [[unlikely]]
 3345|       |                        return;
 3346|       |                     if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3347|       |                        return;
 3348|       |                     const sv key{start, size_t(it - start)};
 3349|       |                     ++it;
 3350|       |                     if constexpr (not Opts.null_terminated) {
 3351|       |                        if (it == end) [[unlikely]] {
 3352|       |                           ctx.error = error_code::unexpected_end;
 3353|       |                           return;
 3354|       |                        }
 3355|       |                     }
 3356|       |
 3357|       |                     if (key == tag.sv()) {
 3358|       |                        if (parse_ws_colon<Opts>(ctx, it, end)) {
 3359|       |                           return;
 3360|       |                        }
 3361|       |
 3362|       |                        parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3363|       |                        if (bool(ctx.error)) [[unlikely]]
 3364|       |                           return;
 3365|       |
 3366|       |                        if (skip_ws<Opts>(ctx, it, end)) {
 3367|       |                           return;
 3368|       |                        }
 3369|       |                        continue;
 3370|       |                     }
 3371|       |                     else {
 3372|       |                        it = start; // reset the iterator
 3373|       |                     }
 3374|       |                  }
 3375|       |
 3376|       |                  if constexpr (Opts.error_on_missing_keys || Opts.partial_read) {
 3377|       |                     size_t index = num_members;
 3378|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end, index);
 3379|       |                     if (bool(ctx.error)) [[unlikely]]
 3380|       |                        return;
 3381|       |                     if (index < num_members) {
 3382|       |                        fields[index] = true;
 3383|       |                     }
 3384|       |                  }
 3385|       |                  else {
 3386|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end);
 3387|       |                     if (bool(ctx.error)) [[unlikely]]
 3388|       |                        return;
 3389|       |                  }
 3390|       |               }
 3391|   870k|               else {
 3392|       |                  // For types like std::map, std::unordered_map
 3393|       |
 3394|   870k|                  auto reading = [&](auto&& key) {
 3395|   870k|                     if constexpr (Opts.partial_read) {
 3396|   870k|                        if (auto element = value.find(key); element != value.end()) {
 3397|   870k|                           ++read_count;
 3398|   870k|                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3399|   870k|                        }
 3400|   870k|                        else {
 3401|   870k|                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3402|   870k|                        }
 3403|   870k|                     }
 3404|   870k|                     else {
 3405|   870k|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3406|   870k|                     }
 3407|   870k|                  };
 3408|       |
 3409|       |                  // using Key = std::conditional_t<heterogeneous_map<T>, sv, typename T::key_type>;
 3410|   870k|                  using Key = typename T::key_type;
 3411|   870k|                  if constexpr (std::is_same_v<Key, std::string>) {
 3412|   870k|                     ctx.scratch.clear();
 3413|   870k|                     parse<JSON>::op<Opts>(ctx.scratch, ctx, it, end);
 3414|   870k|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3414:26): [True: 1.56k, False: 869k]
  ------------------
 3415|  1.56k|                        return;
 3416|       |
 3417|   869k|                     if (parse_ws_colon<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3417:26): [True: 1.61k, False: 867k]
  ------------------
 3418|  1.61k|                        return;
 3419|  1.61k|                     }
 3420|       |
 3421|   867k|                     reading(ctx.scratch);
 3422|       |                     if constexpr (Opts.partial_read) {
 3423|       |                        if (read_count == value.size()) {
 3424|       |                           return;
 3425|       |                        }
 3426|       |                     }
 3427|   867k|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3427:26): [True: 19.3k, False: 848k]
  ------------------
 3428|  19.3k|                        return;
 3429|       |                  }
 3430|       |                  else if constexpr (str_t<Key>) {
 3431|       |                     Key key;
 3432|       |                     parse<JSON>::op<Opts>(key, ctx, it, end);
 3433|       |                     if (bool(ctx.error)) [[unlikely]]
 3434|       |                        return;
 3435|       |
 3436|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3437|       |                        return;
 3438|       |                     }
 3439|       |
 3440|       |                     reading(key);
 3441|       |                     if constexpr (Opts.partial_read) {
 3442|       |                        if (read_count == value.size()) {
 3443|       |                           return;
 3444|       |                        }
 3445|       |                     }
 3446|       |                     if (bool(ctx.error)) [[unlikely]]
 3447|       |                        return;
 3448|       |                  }
 3449|       |                  else {
 3450|       |                     Key key_value{};
 3451|       |                     if constexpr (is_named_enum<Key> || mimics_str_t<Key>) {
 3452|       |                        parse<JSON>::op<Opts>(key_value, ctx, it, end);
 3453|       |                     }
 3454|       |                     else if constexpr (std::is_arithmetic_v<Key>) {
 3455|       |                        // prefer over quoted_t below to avoid double parsing of quoted_t
 3456|       |                        parse<JSON>::op<opt_true<Opts, quoted_num_opt_tag{}>>(key_value, ctx, it, end);
 3457|       |                     }
 3458|       |                     else {
 3459|       |                        parse<JSON>::op<opt_false<Opts, raw_string_opt_tag{}>>(quoted_t<Key>{key_value}, ctx, it, end);
 3460|       |                     }
 3461|       |                     if (bool(ctx.error)) [[unlikely]]
 3462|       |                        return;
 3463|       |
 3464|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3465|       |                        return;
 3466|       |                     }
 3467|       |
 3468|       |                     reading(key_value);
 3469|       |                     if constexpr (Opts.partial_read) {
 3470|       |                        if (read_count == value.size()) {
 3471|       |                           return;
 3472|       |                        }
 3473|       |                     }
 3474|       |                     if (bool(ctx.error)) [[unlikely]]
 3475|       |                        return;
 3476|       |                  }
 3477|   870k|               }
 3478|       |
 3479|       |               // Streaming refill point: after parsing each key-value pair, refill if buffer is low
 3480|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 3481|       |                  if (ctx.stream.enabled()) {
 3482|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 3483|       |                     // Refill when less than 25% of buffer remains to ensure enough space for next element
 3484|       |                     if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 3485|       |                        const char* new_it;
 3486|       |                        const char* new_end;
 3487|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 3488|       |                        it = new_it;
 3489|       |                        end = new_end;
 3490|       |                        if (it >= end && ctx.stream.at_eof()) {
 3491|       |                           ctx.error = error_code::unexpected_end;
 3492|       |                           return;
 3493|       |                        }
 3494|       |                     }
 3495|       |                  }
 3496|       |               }
 3497|       |
 3498|   870k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3498:20): [True: 163, False: 870k]
  ------------------
 3499|    163|                  return;
 3500|    163|               }
 3501|   870k|            }
 3502|  25.2k|         }
 3503|  25.2k|      }
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlvE_clEv:
 3148|  25.2k|            decltype(auto) fields = [&]() -> decltype(auto) {
 3149|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 3150|       |                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 3151|       |                  return bit_array<num_members>{};
 3152|       |               }
 3153|  25.2k|               else {
 3154|  25.2k|                  return nullptr;
 3155|  25.2k|               }
 3156|  25.2k|            }();
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|   870k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|   870k|         else {
   60|   870k|            using V = std::remove_cvref_t<T>;
   61|   870k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|   870k|                                             end);
   63|   870k|         }
   64|   870k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEQntcl15check_is_paddedTL0__EEEvRT2_OT3_OT0_T1_:
 1043|   870k|      {
 1044|       |         if constexpr (check_string_as_number(Opts)) {
 1045|       |            auto start = it;
 1046|       |            skip_number<Opts>(ctx, it, end);
 1047|       |            if (bool(ctx.error)) [[unlikely]] {
 1048|       |               return;
 1049|       |            }
 1050|       |            if (start == it) [[unlikely]] {
 1051|       |               ctx.error = error_code::parse_number_failure;
 1052|       |               return;
 1053|       |            }
 1054|       |            value.append(start, size_t(it - start));
 1055|       |         }
 1056|   870k|         else {
 1057|   870k|            if constexpr (!check_opening_handled(Opts)) {
 1058|   870k|               if constexpr (!check_ws_handled(Opts)) {
 1059|   870k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (1059:23): [True: 0, False: 870k]
  ------------------
 1060|      0|                     return;
 1061|      0|                  }
 1062|   870k|               }
 1063|       |
 1064|   870k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (1064:20): [True: 293, False: 870k]
  ------------------
 1065|    293|                  return;
 1066|    293|               }
 1067|   870k|            }
 1068|       |
 1069|   870k|            if constexpr (not check_raw_string(Opts)) {
 1070|   870k|               static constexpr auto string_padding_bytes = 8;
 1071|       |
 1072|   870k|               if (size_t(end - it) >= 8) {
  ------------------
  |  Branch (1072:20): [True: 868k, False: 2.74k]
  ------------------
 1073|   868k|                  auto start = it;
 1074|   868k|                  uint64_t ascii_acc{};
 1075|   868k|                  const auto end8 = end - 8;
 1076|  4.47M|                  while (true) {
  ------------------
  |  Branch (1076:26): [True: 4.47M, Folded]
  ------------------
 1077|  4.47M|                     if (it >= end8) [[unlikely]] {
  ------------------
  |  Branch (1077:26): [True: 1.05k, False: 4.47M]
  ------------------
 1078|  1.05k|                        break;
 1079|  1.05k|                     }
 1080|       |
 1081|  4.47M|                     uint64_t chunk;
 1082|  4.47M|                     std::memcpy(&chunk, it, 8);
 1083|       |                     if constexpr (std::endian::native == std::endian::big) {
 1084|       |                        chunk = std::byteswap(chunk);
 1085|       |                     }
 1086|  4.47M|                     ascii_acc |= chunk;
 1087|  4.47M|                     const uint64_t test_chars = has_quote(chunk);
 1088|  4.47M|                     if (test_chars) {
  ------------------
  |  Branch (1088:26): [True: 868k, False: 3.60M]
  ------------------
 1089|   868k|                        it += (countr_zero(test_chars) >> 3);
 1090|       |
 1091|   868k|                        auto* prev = it - 1;
 1092|   869k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1092:32): [True: 1.82k, False: 868k]
  ------------------
 1093|  1.82k|                           --prev;
 1094|  1.82k|                        }
 1095|   868k|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1095:29): [True: 866k, False: 1.13k]
  ------------------
 1096|   866k|                           goto continue_decode;
 1097|   866k|                        }
 1098|  1.13k|                        ++it; // skip the escaped quote
 1099|  1.13k|                     }
 1100|  3.60M|                     else {
 1101|  3.60M|                        it += 8;
 1102|  3.60M|                     }
 1103|  4.47M|                  }
 1104|       |
 1105|  3.15k|                  while (it[-1] == '\\') [[unlikely]] {
  ------------------
  |  Branch (1105:26): [True: 2.09k, False: 1.05k]
  ------------------
 1106|       |                     // if we ended on an escape character then we need to rewind
 1107|       |                     // because we lost our context
 1108|  2.09k|                     --it;
 1109|  2.09k|                  }
 1110|       |
 1111|       |                  // The byte-wise tail keeps feeding the accumulator: it has to cover every byte of
 1112|       |                  // the string, or a non-ASCII byte reached here would be waved through unvalidated.
 1113|  5.85k|                  for (; it < end; ++it) {
  ------------------
  |  Branch (1113:26): [True: 5.68k, False: 170]
  ------------------
 1114|  5.68k|                     ascii_acc |= uint8_t(*it);
 1115|  5.68k|                     if (*it == '"') {
  ------------------
  |  Branch (1115:26): [True: 954, False: 4.72k]
  ------------------
 1116|    954|                        auto* prev = it - 1;
 1117|  2.00k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1117:32): [True: 1.05k, False: 954]
  ------------------
 1118|  1.05k|                           --prev;
 1119|  1.05k|                        }
 1120|    954|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1120:29): [True: 887, False: 67]
  ------------------
 1121|    887|                           goto continue_decode;
 1122|    887|                        }
 1123|    954|                     }
 1124|  5.68k|                  }
 1125|       |
 1126|    170|                  ctx.error = error_code::unexpected_end;
 1127|    170|                  return;
 1128|       |
 1129|   867k|               continue_decode:
 1130|       |
 1131|   867k|                  if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (1131:23): [True: 151, False: 867k]
  ------------------
 1132|    151|                     return;
 1133|    151|                  }
 1134|       |
 1135|   867k|                  const auto available_padding = size_t(end - it);
 1136|   867k|                  auto n = size_t(it - start);
 1137|   867k|                  if (available_padding >= 8) [[likely]] {
  ------------------
  |  Branch (1137:23): [True: 866k, False: 1.18k]
  ------------------
 1138|   866k|                     value.resize(n + string_padding_bytes);
 1139|       |
 1140|   866k|                     auto* p = value.data();
 1141|       |
 1142|  4.90M|                     while (true) {
  ------------------
  |  Branch (1142:29): [True: 4.90M, Folded]
  ------------------
 1143|  4.90M|                        if (start >= it) {
  ------------------
  |  Branch (1143:29): [True: 865k, False: 4.04M]
  ------------------
 1144|   865k|                           break;
 1145|   865k|                        }
 1146|       |
 1147|  4.04M|                        std::memcpy(p, start, 8);
 1148|  4.04M|                        uint64_t swar;
 1149|  4.04M|                        std::memcpy(&swar, p, 8);
 1150|       |                        if constexpr (std::endian::native == std::endian::big) {
 1151|       |                           swar = std::byteswap(swar);
 1152|       |                        }
 1153|       |
 1154|  4.04M|                        constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1155|  4.04M|                        const uint64_t lo7 = swar & lo7_mask;
 1156|  4.04M|                        const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1157|  4.04M|                        const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1158|  4.04M|                        uint64_t next = ~((backslash & less_32) | swar);
 1159|       |
 1160|  4.04M|                        next &= repeat_byte8(0b10000000);
 1161|  4.04M|                        if (next == 0) {
  ------------------
  |  Branch (1161:29): [True: 4.03M, False: 12.3k]
  ------------------
 1162|  4.03M|                           start += 8;
 1163|  4.03M|                           p += 8;
 1164|  4.03M|                           continue;
 1165|  4.03M|                        }
 1166|       |
 1167|  12.3k|                        next = countr_zero(next) >> 3;
 1168|  12.3k|                        start += next;
 1169|  12.3k|                        if (start >= it) {
  ------------------
  |  Branch (1169:29): [True: 1.20k, False: 11.1k]
  ------------------
 1170|  1.20k|                           break;
 1171|  1.20k|                        }
 1172|       |
 1173|  11.1k|                        if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1173:29): [True: 38, False: 11.0k]
  ------------------
 1174|     38|                           ctx.error = error_code::syntax_error;
 1175|     38|                           return;
 1176|     38|                        }
 1177|  11.0k|                        ++start; // skip the escape
 1178|  11.0k|                        if (*start == 'u') {
  ------------------
  |  Branch (1178:29): [True: 10.1k, False: 971]
  ------------------
 1179|  10.1k|                           ++start;
 1180|  10.1k|                           p += next;
 1181|  10.1k|                           const auto mark = start;
 1182|  10.1k|                           const auto offset = handle_unicode_code_point(start, p, end);
 1183|  10.1k|                           if (offset == 0) [[unlikely]] {
  ------------------
  |  Branch (1183:32): [True: 26, False: 10.0k]
  ------------------
 1184|     26|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1185|     26|                              return;
 1186|     26|                           }
 1187|  10.0k|                           n += offset;
 1188|       |                           // escape + u + unicode code points
 1189|  10.0k|                           n -= 2 + uint32_t(start - mark);
 1190|  10.0k|                        }
 1191|    971|                        else {
 1192|    971|                           p += next;
 1193|    971|                           *p = char_unescape_table[uint8_t(*start)];
 1194|    971|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1194:32): [True: 11, False: 960]
  ------------------
 1195|     11|                              ctx.error = error_code::invalid_escape;
 1196|     11|                              return;
 1197|     11|                           }
 1198|    960|                           ++p;
 1199|    960|                           ++start;
 1200|    960|                           --n;
 1201|    960|                        }
 1202|  11.0k|                     }
 1203|       |
 1204|   866k|                     value.resize(n);
 1205|   866k|                     ++it;
 1206|   866k|                  }
 1207|  1.18k|                  else {
 1208|       |                     // For large inputs this case of running out of buffer is very rare
 1209|  1.18k|                     value.resize(n);
 1210|  1.18k|                     auto* p = value.data();
 1211|       |
 1212|  1.18k|                     it = start;
 1213|  52.9k|                     while (it < end) [[likely]] {
  ------------------
  |  Branch (1213:29): [True: 52.9k, False: 0]
  ------------------
 1214|  52.9k|                        if (*it == '"') {
  ------------------
  |  Branch (1214:29): [True: 1.03k, False: 51.8k]
  ------------------
 1215|  1.03k|                           value.resize(size_t(p - value.data()));
 1216|  1.03k|                           ++it;
 1217|  1.03k|                           return;
 1218|  1.03k|                        }
 1219|       |
 1220|  51.8k|                        if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1220:29): [True: 41, False: 51.8k]
  ------------------
 1221|     41|                           ctx.error = error_code::syntax_error;
 1222|     41|                           return;
 1223|     41|                        }
 1224|       |
 1225|  51.8k|                        *p = *it;
 1226|       |
 1227|  51.8k|                        if (*it == '\\') {
  ------------------
  |  Branch (1227:29): [True: 2.53k, False: 49.3k]
  ------------------
 1228|  2.53k|                           ++it; // skip the escape
 1229|  2.53k|                           if (*it == 'u') {
  ------------------
  |  Branch (1229:32): [True: 1.22k, False: 1.30k]
  ------------------
 1230|  1.22k|                              ++it;
 1231|  1.22k|                              if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1231:35): [True: 91, False: 1.13k]
  ------------------
 1232|     91|                                 ctx.error = error_code::unicode_escape_conversion_failure;
 1233|     91|                                 return;
 1234|     91|                              }
 1235|  1.22k|                           }
 1236|  1.30k|                           else {
 1237|  1.30k|                              *p = char_unescape_table[uint8_t(*it)];
 1238|  1.30k|                              if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1238:35): [True: 14, False: 1.29k]
  ------------------
 1239|     14|                                 ctx.error = error_code::invalid_escape;
 1240|     14|                                 return;
 1241|     14|                              }
 1242|  1.29k|                              ++p;
 1243|  1.29k|                              ++it;
 1244|  1.29k|                           }
 1245|  2.53k|                        }
 1246|  49.3k|                        else {
 1247|  49.3k|                           ++it;
 1248|  49.3k|                           ++p;
 1249|  49.3k|                        }
 1250|  51.8k|                     }
 1251|       |
 1252|      0|                     ctx.error = error_code::unexpected_end;
 1253|      0|                  }
 1254|   867k|               }
 1255|  2.74k|               else {
 1256|       |                  // For short strings
 1257|       |
 1258|  2.74k|                  std::array<char, 8> buffer{};
 1259|       |
 1260|  2.74k|                  auto* p = buffer.data();
 1261|  2.74k|                  const auto* const utf8_start = it;
 1262|       |
 1263|  5.90k|                  while (it < end) [[likely]] {
  ------------------
  |  Branch (1263:26): [True: 5.24k, False: 661]
  ------------------
 1264|  5.24k|                     *p = *it;
 1265|  5.24k|                     if (*it == '"') {
  ------------------
  |  Branch (1265:26): [True: 1.98k, False: 3.26k]
  ------------------
 1266|  1.98k|                        if (validate_utf8_span<Opts>(ctx, utf8_start, it)) [[unlikely]] {
  ------------------
  |  Branch (1266:29): [True: 112, False: 1.87k]
  ------------------
 1267|    112|                           return;
 1268|    112|                        }
 1269|  1.87k|                        const size_t n = size_t(p - buffer.data());
 1270|  1.87k|#if __has_cpp_attribute(assume) >= 202207L
 1271|  1.87k|                        [[assume(n <= sizeof(buffer))]];
 1272|  1.87k|#endif
 1273|  1.87k|                        value.assign(buffer.data(), n);
 1274|  1.87k|                        ++it;
 1275|  1.87k|                        if constexpr (not Opts.null_terminated) {
 1276|  1.87k|                           if (it == end) {
  ------------------
  |  Branch (1276:32): [True: 145, False: 1.72k]
  ------------------
 1277|    145|                              ctx.error = error_code::end_reached;
 1278|    145|                              return;
 1279|    145|                           }
 1280|  1.87k|                        }
 1281|  1.72k|                        return;
 1282|  1.98k|                     }
 1283|  3.26k|                     else if (*it == '\\') {
  ------------------
  |  Branch (1283:31): [True: 166, False: 3.09k]
  ------------------
 1284|    166|                        ++it; // skip the escape
 1285|    166|                        if constexpr (not Opts.null_terminated) {
 1286|    166|                           if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1286:32): [True: 3, False: 163]
  ------------------
 1287|      3|                              ctx.error = error_code::unexpected_end;
 1288|      3|                              return;
 1289|      3|                           }
 1290|    166|                        }
 1291|    166|                        if (*it == 'u') {
  ------------------
  |  Branch (1291:29): [True: 101, False: 65]
  ------------------
 1292|    101|                           ++it;
 1293|    101|                           if constexpr (not Opts.null_terminated) {
 1294|    101|                              if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1294:35): [True: 1, False: 100]
  ------------------
 1295|      1|                                 ctx.error = error_code::unexpected_end;
 1296|      1|                                 return;
 1297|      1|                              }
 1298|    101|                           }
 1299|    101|                           if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1299:32): [True: 52, False: 49]
  ------------------
 1300|     52|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1301|     52|                              return;
 1302|     52|                           }
 1303|    101|                        }
 1304|     65|                        else {
 1305|     65|                           *p = char_unescape_table[uint8_t(*it)];
 1306|     65|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1306:32): [True: 18, False: 47]
  ------------------
 1307|     18|                              ctx.error = error_code::invalid_escape;
 1308|     18|                              return;
 1309|     18|                           }
 1310|     47|                           ++p;
 1311|     47|                           ++it;
 1312|     47|                        }
 1313|    166|                     }
 1314|  3.09k|                     else if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1314:31): [True: 36, False: 3.05k]
  ------------------
 1315|     36|                        ctx.error = error_code::syntax_error;
 1316|     36|                        return;
 1317|     36|                     }
 1318|  3.05k|                     else {
 1319|  3.05k|                        ++it;
 1320|  3.05k|                        ++p;
 1321|  3.05k|                     }
 1322|  5.24k|                  }
 1323|       |
 1324|    661|                  ctx.error = error_code::unexpected_end;
 1325|    661|               }
 1326|       |            }
 1327|       |            else {
 1328|       |               // raw_string
 1329|       |               auto start = it;
 1330|       |               skip_string_view(ctx, it, end);
 1331|       |               if (bool(ctx.error)) [[unlikely]]
 1332|       |                  return;
 1333|       |
 1334|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1335|       |                  return;
 1336|       |               }
 1337|       |
 1338|       |               value.assign(start, size_t(it - start));
 1339|       |               ++it;
 1340|       |            }
 1341|   870k|         }
 1342|   870k|      }
_ZN3glz14parse_ws_colonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT0_OT1_T2_:
  159|   869k|   {
  160|   869k|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (160:11): [True: 138, False: 869k]
  ------------------
  161|    138|         return true;
  162|    138|      }
  163|   869k|      if (match_invalid_end<':', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (163:11): [True: 1.45k, False: 867k]
  ------------------
  164|  1.45k|         return true;
  165|  1.45k|      }
  166|   867k|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (166:11): [True: 21, False: 867k]
  ------------------
  167|     21|         return true;
  168|     21|      }
  169|   867k|      return false;
  170|   867k|   }
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlOT_E_clIRNSt3__112basic_stringIcNSS_11char_traitsIcEENSS_9allocatorIcEEEEEEDaSP_:
 3394|   867k|                  auto reading = [&](auto&& key) {
 3395|       |                     if constexpr (Opts.partial_read) {
 3396|       |                        if (auto element = value.find(key); element != value.end()) {
 3397|       |                           ++read_count;
 3398|       |                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3399|       |                        }
 3400|       |                        else {
 3401|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3402|       |                        }
 3403|       |                     }
 3404|   867k|                     else {
 3405|   867k|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3406|   867k|                     }
 3407|   867k|                  };
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  2.59M|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  2.59M|         else {
   60|  2.59M|            using V = std::remove_cvref_t<T>;
   61|  2.59M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  2.59M|                                             end);
   63|  2.59M|         }
   64|  2.59M|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  2.59M|      {
  151|  2.59M|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  2.59M|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  2.59M|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  2.59M|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 4065|  2.59M|      {
 4066|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 4067|       |            read_adjacent<Options>(value, ctx, it, end);
 4068|       |         }
 4069|  2.59M|         else {
 4070|  2.59M|            read_deduced<Options>(value, ctx, it, end);
 4071|  2.59M|         }
 4072|  2.59M|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE12read_deducedITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 4076|  2.59M|      {
 4077|  2.59M|         constexpr auto Opts = ws_handled_off<Options>();
 4078|  2.59M|         if constexpr (variant_is_auto_deducible<T>()) {
 4079|       |            if constexpr (not check_ws_handled(Options)) {
 4080|       |               if (skip_ws<Opts>(ctx, it, end)) {
 4081|       |                  return;
 4082|       |               }
 4083|       |            }
 4084|       |
 4085|  2.59M|            switch (*it) {
 4086|     87|            case '\0':
  ------------------
  |  Branch (4086:13): [True: 87, False: 2.59M]
  ------------------
 4087|     87|               ctx.error = error_code::unexpected_end;
 4088|     87|               return;
 4089|  20.2k|            case '{': {
  ------------------
  |  Branch (4089:13): [True: 20.2k, False: 2.57M]
  ------------------
 4090|       |               // This branch consumes the brace itself and hands the object to a reader with
 4091|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 4092|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 4093|       |               // the reader below.
 4094|  20.2k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (4094:20): [True: 9, False: 20.2k]
  ------------------
 4095|      9|                  return;
 4096|      9|               }
 4097|       |
 4098|  20.2k|               ++it;
 4099|  20.2k|               if constexpr (not Opts.null_terminated) {
 4100|  20.2k|                  if (it == end) [[unlikely]] {
  ------------------
  |  Branch (4100:23): [True: 46, False: 20.2k]
  ------------------
 4101|     46|                     ctx.error = error_code::unexpected_end;
 4102|     46|                     return;
 4103|     46|                  }
 4104|  20.2k|               }
 4105|  20.2k|               using type_counts = variant_type_count<T>;
 4106|  20.2k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 4107|       |               if constexpr (n_object_candidates < 1) {
 4108|       |                  ctx.error = error_code::no_matching_variant_type;
 4109|       |                  return;
 4110|       |               }
 4111|  20.2k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 4112|  20.2k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 4113|  20.2k|                  using V = std::variant_alternative_t<first_idx, T>;
 4114|  20.2k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4114:23): [True: 19.8k, False: 448]
  ------------------
 4115|  20.2k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 4116|  20.2k|                  return;
 4117|       |               }
 4118|       |               else {
 4119|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 4120|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 4121|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 4122|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 4123|       |
 4124|       |                  // Track if we've encountered a tag and what value it had
 4125|       |                  std::optional<size_t> tag_specified_index{};
 4126|       |
 4127|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 4128|       |                     return;
 4129|       |                  }
 4130|       |                  // Once the reader knows which alternative this object holds it may have to read
 4131|       |                  // it again from here. Anchor the position rather than keep the pointer: the scan
 4132|       |                  // below skips values, and a streaming skip refills, which moves the window out
 4133|       |                  // from under a raw pointer (see rewind_anchor).
 4134|       |                  auto start = make_rewind_anchor(ctx, it);
 4135|       |                  bool first_key = true;
 4136|       |                  // Parse bifurcation for tagged variants:
 4137|       |                  //
 4138|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 4139|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 4140|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 4141|       |                  //
 4142|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 4143|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 4144|       |                  // it advances past the trailing comma so the object parser picks up at the
 4145|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 4146|       |                  //
 4147|       |                  // One exception: if the tag name is also a field on the resolved struct
 4148|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 4149|       |                  // the struct field. This override is applied inside each std::visit lambda.
 4150|       |                  //
 4151|       |                  // Either way the rewind can fail under a streaming read: the window only holds so
 4152|       |                  // much, and an object wider than it has no start left to return to.
 4153|       |                  auto position_after_tag = [&] {
 4154|       |                     if (first_key) {
 4155|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 4156|       |                        return true;
 4157|       |                     }
 4158|       |                     return start.rewind(ctx, it, end); // tag came later, re-parse from the beginning
 4159|       |                  };
 4160|       |                  // `first_key` also answers "were we reset to the object start", which is what
 4161|       |                  // position_after_tag does for every key but the first.
 4162|       |                  for (; *it != '}'; first_key = false) {
 4163|       |                     if (!first_key) {
 4164|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 4165|       |                           return;
 4166|       |                        }
 4167|       |                     }
 4168|       |
 4169|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4170|       |                        return;
 4171|       |                     }
 4172|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4173|       |                        return;
 4174|       |                     }
 4175|       |
 4176|       |                     auto* key_start = it;
 4177|       |                     skip_string_view(ctx, it, end);
 4178|       |                     if (bool(ctx.error)) [[unlikely]]
 4179|       |                        return;
 4180|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 4181|       |                        return;
 4182|       |                     const sv key = {key_start, size_t(it - key_start)};
 4183|       |
 4184|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4185|       |                        return;
 4186|       |                     }
 4187|       |
 4188|       |                     if constexpr (deduction_key_count > 0) {
 4189|       |                        // We first check if a tag is defined and see if the key matches the tag
 4190|       |                        if constexpr (not tag_v<T>.empty()) {
 4191|       |                           if (key == tag_v<T>) {
 4192|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 4193|       |                                 return;
 4194|       |                              }
 4195|       |
 4196|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 4197|       |
 4198|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 4199|       |                              if constexpr (std::integral<id_type>) {
 4200|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4201|       |                              }
 4202|       |                              else {
 4203|       |                                 // The id is turned into an index below and never leaves this
 4204|       |                                 // reader, so the view of the window it borrows cannot outlive it.
 4205|       |                                 parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4206|       |                              }
 4207|       |                              if (bool(ctx.error)) [[unlikely]]
 4208|       |                                 return;
 4209|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4210|       |                                 return;
 4211|       |                              }
 4212|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4213|       |                                 ctx.error = error_code::syntax_error;
 4214|       |                                 return;
 4215|       |                              }
 4216|       |
 4217|       |                              size_t type_index;
 4218|       |                              if constexpr (std::integral<id_type>) {
 4219|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4220|       |                              }
 4221|       |                              else {
 4222|       |                                 type_index = variant_id_to_index<T>::op(
 4223|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4224|       |                              }
 4225|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4226|       |                                 // Check if the deduced types include the tag-specified type
 4227|       |                                 // If not, the tag doesn't match the fields
 4228|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4229|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4230|       |                                 // Check if the tag-specified type is still possible
 4231|       |                                 const bool type_is_possible = possible_types[type_index];
 4232|       |                                 if (!type_is_possible) {
 4233|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4234|       |                                    ctx.error = error_code::no_matching_variant_type;
 4235|       |                                    return;
 4236|       |                                 }
 4237|       |
 4238|       |                                 if (!position_after_tag()) return;
 4239|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4240|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4241|       |                                 std::visit(
 4242|       |                                    [&](auto&& v) {
 4243|       |                                       using V = std::decay_t<decltype(v)>;
 4244|       |                                       constexpr bool is_object =
 4245|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4246|       |                                       if constexpr (variant_unit_alternative<V>) {
 4247|       |                                          // A unit alternative carries no data; its object holds only the
 4248|       |                                          // discriminator. Consume that body through an empty reflected object so
 4249|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4250|       |                                          detail::variant_unit_body unit_body{};
 4251|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4252|       |                                                                                             tag_literal>(unit_body,
 4253|       |                                                                                                          ctx, it, end);
 4254|       |                                       }
 4255|       |                                       else if constexpr (is_object) {
 4256|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4257|       |                                             // tag is a struct field, must re-parse
 4258|       |                                             if (!start.rewind(ctx, it, end)) return;
 4259|       |                                          }
 4260|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4261|       |                                                                                                           end);
 4262|       |                                       }
 4263|       |                                       else if constexpr (is_memory_object<V>) {
 4264|       |                                          if (!v) {
 4265|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4266|       |                                                if constexpr (requires { v.emplace(); }) {
 4267|       |                                                   v.emplace();
 4268|       |                                                }
 4269|       |                                                else {
 4270|       |                                                   v = typename V::value_type{};
 4271|       |                                                }
 4272|       |                                             }
 4273|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4274|       |                                                v = std::make_unique<typename V::element_type>();
 4275|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4276|       |                                                v = std::make_shared<typename V::element_type>();
 4277|       |                                             else if constexpr (constructible<V>) {
 4278|       |                                                v = meta_construct_v<V>();
 4279|       |                                             }
 4280|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4281|       |                                                                can_allocate_raw_pointer<Opts,
 4282|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4283|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4284|       |                                                   return;
 4285|       |                                                }
 4286|       |                                             }
 4287|       |                                             else {
 4288|       |                                                ctx.error = error_code::invalid_nullable_read;
 4289|       |                                                return;
 4290|       |                                                // Cannot read into unset nullable that is not std::optional,
 4291|       |                                                // std::unique_ptr, or std::shared_ptr
 4292|       |                                             }
 4293|       |                                          }
 4294|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4295|       |                                             // tag is a struct field, must re-parse
 4296|       |                                             if (!start.rewind(ctx, it, end)) return;
 4297|       |                                          }
 4298|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4299|       |                                             *v, ctx, it, end);
 4300|       |                                       }
 4301|       |                                       else if constexpr (custom_read<V>) {
 4302|       |                                          // Custom handlers parse the remaining body themselves and do not
 4303|       |                                          // accept the tag template parameter; the tag was already consumed.
 4304|       |                                          // This only works when the tag was the first key. If it came later,
 4305|       |                                          // we were reset to the object start and the custom handler would
 4306|       |                                          // absorb the tag, so error rather than corrupt the value.
 4307|       |                                          if (!first_key) {
 4308|       |                                             ctx.error = error_code::feature_not_supported;
 4309|       |                                             ctx.custom_error_message =
 4310|       |                                                "the tag must be the first key for a custom variant alternative";
 4311|       |                                             return;
 4312|       |                                          }
 4313|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4314|       |                                       }
 4315|       |                                    },
 4316|       |                                    value);
 4317|       |
 4318|       |                                 return; // we've decoded our target type
 4319|       |                              }
 4320|       |                              else [[unlikely]] {
 4321|       |                                 // Check if we have a default type (ids array shorter than variant)
 4322|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4323|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4324|       |                                 if constexpr (ids_size < variant_size) {
 4325|       |                                    // Use the first unlabeled type as the default
 4326|       |                                    const auto default_type_index = ids_size;
 4327|       |
 4328|       |                                    if (!position_after_tag()) return;
 4329|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4330|       |                                    if (value.index() != default_type_index)
 4331|       |                                       emplace_runtime_variant(value, default_type_index);
 4332|       |                                    std::visit(
 4333|       |                                       [&](auto&& v) {
 4334|       |                                          using V = std::decay_t<decltype(v)>;
 4335|       |                                          constexpr bool is_object =
 4336|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4337|       |                                          if constexpr (variant_unit_alternative<V>) {
 4338|       |                                             // A unit alternative carries no data; its object holds only the
 4339|       |                                             // discriminator. Consume that body through an empty reflected object so
 4340|       |                                             // unknown-key policy and terminator handling match every other
 4341|       |                                             // alternative.
 4342|       |                                             detail::variant_unit_body unit_body{};
 4343|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4344|       |                                                                                                tag_literal>(
 4345|       |                                                unit_body, ctx, it, end);
 4346|       |                                          }
 4347|       |                                          else if constexpr (is_object) {
 4348|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4349|       |                                                // tag is a struct field, must re-parse
 4350|       |                                                if (!start.rewind(ctx, it, end)) return;
 4351|       |                                             }
 4352|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4353|       |                                          }
 4354|       |                                          else if constexpr (is_memory_object<V>) {
 4355|       |                                             if (!v) {
 4356|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4357|       |                                                   if constexpr (requires { v.emplace(); }) {
 4358|       |                                                      v.emplace();
 4359|       |                                                   }
 4360|       |                                                   else {
 4361|       |                                                      v = typename V::value_type{};
 4362|       |                                                   }
 4363|       |                                                }
 4364|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4365|       |                                                   v = std::make_unique<typename V::element_type>();
 4366|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4367|       |                                                   v = std::make_shared<typename V::element_type>();
 4368|       |                                                else if constexpr (constructible<V>) {
 4369|       |                                                   v = meta_construct_v<V>();
 4370|       |                                                }
 4371|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4372|       |                                                                   can_allocate_raw_pointer<
 4373|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4374|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4375|       |                                                      return;
 4376|       |                                                   }
 4377|       |                                                }
 4378|       |                                                else {
 4379|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4380|       |                                                   return;
 4381|       |                                                }
 4382|       |                                             }
 4383|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4384|       |                                                // tag is a struct field, must re-parse
 4385|       |                                                if (!start.rewind(ctx, it, end)) return;
 4386|       |                                             }
 4387|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4388|       |                                                                                                              it, end);
 4389|       |                                          }
 4390|       |                                          else if constexpr (custom_read<V>) {
 4391|       |                                             // Custom handlers parse the remaining body themselves; this only
 4392|       |                                             // works when the tag was the first key (see above). If it came
 4393|       |                                             // later we were reset to the object start, so error rather than
 4394|       |                                             // let the custom handler absorb the tag.
 4395|       |                                             if (!first_key) {
 4396|       |                                                ctx.error = error_code::feature_not_supported;
 4397|       |                                                ctx.custom_error_message =
 4398|       |                                                   "the tag must be the first key for a custom variant alternative";
 4399|       |                                                return;
 4400|       |                                             }
 4401|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4402|       |                                          }
 4403|       |                                       },
 4404|       |                                       value);
 4405|       |
 4406|       |                                    return;
 4407|       |                                 }
 4408|       |                                 else {
 4409|       |                                    ctx.error = error_code::no_matching_variant_type;
 4410|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4411|       |                                    return;
 4412|       |                                 }
 4413|       |                              }
 4414|       |                           }
 4415|       |                        }
 4416|       |
 4417|       |                        // Inline decode_hash lookup for variant deduction
 4418|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4419|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4420|       |                        const auto deduction_index =
 4421|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4422|       |                              key.data(), key.data() + key.size(), key.size());
 4423|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4424|       |                           [[likely]] {
 4425|       |                           possible_types &= deduction_bits[deduction_index];
 4426|       |                        }
 4427|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4428|       |                           ctx.error = error_code::unknown_key;
 4429|       |                           return;
 4430|       |                        }
 4431|       |                     }
 4432|       |                     else if constexpr (not tag_v<T>.empty()) {
 4433|       |                        // empty object case for variant, if there are no normal elements
 4434|       |                        if (key == tag_v<T>) {
 4435|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4436|       |                              return;
 4437|       |                           }
 4438|       |
 4439|       |                           // The id is turned into an index below and never leaves this reader,
 4440|       |                           // so the view of the window it borrows cannot outlive that window.
 4441|       |                           std::string_view type_id{};
 4442|       |                           parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4443|       |                           if (bool(ctx.error)) [[unlikely]]
 4444|       |                              return;
 4445|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4446|       |                              return;
 4447|       |                           }
 4448|       |
 4449|       |                           const auto type_index = variant_id_to_index<T>::op(
 4450|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4451|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4452|       |                              if (!position_after_tag()) return;
 4453|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4454|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4455|       |                           }
 4456|       |                           else {
 4457|       |                              // Check if we have a default type (ids array shorter than variant)
 4458|       |                              constexpr auto ids_size = ids_v<T>.size();
 4459|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4460|       |                              if constexpr (ids_size < variant_size) {
 4461|       |                                 // Use the first unlabeled type as the default
 4462|       |                                 if (!position_after_tag()) return;
 4463|       |                                 const auto default_index = ids_size;
 4464|       |                                 tag_specified_index = default_index; // Store the default type index
 4465|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4466|       |                              }
 4467|       |                              else {
 4468|       |                                 ctx.error = error_code::no_matching_variant_type;
 4469|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4470|       |                                 return;
 4471|       |                              }
 4472|       |                           }
 4473|       |                           // Parse the type (handles tag skipping and unknown keys)
 4474|       |                           std::visit(
 4475|       |                              [&](auto&& v) {
 4476|       |                                 using V = std::decay_t<decltype(v)>;
 4477|       |                                 if constexpr (custom_read<V>) {
 4478|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4479|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4480|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4481|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4482|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4483|       |                                    // into its value, so error here rather than corrupt the result.
 4484|       |                                    if (!first_key) {
 4485|       |                                       ctx.error = error_code::feature_not_supported;
 4486|       |                                       ctx.custom_error_message =
 4487|       |                                          "the tag must be the first key for a custom variant alternative";
 4488|       |                                       return;
 4489|       |                                    }
 4490|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4491|       |                                 }
 4492|       |                                 else {
 4493|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4494|       |                                       // tag is a struct field, must re-parse
 4495|       |                                       if (!start.rewind(ctx, it, end)) return;
 4496|       |                                    }
 4497|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4498|       |                                 }
 4499|       |                              },
 4500|       |                              value);
 4501|       |                           return;
 4502|       |                        }
 4503|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4504|       |                           ctx.error = error_code::unknown_key;
 4505|       |                           return;
 4506|       |                        }
 4507|       |                        else {
 4508|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4509|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4510|       |                              return;
 4511|       |                           }
 4512|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4513|       |                           if (bool(ctx.error)) [[unlikely]]
 4514|       |                              return;
 4515|       |                           resync_window_end(ctx, end); // a streaming skip refills
 4516|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4517|       |                              return;
 4518|       |                           }
 4519|       |                           continue; // Continue loop to find the tag
 4520|       |                        }
 4521|       |                     }
 4522|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4523|       |                        ctx.error = error_code::unknown_key;
 4524|       |                        return;
 4525|       |                     }
 4526|       |
 4527|       |                     auto matching_types = possible_types.popcount();
 4528|       |                     if (matching_types == 0) {
 4529|       |                        ctx.error = error_code::no_matching_variant_type;
 4530|       |                        return;
 4531|       |                     }
 4532|       |                     // Only short-circuit for variants without tags
 4533|       |                     else if constexpr (tag_v<T>.empty()) {
 4534|       |                        if (matching_types == 1) {
 4535|       |                           if (!start.rewind(ctx, it, end)) return;
 4536|       |                           const auto type_index = possible_types.countr_zero();
 4537|       |
 4538|       |                           if (value.index() != static_cast<size_t>(type_index))
 4539|       |                              emplace_runtime_variant(value, type_index);
 4540|       |                           std::visit(
 4541|       |                              [&](auto&& v) {
 4542|       |                                 using V = std::decay_t<decltype(v)>;
 4543|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4544|       |                                 if constexpr (variant_unit_alternative<V>) {
 4545|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4546|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4547|       |                                    // terminator handling match every other alternative.
 4548|       |                                    detail::variant_unit_body unit_body{};
 4549|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4550|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4551|       |                                                                                                    end);
 4552|       |                                 }
 4553|       |                                 else if constexpr (is_object) {
 4554|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4555|       |                                 }
 4556|       |                                 else if constexpr (is_memory_object<V>) {
 4557|       |                                    if (!v) {
 4558|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4559|       |                                          if constexpr (requires { v.emplace(); }) {
 4560|       |                                             v.emplace();
 4561|       |                                          }
 4562|       |                                          else {
 4563|       |                                             v = typename V::value_type{};
 4564|       |                                          }
 4565|       |                                       }
 4566|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4567|       |                                          v = std::make_unique<typename V::element_type>();
 4568|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4569|       |                                          v = std::make_shared<typename V::element_type>();
 4570|       |                                       else if constexpr (constructible<V>) {
 4571|       |                                          v = meta_construct_v<V>();
 4572|       |                                       }
 4573|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4574|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4575|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4576|       |                                             return;
 4577|       |                                          }
 4578|       |                                       }
 4579|       |                                       else {
 4580|       |                                          ctx.error = error_code::invalid_nullable_read;
 4581|       |                                          return;
 4582|       |                                          // Cannot read into unset nullable that is not std::optional,
 4583|       |                                          // std::unique_ptr, or std::shared_ptr
 4584|       |                                       }
 4585|       |                                    }
 4586|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4587|       |                                       *v, ctx, it, end);
 4588|       |                                 }
 4589|       |                                 else if constexpr (custom_read<V>) {
 4590|       |                                    // Custom handlers parse the remaining body themselves.
 4591|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4592|       |                                 }
 4593|       |                              },
 4594|       |                              value);
 4595|       |
 4596|       |                           return; // we've decoded our target type
 4597|       |                        }
 4598|       |                     }
 4599|       |                     // For tagged variants, continue processing to validate tags
 4600|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4601|       |                        return;
 4602|       |                     }
 4603|       |
 4604|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4605|       |                     if (bool(ctx.error)) [[unlikely]]
 4606|       |                        return;
 4607|       |                     resync_window_end(ctx, end); // a streaming skip refills
 4608|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4609|       |                        return;
 4610|       |                     }
 4611|       |                  }
 4612|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4613|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4614|       |                     // After parsing all keys, check if we have multiple matching types
 4615|       |                     // If so, choose the one with the fewest fields
 4616|       |                     auto final_matching = possible_types.popcount();
 4617|       |                     if (final_matching == 0) {
 4618|       |                        ctx.error = error_code::no_matching_variant_type;
 4619|       |                     }
 4620|       |                     else if (final_matching == 1) {
 4621|       |                        // Single type remains after field deduction
 4622|       |                        const auto type_index = possible_types.countr_zero();
 4623|       |
 4624|       |                        // Validate against tag if one was specified
 4625|       |                        if (tag_specified_index.has_value() &&
 4626|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4627|       |                           ctx.error = error_code::no_matching_variant_type;
 4628|       |                           return;
 4629|       |                        }
 4630|       |
 4631|       |                        if (!start.rewind(ctx, it, end)) return;
 4632|       |                        if (value.index() != static_cast<size_t>(type_index))
 4633|       |                           emplace_runtime_variant(value, type_index);
 4634|       |                        std::visit(
 4635|       |                           [&](auto&& v) {
 4636|       |                              using V = std::decay_t<decltype(v)>;
 4637|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4638|       |                              if constexpr (variant_unit_alternative<V>) {
 4639|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4640|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4641|       |                                 // terminator handling match every other alternative.
 4642|       |                                 detail::variant_unit_body unit_body{};
 4643|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4644|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4645|       |                                                                                                 end);
 4646|       |                              }
 4647|       |                              else if constexpr (is_object) {
 4648|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4649|       |                              }
 4650|       |                              else if constexpr (is_memory_object<V>) {
 4651|       |                                 if (!v) {
 4652|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4653|       |                                       if constexpr (requires { v.emplace(); }) {
 4654|       |                                          v.emplace();
 4655|       |                                       }
 4656|       |                                       else {
 4657|       |                                          v = typename V::value_type{};
 4658|       |                                       }
 4659|       |                                    }
 4660|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4661|       |                                       v = std::make_unique<typename V::element_type>();
 4662|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4663|       |                                       v = std::make_shared<typename V::element_type>();
 4664|       |                                    else if constexpr (constructible<V>) {
 4665|       |                                       v = meta_construct_v<V>();
 4666|       |                                    }
 4667|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4668|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4669|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4670|       |                                          return;
 4671|       |                                       }
 4672|       |                                    }
 4673|       |                                    else {
 4674|       |                                       ctx.error = error_code::invalid_nullable_read;
 4675|       |                                       return;
 4676|       |                                    }
 4677|       |                                 }
 4678|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4679|       |                                                                                                               it, end);
 4680|       |                              }
 4681|       |                              else if constexpr (custom_read<V>) {
 4682|       |                                 // Custom handlers parse the remaining body themselves.
 4683|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4684|       |                              }
 4685|       |                           },
 4686|       |                           value);
 4687|       |                     }
 4688|       |                     else if (final_matching > 1) {
 4689|       |                        constexpr auto N = std::variant_size_v<T>;
 4690|       |
 4691|       |                        // Compile-time array of field counts for each variant type
 4692|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4693|       |                           return std::array<size_t, N> {
 4694|       |                              ([]<size_t J = I>() -> size_t {
 4695|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4696|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4697|       |                                    return reflect<V>::size;
 4698|       |                                 }
 4699|       |                                 else if constexpr (is_memory_object<V>) {
 4700|       |                                    using X = memory_type<V>;
 4701|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4702|       |                                       return reflect<X>::size;
 4703|       |                                    }
 4704|       |                                    else {
 4705|       |                                       return (std::numeric_limits<size_t>::max)();
 4706|       |                                    }
 4707|       |                                 }
 4708|       |                                 else {
 4709|       |                                    return (std::numeric_limits<size_t>::max)();
 4710|       |                                 }
 4711|       |                              }.template operator()<I>())...
 4712|       |                           };
 4713|       |                        }(std::make_index_sequence<N>{});
 4714|       |
 4715|       |                        // Find the type with minimum field count among the possible types
 4716|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4717|       |                        size_t chosen_index = N; // Invalid index initially
 4718|       |
 4719|       |                        for (size_t i = 0; i < N; ++i) {
 4720|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4721|       |                              min_fields = field_counts[i];
 4722|       |                              chosen_index = i;
 4723|       |                           }
 4724|       |                        }
 4725|       |
 4726|       |                        if (chosen_index < N) {
 4727|       |                           // Validate against tag if one was specified
 4728|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4729|       |                              ctx.error = error_code::no_matching_variant_type;
 4730|       |                              return;
 4731|       |                           }
 4732|       |
 4733|       |                           if (!start.rewind(ctx, it, end)) return;
 4734|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4735|       |                           std::visit(
 4736|       |                              [&](auto&& v) {
 4737|       |                                 using V = std::decay_t<decltype(v)>;
 4738|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4739|       |                                 if constexpr (variant_unit_alternative<V>) {
 4740|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4741|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4742|       |                                    // terminator handling match every other alternative.
 4743|       |                                    detail::variant_unit_body unit_body{};
 4744|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4745|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4746|       |                                                                                                    end);
 4747|       |                                 }
 4748|       |                                 else if constexpr (is_object) {
 4749|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4750|       |                                 }
 4751|       |                                 else if constexpr (is_memory_object<V>) {
 4752|       |                                    if (!v) {
 4753|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4754|       |                                          if constexpr (requires { v.emplace(); }) {
 4755|       |                                             v.emplace();
 4756|       |                                          }
 4757|       |                                          else {
 4758|       |                                             v = typename V::value_type{};
 4759|       |                                          }
 4760|       |                                       }
 4761|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4762|       |                                          v = std::make_unique<typename V::element_type>();
 4763|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4764|       |                                          v = std::make_shared<typename V::element_type>();
 4765|       |                                       else if constexpr (constructible<V>) {
 4766|       |                                          v = meta_construct_v<V>();
 4767|       |                                       }
 4768|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4769|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4770|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4771|       |                                             return;
 4772|       |                                          }
 4773|       |                                       }
 4774|       |                                       else {
 4775|       |                                          ctx.error = error_code::invalid_nullable_read;
 4776|       |                                          return;
 4777|       |                                       }
 4778|       |                                    }
 4779|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4780|       |                                       *v, ctx, it, end);
 4781|       |                                 }
 4782|       |                                 else if constexpr (custom_read<V>) {
 4783|       |                                    // Custom handlers parse the remaining body themselves.
 4784|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4785|       |                                 }
 4786|       |                              },
 4787|       |                              value);
 4788|       |                        }
 4789|       |                        else {
 4790|       |                           ctx.error = error_code::no_matching_variant_type;
 4791|       |                        }
 4792|       |                     }
 4793|       |                  }
 4794|       |                  else {
 4795|       |                     // For variants with 0 or 1 object types, use the original error handling
 4796|       |                     ctx.error = error_code::no_matching_variant_type;
 4797|       |                  }
 4798|       |               }
 4799|      0|               break;
 4800|  20.2k|            }
 4801|   613k|            case '[':
  ------------------
  |  Branch (4801:13): [True: 613k, False: 1.97M]
  ------------------
 4802|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4803|   613k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4804|   613k|               break;
 4805|  5.26k|            case '"': {
  ------------------
  |  Branch (4805:13): [True: 5.26k, False: 2.58M]
  ------------------
 4806|  5.26k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4807|  5.26k|               break;
 4808|  20.2k|            }
 4809|    909|            case 't':
  ------------------
  |  Branch (4809:13): [True: 909, False: 2.59M]
  ------------------
 4810|  1.19k|            case 'f': {
  ------------------
  |  Branch (4810:13): [True: 290, False: 2.59M]
  ------------------
 4811|  1.19k|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4812|  1.19k|               break;
 4813|    909|            }
 4814|    590|            case 'n':
  ------------------
  |  Branch (4814:13): [True: 590, False: 2.59M]
  ------------------
 4815|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4816|       |                  ctx.error = error_code::no_matching_variant_type;
 4817|       |               }
 4818|    590|               else {
 4819|    590|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4820|    590|                  using V = std::variant_alternative_t<first_idx, T>;
 4821|    590|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4821:23): [True: 200, False: 390]
  ------------------
 4822|    590|                  match<"null", Opts>(ctx, it, end);
 4823|    590|               }
 4824|    590|               break;
 4825|  1.95M|            default: {
  ------------------
  |  Branch (4825:13): [True: 1.95M, False: 641k]
  ------------------
 4826|       |               // Not bool, string, object, or array so must be number or null
 4827|  1.95M|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4828|  1.95M|            }
 4829|  2.59M|            }
 4830|       |         }
 4831|       |         else {
 4832|       |            // For non-auto-deducible variants, try each type until one succeeds
 4833|       |            constexpr auto N = std::variant_size_v<T>;
 4834|       |            bool parsed = false;
 4835|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4836|       |
 4837|       |            for_each<N>([&]<size_t I>() {
 4838|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4839|       |
 4840|       |               auto copy_it = it;
 4841|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4842|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4843|       |               const auto copy_depth = ctx.depth;
 4844|       |
 4845|       |               // Try parsing as this type
 4846|       |               if (value.index() != I) {
 4847|       |                  emplace_runtime_variant(value, I);
 4848|       |               }
 4849|       |
 4850|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4851|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4852|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4853|       |               }
 4854|       |
 4855|       |               if (!bool(ctx.error)) {
 4856|       |                  parsed = true;
 4857|       |               }
 4858|       |               else if constexpr (not Options.null_terminated) {
 4859|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4860|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4861|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4862|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4863|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4864|       |                     parsed = true;
 4865|       |                     ctx.error = error_code::none;
 4866|       |                  }
 4867|       |                  else {
 4868|       |                     // Reset for next attempt (unless this is the last type)
 4869|       |                     it = copy_it;
 4870|       |                     rewind_depth<Options>(ctx, copy_depth);
 4871|       |                     if constexpr (I + 1 < N) {
 4872|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4873|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4874|       |                        }
 4875|       |                     }
 4876|       |                  }
 4877|       |               }
 4878|       |               else {
 4879|       |                  // Reset for next attempt (unless this is the last type)
 4880|       |                  it = copy_it;
 4881|       |                  rewind_depth<Options>(ctx, copy_depth);
 4882|       |                  if constexpr (I + 1 < N) {
 4883|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4884|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4885|       |                     }
 4886|       |                  }
 4887|       |               }
 4888|       |            });
 4889|       |         }
 4890|  2.59M|      }
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3725|   615k|      {
 3726|   615k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3727|       |
 3728|       |         if constexpr (category_count == 0) {
 3729|       |            ctx.error = error_code::no_matching_variant_type;
 3730|       |         }
 3731|   615k|         else {
 3732|   615k|            constexpr auto N = std::variant_size_v<Variant>;
 3733|   615k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3734|   615k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3735|       |
 3736|   615k|            bool found_match{};
 3737|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3738|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3739|       |            // so the budget stops it and the failure already in hand is reported.
 3740|   615k|            bool exhausted{};
 3741|       |
 3742|       |            // First pass: const glaze types in this category
 3743|       |            if constexpr (const_count > 0) {
 3744|       |               for_each<N>([&]<size_t I>() {
 3745|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3746|       |                     return;
 3747|       |                  }
 3748|       |                  using V = std::variant_alternative_t<I, Variant>;
 3749|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3750|       |                     // run time substitute to compare to const value
 3751|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3752|       |                     auto copy_it{it};
 3753|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3754|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3755|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3756|       |                     const auto copy_depth{ctx.depth};
 3757|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3758|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3759|       |                     if (substitute == const_value) {
 3760|       |                        found_match = true;
 3761|       |                        if (!std::holds_alternative<V>(value)) {
 3762|       |                           value = V{};
 3763|       |                        }
 3764|       |                     }
 3765|       |                     else {
 3766|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3767|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3768|       |                           exhausted = true;
 3769|       |                        }
 3770|       |                        if constexpr (not Options.null_terminated) {
 3771|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3772|       |                              ctx.error = error_code::none;
 3773|       |                           }
 3774|       |                        }
 3775|       |                        it = copy_it;
 3776|       |                        rewind_depth<Options>(ctx, copy_depth);
 3777|       |                     }
 3778|       |                  }
 3779|       |               });
 3780|       |               if (found_match) {
 3781|       |                  return;
 3782|       |               }
 3783|       |            }
 3784|       |
 3785|       |            // Second pass: non-const types in this category
 3786|   615k|            if constexpr (non_const_count > 0) {
 3787|       |               // Track position within matching types for "is last" check.
 3788|       |               // We iterate over all variant indices but only process matching types,
 3789|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3790|       |               // the loop index directly corresponded to position in filtered set).
 3791|       |               // This has negligible cost: one increment per matching type.
 3792|   615k|               size_t non_const_idx = 0;
 3793|       |
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3796|   615k|                     return;
 3797|   615k|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|   615k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|   615k|                     auto copy_it{it};
 3801|   615k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|   615k|                     if (!std::holds_alternative<V>(value)) {
 3803|   615k|                        value = V{};
 3804|   615k|                     }
 3805|   615k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|   615k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|   615k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|   615k|                     }
 3809|   615k|                     if (!bool(ctx.error)) {
 3810|   615k|                        found_match = true;
 3811|   615k|                     }
 3812|   615k|                     else if constexpr (not Options.null_terminated) {
 3813|   615k|                        constexpr bool is_complete_type =
 3814|   615k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|   615k|                        if constexpr (is_complete_type) {
 3817|   615k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|   615k|                              found_match = true;
 3819|   615k|                              ctx.error = error_code::none;
 3820|   615k|                           }
 3821|   615k|                           else {
 3822|   615k|                              it = copy_it;
 3823|   615k|                              rewind_depth<Options>(ctx, copy_depth);
 3824|   615k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|   615k|                                  not variant_alternative_exhausted(ctx)) {
 3826|   615k|                                 ctx.error = error_code::none;
 3827|   615k|                              }
 3828|   615k|                           }
 3829|   615k|                        }
 3830|   615k|                        else {
 3831|   615k|                           it = copy_it;
 3832|   615k|                           rewind_depth<Options>(ctx, copy_depth);
 3833|   615k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|   615k|                               not variant_alternative_exhausted(ctx)) {
 3835|   615k|                              ctx.error = error_code::none;
 3836|   615k|                           }
 3837|   615k|                        }
 3838|   615k|                     }
 3839|   615k|                     else {
 3840|   615k|                        it = copy_it;
 3841|   615k|                        rewind_depth<Options>(ctx, copy_depth);
 3842|   615k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|   615k|                            not variant_alternative_exhausted(ctx)) {
 3844|   615k|                           ctx.error = error_code::none;
 3845|   615k|                        }
 3846|   615k|                     }
 3847|   615k|                     ++non_const_idx;
 3848|   615k|                  }
 3849|   615k|               });
 3850|   615k|               if (!found_match) {
  ------------------
  |  Branch (3850:20): [True: 13.7k, False: 602k]
  ------------------
 3851|  13.7k|                  if constexpr (non_const_count == 1) {
 3852|       |                     // Keep the specific error from the single type we tried
 3853|       |                  }
 3854|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3855|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3856|       |                     ctx.error = error_code::no_matching_variant_type;
 3857|       |                  }
 3858|  13.7k|               }
 3859|       |            }
 3860|       |            else {
 3861|       |               ctx.error = error_code::no_matching_variant_type;
 3862|       |            }
 3863|   615k|         }
 3864|   615k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|   615k|               });
_ZN3glz29variant_alternative_exhaustedITkNS_10is_contextENS_7contextEEEbRT_:
 3714|  21.1M|   {
 3715|  21.1M|      return ctx.error == error_code::exceeded_max_recursive_depth;
 3716|  21.1M|   }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|   615k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|   615k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|   615k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|   615k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|   615k|                     auto copy_it{it};
 3801|   615k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|   615k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3802:26): [True: 482k, False: 132k]
  ------------------
 3803|   482k|                        value = V{};
 3804|   482k|                     }
 3805|   615k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|   615k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3806:26): [True: 13.7k, False: 602k]
  |  Branch (3806:45): [True: 0, False: 13.7k]
  ------------------
 3807|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|      0|                     }
 3809|   615k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3809:26): [True: 602k, False: 13.7k]
  ------------------
 3810|   602k|                        found_match = true;
 3811|   602k|                     }
 3812|  13.7k|                     else if constexpr (not Options.null_terminated) {
 3813|  13.7k|                        constexpr bool is_complete_type =
 3814|  13.7k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
  ------------------
  |  Branch (3814:28): [Folded, False: 0]
  |  Branch (3814:40): [Folded, False: 0]
  |  Branch (3814:53): [Folded, False: 0]
  |  Branch (3814:68): [Folded, False: 0]
  |  Branch (3814:89): [Folded, False: 0]
  |  Branch (3814:103): [Folded, False: 0]
  ------------------
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|  13.7k|                        else {
 3831|  13.7k|                           it = copy_it;
 3832|  13.7k|                           rewind_depth<Options>(ctx, copy_depth);
 3833|  13.7k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3833:32): [True: 0, False: 13.7k]
  |  Branch (3833:71): [True: 0, False: 0]
  ------------------
 3834|      0|                               not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3834:32): [True: 0, False: 0]
  ------------------
 3835|      0|                              ctx.error = error_code::none;
 3836|      0|                           }
 3837|  13.7k|                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|   615k|                     ++non_const_idx;
 3848|   615k|                  }
 3849|   615k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS4_9allocatorIS9_EEEETkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
   49|   615k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|   615k|         else {
   60|   615k|            using V = std::remove_cvref_t<T>;
   61|   615k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|   615k|                                             end);
   63|   615k|         }
   64|   615k|      }
_ZN3glz4fromILj10ENSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS1_9allocatorIS6_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERS9_TkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
 2308|   615k|      {
 2309|   615k|         constexpr auto Opts = ws_handled_off<Options>();
 2310|       |         if constexpr (!check_ws_handled(Options)) {
 2311|       |            if (skip_ws<Opts>(ctx, it, end)) {
 2312|       |               return;
 2313|       |            }
 2314|       |         }
 2315|       |
 2316|   615k|         if (match_invalid_end<'[', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2316:14): [True: 110, False: 615k]
  ------------------
 2317|    110|            return;
 2318|    110|         }
 2319|       |         // one nesting level (see enter_depth): counted in both modes so the limit binds,
 2320|       |         // released at each syntactic close below
 2321|   615k|         if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (2321:14): [True: 2, False: 615k]
  ------------------
 2322|      2|            return;
 2323|      2|         }
 2324|       |
 2325|   615k|         const auto ws_start = it;
 2326|   615k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2326:14): [True: 58, False: 615k]
  ------------------
 2327|     58|            return;
 2328|     58|         }
 2329|       |
 2330|   615k|         if (*it == ']') {
  ------------------
  |  Branch (2330:14): [True: 4.84k, False: 610k]
  ------------------
 2331|  4.84k|            --ctx.depth;
 2332|  4.84k|            ++it;
 2333|  4.84k|            if constexpr ((resizable<T> || is_inplace_vector<T>) && not check_append_arrays(Opts)) {
 2334|  4.84k|               value.clear();
 2335|       |
 2336|       |               if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2337|       |                  value.shrink_to_fit();
 2338|       |               }
 2339|  4.84k|            }
 2340|  4.84k|            return;
 2341|  4.84k|         }
 2342|       |
 2343|   610k|         const size_t ws_size = size_t(it - ws_start);
 2344|       |
 2345|   610k|         static constexpr bool should_append = (resizable<T> || is_inplace_vector<T>) && check_append_arrays(Opts);
  ------------------
  |  Branch (2345:49): [True: 610k, Folded]
  |  Branch (2345:65): [Folded, False: 0]
  |  Branch (2345:90): [Folded, False: 0]
  ------------------
 2346|   610k|         if constexpr (not should_append) {
 2347|   610k|            const auto n = value.size();
 2348|       |
 2349|   610k|            auto value_it = value.begin();
 2350|       |
 2351|   618k|            for (size_t i = 0; i < n; ++i) {
  ------------------
  |  Branch (2351:32): [True: 138k, False: 480k]
  ------------------
 2352|   138k|               parse<JSON>::op<ws_handled<Opts>()>(*value_it++, ctx, it, end);
 2353|   138k|               if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2353:20): [True: 728, False: 137k]
  ------------------
 2354|    728|                  return;
 2355|   137k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2355:20): [True: 43, False: 137k]
  ------------------
 2356|     43|                  return;
 2357|     43|               }
 2358|   137k|               if (*it == ',') {
  ------------------
  |  Branch (2358:20): [True: 7.74k, False: 129k]
  ------------------
 2359|  7.74k|                  ++it;
 2360|       |
 2361|  7.74k|                  if constexpr (!Opts.minified && !Opts.comments) {
 2362|  7.74k|                     if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2362:26): [True: 4.53k, False: 3.20k]
  |  Branch (2362:37): [True: 3.91k, False: 619]
  ------------------
 2363|  3.91k|                        skip_matching_ws(ws_start, it, ws_size);
 2364|  3.91k|                     }
 2365|  7.74k|                  }
 2366|       |
 2367|  7.74k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2367:23): [True: 102, False: 7.64k]
  ------------------
 2368|    102|                     return;
 2369|    102|                  }
 2370|  7.74k|               }
 2371|   129k|               else if (*it == ']') {
  ------------------
  |  Branch (2371:25): [True: 129k, False: 32]
  ------------------
 2372|   129k|                  --ctx.depth;
 2373|   129k|                  ++it;
 2374|   129k|                  if constexpr (erasable<T>) {
 2375|   129k|                     value.erase(value_it,
 2376|   129k|                                 value.end()); // use erase rather than resize for non-default constructible elements
 2377|       |
 2378|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2379|       |                        value.shrink_to_fit();
 2380|       |                     }
 2381|   129k|                  }
 2382|   129k|                  return;
 2383|   129k|               }
 2384|     32|               else [[unlikely]] {
 2385|     32|                  ctx.error = error_code::expected_bracket;
 2386|     32|                  return;
 2387|     32|               }
 2388|   137k|            }
 2389|   610k|         }
 2390|       |
 2391|       |         if constexpr (Opts.partial_read) {
 2392|       |            // partial_read stops early on a success path, so give the level back like the
 2393|       |            // syntactic-close paths do; otherwise it accumulates across reads sharing a context.
 2394|       |            --ctx.depth;
 2395|       |            return;
 2396|       |         }
 2397|   610k|         else {
 2398|       |            // growing
 2399|   610k|            if constexpr (emplace_backable<T> || has_try_emplace_back<T>) {
 2400|  1.71M|               while (it < end) {
  ------------------
  |  Branch (2400:23): [True: 1.58M, False: 130k]
  ------------------
 2401|       |                  // Streaming refill point: at start of each iteration, ensure buffer has data
 2402|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2403|       |                     if (ctx.stream.enabled()) {
 2404|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2405|       |                        const size_t remaining = ctx.stream.size() - consumed;
 2406|       |                        // Refill when less than half of buffer remains to ensure space for next element
 2407|       |                        if (remaining <= ctx.stream.size() / 2 || it >= end) {
 2408|       |                           const char* new_it;
 2409|       |                           const char* new_end;
 2410|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2411|       |                           it = new_it;
 2412|       |                           end = new_end;
 2413|       |                           if (it >= end && ctx.stream.at_eof()) {
 2414|       |                              break; // No more data, exit loop normally
 2415|       |                           }
 2416|       |                        }
 2417|       |                     }
 2418|       |                  }
 2419|       |
 2420|       |                  if constexpr (has_try_emplace_back<T>) {
 2421|       |                     if (value.try_emplace_back())
 2422|       |                        parse<JSON>::op<ws_handled<Opts>()>(value.back(), ctx, it, end);
 2423|       |                     else
 2424|       |                        ctx.error = error_code::exceeded_static_array_size;
 2425|       |                  }
 2426|  1.58M|                  else {
 2427|  1.58M|                     parse<JSON>::op<ws_handled<Opts>()>(value.emplace_back(), ctx, it, end);
 2428|  1.58M|                  }
 2429|       |
 2430|  1.58M|                  if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2430:23): [True: 11.4k, False: 1.57M]
  ------------------
 2431|  11.4k|                     return;
 2432|       |
 2433|       |                  // Streaming refill point: after parsing each element, refill if buffer is low
 2434|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2435|       |                     if (ctx.stream.enabled()) {
 2436|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2437|       |                        // Refill when less than 25% of buffer remains to ensure enough space for next element
 2438|       |                        if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 2439|       |                           const char* new_it;
 2440|       |                           const char* new_end;
 2441|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2442|       |                           it = new_it;
 2443|       |                           end = new_end;
 2444|       |                           if (it >= end && ctx.stream.at_eof()) {
 2445|       |                              ctx.error = error_code::unexpected_end;
 2446|       |                              return;
 2447|       |                           }
 2448|       |                        }
 2449|       |                     }
 2450|       |                  }
 2451|       |
 2452|  1.57M|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2452:23): [True: 638, False: 1.57M]
  ------------------
 2453|    638|                     return;
 2454|    638|                  }
 2455|  1.57M|                  if (*it == ',') [[likely]] {
  ------------------
  |  Branch (2455:23): [True: 1.10M, False: 467k]
  ------------------
 2456|  1.10M|                     ++it;
 2457|       |
 2458|  1.10M|                     if constexpr (!Opts.minified && !Opts.comments) {
 2459|  1.10M|                        if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2459:29): [True: 15.4k, False: 1.09M]
  |  Branch (2459:40): [True: 14.5k, False: 866]
  ------------------
 2460|  14.5k|                           skip_matching_ws(ws_start, it, ws_size);
 2461|  14.5k|                        }
 2462|  1.10M|                     }
 2463|       |
 2464|  1.10M|                     if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2464:26): [True: 222, False: 1.10M]
  ------------------
 2465|    222|                        return;
 2466|    222|                     }
 2467|  1.10M|                  }
 2468|   467k|                  else if (*it == ']') {
  ------------------
  |  Branch (2468:28): [True: 467k, False: 364]
  ------------------
 2469|   467k|                     --ctx.depth;
 2470|   467k|                     ++it;
 2471|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2472|       |                        value.shrink_to_fit();
 2473|       |                     }
 2474|   467k|                     return;
 2475|   467k|                  }
 2476|    364|                  else [[unlikely]] {
 2477|    364|                     ctx.error = error_code::expected_bracket;
 2478|    364|                     return;
 2479|    364|                  }
 2480|  1.57M|               }
 2481|       |
 2482|       |               // A valid array always returns from inside the loop upon reaching ']'.
 2483|       |               // For a null-terminated buffer the loop can only exit here by falling
 2484|       |               // through when `it` reaches the terminator without a closing bracket,
 2485|       |               // which means the input was truncated (e.g. "[", "[1," or "[1,2,").
 2486|       |               // Non-null-terminated buffers surface this through skip_ws/depth
 2487|       |               // tracking (or the streaming refill break), so this guard is limited
 2488|       |               // to the null-terminated case.
 2489|       |               if constexpr (Opts.null_terminated) {
 2490|       |                  ctx.error = error_code::unexpected_end;
 2491|       |               }
 2492|       |            }
 2493|       |            else {
 2494|       |               ctx.error = error_code::exceeded_static_array_size;
 2495|       |            }
 2496|   610k|         }
 2497|   610k|      }
_ZN3glz12rewind_depthITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextENS_7contextEEEvRT0_j:
 3697|  16.3k|   {
 3698|  16.3k|      if (ctx.error == error_code::exceeded_max_recursive_depth) [[unlikely]] {
  ------------------
  |  Branch (3698:11): [True: 940, False: 15.4k]
  ------------------
 3699|    940|         return;
 3700|    940|      }
 3701|       |      if constexpr (Opts.null_terminated) {
 3702|       |         ctx.depth = depth;
 3703|       |      }
 3704|  15.4k|      else {
 3705|  15.4k|         if (ctx.error != error_code::end_reached && ctx.error != error_code::unexpected_end) {
  ------------------
  |  Branch (3705:14): [True: 13.1k, False: 2.25k]
  |  Branch (3705:54): [True: 7.16k, False: 6.01k]
  ------------------
 3706|  7.16k|            ctx.depth = depth;
 3707|  7.16k|         }
 3708|  15.4k|      }
 3709|  15.4k|   }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 602k, False: 13.7k]
  |  Branch (3795:38): [True: 0, False: 13.7k]
  |  Branch (3795:51): [True: 940, False: 12.7k]
  ------------------
 3796|   603k|                     return;
 3797|   603k|                  }
 3798|  12.7k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  12.7k|               });
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3725|  6.38k|      {
 3726|  6.38k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3727|       |
 3728|       |         if constexpr (category_count == 0) {
 3729|       |            ctx.error = error_code::no_matching_variant_type;
 3730|       |         }
 3731|  6.38k|         else {
 3732|  6.38k|            constexpr auto N = std::variant_size_v<Variant>;
 3733|  6.38k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3734|  6.38k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3735|       |
 3736|  6.38k|            bool found_match{};
 3737|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3738|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3739|       |            // so the budget stops it and the failure already in hand is reported.
 3740|  6.38k|            bool exhausted{};
 3741|       |
 3742|       |            // First pass: const glaze types in this category
 3743|       |            if constexpr (const_count > 0) {
 3744|       |               for_each<N>([&]<size_t I>() {
 3745|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3746|       |                     return;
 3747|       |                  }
 3748|       |                  using V = std::variant_alternative_t<I, Variant>;
 3749|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3750|       |                     // run time substitute to compare to const value
 3751|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3752|       |                     auto copy_it{it};
 3753|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3754|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3755|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3756|       |                     const auto copy_depth{ctx.depth};
 3757|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3758|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3759|       |                     if (substitute == const_value) {
 3760|       |                        found_match = true;
 3761|       |                        if (!std::holds_alternative<V>(value)) {
 3762|       |                           value = V{};
 3763|       |                        }
 3764|       |                     }
 3765|       |                     else {
 3766|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3767|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3768|       |                           exhausted = true;
 3769|       |                        }
 3770|       |                        if constexpr (not Options.null_terminated) {
 3771|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3772|       |                              ctx.error = error_code::none;
 3773|       |                           }
 3774|       |                        }
 3775|       |                        it = copy_it;
 3776|       |                        rewind_depth<Options>(ctx, copy_depth);
 3777|       |                     }
 3778|       |                  }
 3779|       |               });
 3780|       |               if (found_match) {
 3781|       |                  return;
 3782|       |               }
 3783|       |            }
 3784|       |
 3785|       |            // Second pass: non-const types in this category
 3786|  6.38k|            if constexpr (non_const_count > 0) {
 3787|       |               // Track position within matching types for "is last" check.
 3788|       |               // We iterate over all variant indices but only process matching types,
 3789|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3790|       |               // the loop index directly corresponded to position in filtered set).
 3791|       |               // This has negligible cost: one increment per matching type.
 3792|  6.38k|               size_t non_const_idx = 0;
 3793|       |
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3796|  6.38k|                     return;
 3797|  6.38k|                  }
 3798|  6.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  6.38k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  6.38k|                     auto copy_it{it};
 3801|  6.38k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  6.38k|                     if (!std::holds_alternative<V>(value)) {
 3803|  6.38k|                        value = V{};
 3804|  6.38k|                     }
 3805|  6.38k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  6.38k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|  6.38k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|  6.38k|                     }
 3809|  6.38k|                     if (!bool(ctx.error)) {
 3810|  6.38k|                        found_match = true;
 3811|  6.38k|                     }
 3812|  6.38k|                     else if constexpr (not Options.null_terminated) {
 3813|  6.38k|                        constexpr bool is_complete_type =
 3814|  6.38k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|  6.38k|                        if constexpr (is_complete_type) {
 3817|  6.38k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|  6.38k|                              found_match = true;
 3819|  6.38k|                              ctx.error = error_code::none;
 3820|  6.38k|                           }
 3821|  6.38k|                           else {
 3822|  6.38k|                              it = copy_it;
 3823|  6.38k|                              rewind_depth<Options>(ctx, copy_depth);
 3824|  6.38k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|  6.38k|                                  not variant_alternative_exhausted(ctx)) {
 3826|  6.38k|                                 ctx.error = error_code::none;
 3827|  6.38k|                              }
 3828|  6.38k|                           }
 3829|  6.38k|                        }
 3830|  6.38k|                        else {
 3831|  6.38k|                           it = copy_it;
 3832|  6.38k|                           rewind_depth<Options>(ctx, copy_depth);
 3833|  6.38k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|  6.38k|                               not variant_alternative_exhausted(ctx)) {
 3835|  6.38k|                              ctx.error = error_code::none;
 3836|  6.38k|                           }
 3837|  6.38k|                        }
 3838|  6.38k|                     }
 3839|  6.38k|                     else {
 3840|  6.38k|                        it = copy_it;
 3841|  6.38k|                        rewind_depth<Options>(ctx, copy_depth);
 3842|  6.38k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|  6.38k|                            not variant_alternative_exhausted(ctx)) {
 3844|  6.38k|                           ctx.error = error_code::none;
 3845|  6.38k|                        }
 3846|  6.38k|                     }
 3847|  6.38k|                     ++non_const_idx;
 3848|  6.38k|                  }
 3849|  6.38k|               });
 3850|  6.38k|               if (!found_match) {
  ------------------
  |  Branch (3850:20): [True: 843, False: 5.53k]
  ------------------
 3851|    843|                  if constexpr (non_const_count == 1) {
 3852|       |                     // Keep the specific error from the single type we tried
 3853|       |                  }
 3854|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3855|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3856|       |                     ctx.error = error_code::no_matching_variant_type;
 3857|       |                  }
 3858|    843|               }
 3859|       |            }
 3860|       |            else {
 3861|       |               ctx.error = error_code::no_matching_variant_type;
 3862|       |            }
 3863|  6.38k|         }
 3864|  6.38k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 6.38k]
  |  Branch (3795:38): [True: 0, False: 6.38k]
  |  Branch (3795:51): [True: 0, False: 6.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  6.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  6.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 6.38k]
  |  Branch (3795:38): [True: 0, False: 6.38k]
  |  Branch (3795:51): [True: 0, False: 6.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  6.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  6.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 6.38k]
  |  Branch (3795:38): [True: 0, False: 6.38k]
  |  Branch (3795:51): [True: 0, False: 6.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  6.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  6.38k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  6.38k|                     auto copy_it{it};
 3801|  6.38k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  6.38k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3802:26): [True: 4.65k, False: 1.72k]
  ------------------
 3803|  4.65k|                        value = V{};
 3804|  4.65k|                     }
 3805|  6.38k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  6.38k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3806:26): [True: 988, False: 5.39k]
  |  Branch (3806:45): [True: 0, False: 988]
  ------------------
 3807|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|      0|                     }
 3809|  6.38k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3809:26): [True: 5.39k, False: 988]
  ------------------
 3810|  5.39k|                        found_match = true;
 3811|  5.39k|                     }
 3812|    988|                     else if constexpr (not Options.null_terminated) {
 3813|    988|                        constexpr bool is_complete_type =
 3814|    988|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
  ------------------
  |  Branch (3814:28): [Folded, False: 0]
  |  Branch (3814:40): [Folded, False: 0]
  |  Branch (3814:53): [True: 0, Folded]
  |  Branch (3814:68): [Folded, False: 0]
  |  Branch (3814:89): [Folded, False: 0]
  |  Branch (3814:103): [Folded, False: 0]
  ------------------
 3815|       |
 3816|    988|                        if constexpr (is_complete_type) {
 3817|    988|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
  ------------------
  |  Branch (3817:32): [True: 145, False: 843]
  |  Branch (3817:72): [True: 145, False: 0]
  |  Branch (3817:88): [True: 145, False: 0]
  ------------------
 3818|    145|                              found_match = true;
 3819|    145|                              ctx.error = error_code::none;
 3820|    145|                           }
 3821|    843|                           else {
 3822|    843|                              it = copy_it;
 3823|    843|                              rewind_depth<Options>(ctx, copy_depth);
 3824|    843|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3824:35): [True: 0, False: 843]
  |  Branch (3824:74): [True: 0, False: 0]
  ------------------
 3825|      0|                                  not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3825:35): [True: 0, False: 0]
  ------------------
 3826|      0|                                 ctx.error = error_code::none;
 3827|      0|                              }
 3828|    843|                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|  6.38k|                     ++non_const_idx;
 3848|  6.38k|                  }
 3849|  6.38k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|  6.38k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  6.38k|         else {
   60|  6.38k|            using V = std::remove_cvref_t<T>;
   61|  6.38k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  6.38k|                                             end);
   63|  6.38k|         }
   64|  6.38k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEQntcl15check_is_paddedTL0__EEEvRT2_OT3_OT0_T1_:
 1043|  6.38k|      {
 1044|       |         if constexpr (check_string_as_number(Opts)) {
 1045|       |            auto start = it;
 1046|       |            skip_number<Opts>(ctx, it, end);
 1047|       |            if (bool(ctx.error)) [[unlikely]] {
 1048|       |               return;
 1049|       |            }
 1050|       |            if (start == it) [[unlikely]] {
 1051|       |               ctx.error = error_code::parse_number_failure;
 1052|       |               return;
 1053|       |            }
 1054|       |            value.append(start, size_t(it - start));
 1055|       |         }
 1056|  6.38k|         else {
 1057|  6.38k|            if constexpr (!check_opening_handled(Opts)) {
 1058|       |               if constexpr (!check_ws_handled(Opts)) {
 1059|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 1060|       |                     return;
 1061|       |                  }
 1062|       |               }
 1063|       |
 1064|  6.38k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (1064:20): [True: 71, False: 6.31k]
  ------------------
 1065|     71|                  return;
 1066|     71|               }
 1067|  6.38k|            }
 1068|       |
 1069|  6.38k|            if constexpr (not check_raw_string(Opts)) {
 1070|  6.38k|               static constexpr auto string_padding_bytes = 8;
 1071|       |
 1072|  6.38k|               if (size_t(end - it) >= 8) {
  ------------------
  |  Branch (1072:20): [True: 5.72k, False: 652]
  ------------------
 1073|  5.72k|                  auto start = it;
 1074|  5.72k|                  uint64_t ascii_acc{};
 1075|  5.72k|                  const auto end8 = end - 8;
 1076|  1.45M|                  while (true) {
  ------------------
  |  Branch (1076:26): [True: 1.45M, Folded]
  ------------------
 1077|  1.45M|                     if (it >= end8) [[unlikely]] {
  ------------------
  |  Branch (1077:26): [True: 586, False: 1.45M]
  ------------------
 1078|    586|                        break;
 1079|    586|                     }
 1080|       |
 1081|  1.45M|                     uint64_t chunk;
 1082|  1.45M|                     std::memcpy(&chunk, it, 8);
 1083|       |                     if constexpr (std::endian::native == std::endian::big) {
 1084|       |                        chunk = std::byteswap(chunk);
 1085|       |                     }
 1086|  1.45M|                     ascii_acc |= chunk;
 1087|  1.45M|                     const uint64_t test_chars = has_quote(chunk);
 1088|  1.45M|                     if (test_chars) {
  ------------------
  |  Branch (1088:26): [True: 6.82k, False: 1.44M]
  ------------------
 1089|  6.82k|                        it += (countr_zero(test_chars) >> 3);
 1090|       |
 1091|  6.82k|                        auto* prev = it - 1;
 1092|  8.79k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1092:32): [True: 1.97k, False: 6.82k]
  ------------------
 1093|  1.97k|                           --prev;
 1094|  1.97k|                        }
 1095|  6.82k|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1095:29): [True: 5.14k, False: 1.68k]
  ------------------
 1096|  5.14k|                           goto continue_decode;
 1097|  5.14k|                        }
 1098|  1.68k|                        ++it; // skip the escaped quote
 1099|  1.68k|                     }
 1100|  1.44M|                     else {
 1101|  1.44M|                        it += 8;
 1102|  1.44M|                     }
 1103|  1.45M|                  }
 1104|       |
 1105|  2.14k|                  while (it[-1] == '\\') [[unlikely]] {
  ------------------
  |  Branch (1105:26): [True: 1.56k, False: 586]
  ------------------
 1106|       |                     // if we ended on an escape character then we need to rewind
 1107|       |                     // because we lost our context
 1108|  1.56k|                     --it;
 1109|  1.56k|                  }
 1110|       |
 1111|       |                  // The byte-wise tail keeps feeding the accumulator: it has to cover every byte of
 1112|       |                  // the string, or a non-ASCII byte reached here would be waved through unvalidated.
 1113|  4.19k|                  for (; it < end; ++it) {
  ------------------
  |  Branch (1113:26): [True: 4.09k, False: 102]
  ------------------
 1114|  4.09k|                     ascii_acc |= uint8_t(*it);
 1115|  4.09k|                     if (*it == '"') {
  ------------------
  |  Branch (1115:26): [True: 568, False: 3.52k]
  ------------------
 1116|    568|                        auto* prev = it - 1;
 1117|  1.40k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1117:32): [True: 834, False: 568]
  ------------------
 1118|    834|                           --prev;
 1119|    834|                        }
 1120|    568|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1120:29): [True: 484, False: 84]
  ------------------
 1121|    484|                           goto continue_decode;
 1122|    484|                        }
 1123|    568|                     }
 1124|  4.09k|                  }
 1125|       |
 1126|    102|                  ctx.error = error_code::unexpected_end;
 1127|    102|                  return;
 1128|       |
 1129|  5.62k|               continue_decode:
 1130|       |
 1131|  5.62k|                  if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (1131:23): [True: 131, False: 5.49k]
  ------------------
 1132|    131|                     return;
 1133|    131|                  }
 1134|       |
 1135|  5.49k|                  const auto available_padding = size_t(end - it);
 1136|  5.49k|                  auto n = size_t(it - start);
 1137|  5.49k|                  if (available_padding >= 8) [[likely]] {
  ------------------
  |  Branch (1137:23): [True: 5.09k, False: 405]
  ------------------
 1138|  5.09k|                     value.resize(n + string_padding_bytes);
 1139|       |
 1140|  5.09k|                     auto* p = value.data();
 1141|       |
 1142|  28.8k|                     while (true) {
  ------------------
  |  Branch (1142:29): [True: 28.8k, Folded]
  ------------------
 1143|  28.8k|                        if (start >= it) {
  ------------------
  |  Branch (1143:29): [True: 4.73k, False: 24.1k]
  ------------------
 1144|  4.73k|                           break;
 1145|  4.73k|                        }
 1146|       |
 1147|  24.1k|                        std::memcpy(p, start, 8);
 1148|  24.1k|                        uint64_t swar;
 1149|  24.1k|                        std::memcpy(&swar, p, 8);
 1150|       |                        if constexpr (std::endian::native == std::endian::big) {
 1151|       |                           swar = std::byteswap(swar);
 1152|       |                        }
 1153|       |
 1154|  24.1k|                        constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1155|  24.1k|                        const uint64_t lo7 = swar & lo7_mask;
 1156|  24.1k|                        const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1157|  24.1k|                        const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1158|  24.1k|                        uint64_t next = ~((backslash & less_32) | swar);
 1159|       |
 1160|  24.1k|                        next &= repeat_byte8(0b10000000);
 1161|  24.1k|                        if (next == 0) {
  ------------------
  |  Branch (1161:29): [True: 22.3k, False: 1.80k]
  ------------------
 1162|  22.3k|                           start += 8;
 1163|  22.3k|                           p += 8;
 1164|  22.3k|                           continue;
 1165|  22.3k|                        }
 1166|       |
 1167|  1.80k|                        next = countr_zero(next) >> 3;
 1168|  1.80k|                        start += next;
 1169|  1.80k|                        if (start >= it) {
  ------------------
  |  Branch (1169:29): [True: 264, False: 1.54k]
  ------------------
 1170|    264|                           break;
 1171|    264|                        }
 1172|       |
 1173|  1.54k|                        if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1173:29): [True: 27, False: 1.51k]
  ------------------
 1174|     27|                           ctx.error = error_code::syntax_error;
 1175|     27|                           return;
 1176|     27|                        }
 1177|  1.51k|                        ++start; // skip the escape
 1178|  1.51k|                        if (*start == 'u') {
  ------------------
  |  Branch (1178:29): [True: 1.06k, False: 454]
  ------------------
 1179|  1.06k|                           ++start;
 1180|  1.06k|                           p += next;
 1181|  1.06k|                           const auto mark = start;
 1182|  1.06k|                           const auto offset = handle_unicode_code_point(start, p, end);
 1183|  1.06k|                           if (offset == 0) [[unlikely]] {
  ------------------
  |  Branch (1183:32): [True: 52, False: 1.01k]
  ------------------
 1184|     52|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1185|     52|                              return;
 1186|     52|                           }
 1187|  1.01k|                           n += offset;
 1188|       |                           // escape + u + unicode code points
 1189|  1.01k|                           n -= 2 + uint32_t(start - mark);
 1190|  1.01k|                        }
 1191|    454|                        else {
 1192|    454|                           p += next;
 1193|    454|                           *p = char_unescape_table[uint8_t(*start)];
 1194|    454|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1194:32): [True: 9, False: 445]
  ------------------
 1195|      9|                              ctx.error = error_code::invalid_escape;
 1196|      9|                              return;
 1197|      9|                           }
 1198|    445|                           ++p;
 1199|    445|                           ++start;
 1200|    445|                           --n;
 1201|    445|                        }
 1202|  1.51k|                     }
 1203|       |
 1204|  5.00k|                     value.resize(n);
 1205|  5.00k|                     ++it;
 1206|  5.00k|                  }
 1207|    405|                  else {
 1208|       |                     // For large inputs this case of running out of buffer is very rare
 1209|    405|                     value.resize(n);
 1210|    405|                     auto* p = value.data();
 1211|       |
 1212|    405|                     it = start;
 1213|  1.15M|                     while (it < end) [[likely]] {
  ------------------
  |  Branch (1213:29): [True: 1.15M, False: 0]
  ------------------
 1214|  1.15M|                        if (*it == '"') {
  ------------------
  |  Branch (1214:29): [True: 244, False: 1.15M]
  ------------------
 1215|    244|                           value.resize(size_t(p - value.data()));
 1216|    244|                           ++it;
 1217|    244|                           return;
 1218|    244|                        }
 1219|       |
 1220|  1.15M|                        if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1220:29): [True: 43, False: 1.15M]
  ------------------
 1221|     43|                           ctx.error = error_code::syntax_error;
 1222|     43|                           return;
 1223|     43|                        }
 1224|       |
 1225|  1.15M|                        *p = *it;
 1226|       |
 1227|  1.15M|                        if (*it == '\\') {
  ------------------
  |  Branch (1227:29): [True: 2.26k, False: 1.15M]
  ------------------
 1228|  2.26k|                           ++it; // skip the escape
 1229|  2.26k|                           if (*it == 'u') {
  ------------------
  |  Branch (1229:32): [True: 1.28k, False: 979]
  ------------------
 1230|  1.28k|                              ++it;
 1231|  1.28k|                              if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1231:35): [True: 97, False: 1.18k]
  ------------------
 1232|     97|                                 ctx.error = error_code::unicode_escape_conversion_failure;
 1233|     97|                                 return;
 1234|     97|                              }
 1235|  1.28k|                           }
 1236|    979|                           else {
 1237|    979|                              *p = char_unescape_table[uint8_t(*it)];
 1238|    979|                              if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1238:35): [True: 21, False: 958]
  ------------------
 1239|     21|                                 ctx.error = error_code::invalid_escape;
 1240|     21|                                 return;
 1241|     21|                              }
 1242|    958|                              ++p;
 1243|    958|                              ++it;
 1244|    958|                           }
 1245|  2.26k|                        }
 1246|  1.15M|                        else {
 1247|  1.15M|                           ++it;
 1248|  1.15M|                           ++p;
 1249|  1.15M|                        }
 1250|  1.15M|                     }
 1251|       |
 1252|      0|                     ctx.error = error_code::unexpected_end;
 1253|      0|                  }
 1254|  5.49k|               }
 1255|    652|               else {
 1256|       |                  // For short strings
 1257|       |
 1258|    652|                  std::array<char, 8> buffer{};
 1259|       |
 1260|    652|                  auto* p = buffer.data();
 1261|    652|                  const auto* const utf8_start = it;
 1262|       |
 1263|  1.59k|                  while (it < end) [[likely]] {
  ------------------
  |  Branch (1263:26): [True: 1.44k, False: 149]
  ------------------
 1264|  1.44k|                     *p = *it;
 1265|  1.44k|                     if (*it == '"') {
  ------------------
  |  Branch (1265:26): [True: 385, False: 1.06k]
  ------------------
 1266|    385|                        if (validate_utf8_span<Opts>(ctx, utf8_start, it)) [[unlikely]] {
  ------------------
  |  Branch (1266:29): [True: 94, False: 291]
  ------------------
 1267|     94|                           return;
 1268|     94|                        }
 1269|    291|                        const size_t n = size_t(p - buffer.data());
 1270|    291|#if __has_cpp_attribute(assume) >= 202207L
 1271|    291|                        [[assume(n <= sizeof(buffer))]];
 1272|    291|#endif
 1273|    291|                        value.assign(buffer.data(), n);
 1274|    291|                        ++it;
 1275|    291|                        if constexpr (not Opts.null_terminated) {
 1276|    291|                           if (it == end) {
  ------------------
  |  Branch (1276:32): [True: 145, False: 146]
  ------------------
 1277|    145|                              ctx.error = error_code::end_reached;
 1278|    145|                              return;
 1279|    145|                           }
 1280|    291|                        }
 1281|    146|                        return;
 1282|    385|                     }
 1283|  1.06k|                     else if (*it == '\\') {
  ------------------
  |  Branch (1283:31): [True: 170, False: 891]
  ------------------
 1284|    170|                        ++it; // skip the escape
 1285|    170|                        if constexpr (not Opts.null_terminated) {
 1286|    170|                           if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1286:32): [True: 2, False: 168]
  ------------------
 1287|      2|                              ctx.error = error_code::unexpected_end;
 1288|      2|                              return;
 1289|      2|                           }
 1290|    170|                        }
 1291|    170|                        if (*it == 'u') {
  ------------------
  |  Branch (1291:29): [True: 114, False: 56]
  ------------------
 1292|    114|                           ++it;
 1293|    114|                           if constexpr (not Opts.null_terminated) {
 1294|    114|                              if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1294:35): [True: 2, False: 112]
  ------------------
 1295|      2|                                 ctx.error = error_code::unexpected_end;
 1296|      2|                                 return;
 1297|      2|                              }
 1298|    114|                           }
 1299|    114|                           if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1299:32): [True: 59, False: 55]
  ------------------
 1300|     59|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1301|     59|                              return;
 1302|     59|                           }
 1303|    114|                        }
 1304|     56|                        else {
 1305|     56|                           *p = char_unescape_table[uint8_t(*it)];
 1306|     56|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1306:32): [True: 12, False: 44]
  ------------------
 1307|     12|                              ctx.error = error_code::invalid_escape;
 1308|     12|                              return;
 1309|     12|                           }
 1310|     44|                           ++p;
 1311|     44|                           ++it;
 1312|     44|                        }
 1313|    170|                     }
 1314|    891|                     else if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1314:31): [True: 47, False: 844]
  ------------------
 1315|     47|                        ctx.error = error_code::syntax_error;
 1316|     47|                        return;
 1317|     47|                     }
 1318|    844|                     else {
 1319|    844|                        ++it;
 1320|    844|                        ++p;
 1321|    844|                     }
 1322|  1.44k|                  }
 1323|       |
 1324|    149|                  ctx.error = error_code::unexpected_end;
 1325|    149|               }
 1326|       |            }
 1327|       |            else {
 1328|       |               // raw_string
 1329|       |               auto start = it;
 1330|       |               skip_string_view(ctx, it, end);
 1331|       |               if (bool(ctx.error)) [[unlikely]]
 1332|       |                  return;
 1333|       |
 1334|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1335|       |                  return;
 1336|       |               }
 1337|       |
 1338|       |               value.assign(start, size_t(it - start));
 1339|       |               ++it;
 1340|       |            }
 1341|  6.38k|         }
 1342|  6.38k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 5.53k, False: 843]
  |  Branch (3795:38): [True: 0, False: 843]
  |  Branch (3795:51): [True: 0, False: 843]
  ------------------
 3796|  5.53k|                     return;
 3797|  5.53k|                  }
 3798|    843|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    843|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 5.53k, False: 843]
  |  Branch (3795:38): [True: 0, False: 843]
  |  Branch (3795:51): [True: 0, False: 843]
  ------------------
 3796|  5.53k|                     return;
 3797|  5.53k|                  }
 3798|    843|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    843|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 5.53k, False: 843]
  |  Branch (3795:38): [True: 0, False: 843]
  |  Branch (3795:51): [True: 0, False: 843]
  ------------------
 3796|  5.53k|                     return;
 3797|  5.53k|                  }
 3798|    843|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    843|               });
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3725|  1.38k|      {
 3726|  1.38k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3727|       |
 3728|       |         if constexpr (category_count == 0) {
 3729|       |            ctx.error = error_code::no_matching_variant_type;
 3730|       |         }
 3731|  1.38k|         else {
 3732|  1.38k|            constexpr auto N = std::variant_size_v<Variant>;
 3733|  1.38k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3734|  1.38k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3735|       |
 3736|  1.38k|            bool found_match{};
 3737|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3738|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3739|       |            // so the budget stops it and the failure already in hand is reported.
 3740|  1.38k|            bool exhausted{};
 3741|       |
 3742|       |            // First pass: const glaze types in this category
 3743|       |            if constexpr (const_count > 0) {
 3744|       |               for_each<N>([&]<size_t I>() {
 3745|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3746|       |                     return;
 3747|       |                  }
 3748|       |                  using V = std::variant_alternative_t<I, Variant>;
 3749|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3750|       |                     // run time substitute to compare to const value
 3751|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3752|       |                     auto copy_it{it};
 3753|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3754|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3755|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3756|       |                     const auto copy_depth{ctx.depth};
 3757|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3758|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3759|       |                     if (substitute == const_value) {
 3760|       |                        found_match = true;
 3761|       |                        if (!std::holds_alternative<V>(value)) {
 3762|       |                           value = V{};
 3763|       |                        }
 3764|       |                     }
 3765|       |                     else {
 3766|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3767|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3768|       |                           exhausted = true;
 3769|       |                        }
 3770|       |                        if constexpr (not Options.null_terminated) {
 3771|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3772|       |                              ctx.error = error_code::none;
 3773|       |                           }
 3774|       |                        }
 3775|       |                        it = copy_it;
 3776|       |                        rewind_depth<Options>(ctx, copy_depth);
 3777|       |                     }
 3778|       |                  }
 3779|       |               });
 3780|       |               if (found_match) {
 3781|       |                  return;
 3782|       |               }
 3783|       |            }
 3784|       |
 3785|       |            // Second pass: non-const types in this category
 3786|  1.38k|            if constexpr (non_const_count > 0) {
 3787|       |               // Track position within matching types for "is last" check.
 3788|       |               // We iterate over all variant indices but only process matching types,
 3789|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3790|       |               // the loop index directly corresponded to position in filtered set).
 3791|       |               // This has negligible cost: one increment per matching type.
 3792|  1.38k|               size_t non_const_idx = 0;
 3793|       |
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3796|  1.38k|                     return;
 3797|  1.38k|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  1.38k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  1.38k|                     auto copy_it{it};
 3801|  1.38k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  1.38k|                     if (!std::holds_alternative<V>(value)) {
 3803|  1.38k|                        value = V{};
 3804|  1.38k|                     }
 3805|  1.38k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  1.38k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|  1.38k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|  1.38k|                     }
 3809|  1.38k|                     if (!bool(ctx.error)) {
 3810|  1.38k|                        found_match = true;
 3811|  1.38k|                     }
 3812|  1.38k|                     else if constexpr (not Options.null_terminated) {
 3813|  1.38k|                        constexpr bool is_complete_type =
 3814|  1.38k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|  1.38k|                        if constexpr (is_complete_type) {
 3817|  1.38k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|  1.38k|                              found_match = true;
 3819|  1.38k|                              ctx.error = error_code::none;
 3820|  1.38k|                           }
 3821|  1.38k|                           else {
 3822|  1.38k|                              it = copy_it;
 3823|  1.38k|                              rewind_depth<Options>(ctx, copy_depth);
 3824|  1.38k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|  1.38k|                                  not variant_alternative_exhausted(ctx)) {
 3826|  1.38k|                                 ctx.error = error_code::none;
 3827|  1.38k|                              }
 3828|  1.38k|                           }
 3829|  1.38k|                        }
 3830|  1.38k|                        else {
 3831|  1.38k|                           it = copy_it;
 3832|  1.38k|                           rewind_depth<Options>(ctx, copy_depth);
 3833|  1.38k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|  1.38k|                               not variant_alternative_exhausted(ctx)) {
 3835|  1.38k|                              ctx.error = error_code::none;
 3836|  1.38k|                           }
 3837|  1.38k|                        }
 3838|  1.38k|                     }
 3839|  1.38k|                     else {
 3840|  1.38k|                        it = copy_it;
 3841|  1.38k|                        rewind_depth<Options>(ctx, copy_depth);
 3842|  1.38k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|  1.38k|                            not variant_alternative_exhausted(ctx)) {
 3844|  1.38k|                           ctx.error = error_code::none;
 3845|  1.38k|                        }
 3846|  1.38k|                     }
 3847|  1.38k|                     ++non_const_idx;
 3848|  1.38k|                  }
 3849|  1.38k|               });
 3850|  1.38k|               if (!found_match) {
  ------------------
  |  Branch (3850:20): [True: 257, False: 1.13k]
  ------------------
 3851|    257|                  if constexpr (non_const_count == 1) {
 3852|       |                     // Keep the specific error from the single type we tried
 3853|       |                  }
 3854|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3855|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3856|       |                     ctx.error = error_code::no_matching_variant_type;
 3857|       |                  }
 3858|    257|               }
 3859|       |            }
 3860|       |            else {
 3861|       |               ctx.error = error_code::no_matching_variant_type;
 3862|       |            }
 3863|  1.38k|         }
 3864|  1.38k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.38k]
  |  Branch (3795:38): [True: 0, False: 1.38k]
  |  Branch (3795:51): [True: 0, False: 1.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.38k]
  |  Branch (3795:38): [True: 0, False: 1.38k]
  |  Branch (3795:51): [True: 0, False: 1.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.38k]
  |  Branch (3795:38): [True: 0, False: 1.38k]
  |  Branch (3795:51): [True: 0, False: 1.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.38k]
  |  Branch (3795:38): [True: 0, False: 1.38k]
  |  Branch (3795:51): [True: 0, False: 1.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  1.38k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  1.38k|                     auto copy_it{it};
 3801|  1.38k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  1.38k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3802:26): [True: 1.19k, False: 194]
  ------------------
 3803|  1.19k|                        value = V{};
 3804|  1.19k|                     }
 3805|  1.38k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  1.38k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3806:26): [True: 274, False: 1.11k]
  |  Branch (3806:45): [True: 0, False: 274]
  ------------------
 3807|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|      0|                     }
 3809|  1.38k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3809:26): [True: 1.11k, False: 274]
  ------------------
 3810|  1.11k|                        found_match = true;
 3811|  1.11k|                     }
 3812|    274|                     else if constexpr (not Options.null_terminated) {
 3813|    274|                        constexpr bool is_complete_type =
 3814|    274|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
  ------------------
  |  Branch (3814:28): [Folded, False: 0]
  |  Branch (3814:40): [True: 0, Folded]
  |  Branch (3814:53): [Folded, False: 0]
  |  Branch (3814:68): [Folded, False: 0]
  |  Branch (3814:89): [Folded, False: 0]
  |  Branch (3814:103): [Folded, False: 0]
  ------------------
 3815|       |
 3816|    274|                        if constexpr (is_complete_type) {
 3817|    274|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
  ------------------
  |  Branch (3817:32): [True: 17, False: 257]
  |  Branch (3817:72): [True: 17, False: 0]
  |  Branch (3817:88): [True: 17, False: 0]
  ------------------
 3818|     17|                              found_match = true;
 3819|     17|                              ctx.error = error_code::none;
 3820|     17|                           }
 3821|    257|                           else {
 3822|    257|                              it = copy_it;
 3823|    257|                              rewind_depth<Options>(ctx, copy_depth);
 3824|    257|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3824:35): [True: 0, False: 257]
  |  Branch (3824:74): [True: 0, False: 0]
  ------------------
 3825|      0|                                  not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3825:35): [True: 0, False: 0]
  ------------------
 3826|      0|                                 ctx.error = error_code::none;
 3827|      0|                              }
 3828|    257|                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|  1.38k|                     ++non_const_idx;
 3848|  1.38k|                  }
 3849|  1.38k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  1.38k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  1.38k|         else {
   60|  1.38k|            using V = std::remove_cvref_t<T>;
   61|  1.38k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  1.38k|                                             end);
   63|  1.38k|         }
   64|  1.38k|      }
_ZN3glz4fromILj10EbE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEETkNS_6bool_tERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
  669|  1.38k|      {
  670|       |         if constexpr (check_quoted_num(Opts)) {
  671|       |            if (skip_ws<Opts>(ctx, it, end)) {
  672|       |               return;
  673|       |            }
  674|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  675|       |               return;
  676|       |            }
  677|       |         }
  678|       |
  679|       |         if constexpr (!check_ws_handled(Opts)) {
  680|       |            if (skip_ws<Opts>(ctx, it, end)) {
  681|       |               return;
  682|       |            }
  683|       |         }
  684|       |
  685|       |         if constexpr (check_bools_as_numbers(Opts)) {
  686|       |            if (*it == '1') {
  687|       |               value = true;
  688|       |               ++it;
  689|       |            }
  690|       |            else if (*it == '0') {
  691|       |               value = false;
  692|       |               ++it;
  693|       |            }
  694|       |            else {
  695|       |               ctx.error = error_code::syntax_error;
  696|       |               return;
  697|       |            }
  698|       |         }
  699|  1.38k|         else {
  700|  1.38k|            if constexpr (not check_is_padded(Opts)) {
  701|  1.38k|               if (size_t(end - it) < 4) [[unlikely]] {
  ------------------
  |  Branch (701:20): [True: 69, False: 1.31k]
  ------------------
  702|     69|                  ctx.error = error_code::expected_true_or_false;
  703|     69|                  return;
  704|     69|               }
  705|  1.38k|            }
  706|       |
  707|  1.31k|            uint32_t c;
  708|  1.38k|            static constexpr uint32_t u_true = 0b01100101'01110101'01110010'01110100;
  709|  1.38k|            static constexpr uint32_t u_fals = 0b01110011'01101100'01100001'01100110;
  710|  1.38k|            std::memcpy(&c, it, 4);
  711|       |            if constexpr (std::endian::native == std::endian::big) {
  712|       |               c = std::byteswap(c);
  713|       |            }
  714|  1.38k|            it += 4;
  715|  1.38k|            if (c == u_true) {
  ------------------
  |  Branch (715:17): [True: 862, False: 525]
  ------------------
  716|    862|               value = true;
  717|    862|            }
  718|    525|            else if (it == end) [[unlikely]] {
  ------------------
  |  Branch (718:22): [True: 66, False: 459]
  ------------------
  719|     66|               ctx.error = error_code::unexpected_end;
  720|     66|               return;
  721|     66|            }
  722|    459|            else {
  723|    459|               if (c == u_fals && (*it == 'e')) [[likely]] {
  ------------------
  |  Branch (723:20): [True: 281, False: 178]
  |  Branch (723:35): [True: 268, False: 13]
  ------------------
  724|    268|                  value = false;
  725|    268|                  ++it;
  726|    268|               }
  727|    191|               else [[unlikely]] {
  728|    191|                  ctx.error = error_code::expected_true_or_false;
  729|    191|                  return;
  730|    191|               }
  731|    459|            }
  732|  1.38k|         }
  733|       |
  734|       |         if constexpr (check_quoted_num(Opts)) {
  735|       |            if constexpr (not Opts.null_terminated) {
  736|       |               if (it == end) [[unlikely]] {
  737|       |                  ctx.error = error_code::unexpected_end;
  738|       |                  return;
  739|       |               }
  740|       |            }
  741|       |            if (match<'"'>(ctx, it)) {
  742|       |               return;
  743|       |            }
  744|       |            if constexpr (not Opts.null_terminated) {
  745|       |               if (it == end) {
  746|       |                  ctx.error = error_code::end_reached;
  747|       |                  return;
  748|       |               }
  749|       |            }
  750|       |         }
  751|  1.38k|         else {
  752|  1.38k|            if constexpr (not Opts.null_terminated) {
  753|  1.38k|               if (it == end) {
  ------------------
  |  Branch (753:20): [True: 17, False: 1.37k]
  ------------------
  754|     17|                  ctx.error = error_code::end_reached;
  755|     17|                  return;
  756|     17|               }
  757|  1.38k|            }
  758|  1.38k|         }
  759|  1.38k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.13k, False: 257]
  |  Branch (3795:38): [True: 0, False: 257]
  |  Branch (3795:51): [True: 0, False: 257]
  ------------------
 3796|  1.13k|                     return;
 3797|  1.13k|                  }
 3798|    257|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    257|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.13k, False: 257]
  |  Branch (3795:38): [True: 0, False: 257]
  |  Branch (3795:51): [True: 0, False: 257]
  ------------------
 3796|  1.13k|                     return;
 3797|  1.13k|                  }
 3798|    257|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    257|               });
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3725|  1.95M|      {
 3726|  1.95M|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3727|       |
 3728|       |         if constexpr (category_count == 0) {
 3729|       |            ctx.error = error_code::no_matching_variant_type;
 3730|       |         }
 3731|  1.95M|         else {
 3732|  1.95M|            constexpr auto N = std::variant_size_v<Variant>;
 3733|  1.95M|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3734|  1.95M|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3735|       |
 3736|  1.95M|            bool found_match{};
 3737|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3738|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3739|       |            // so the budget stops it and the failure already in hand is reported.
 3740|  1.95M|            bool exhausted{};
 3741|       |
 3742|       |            // First pass: const glaze types in this category
 3743|       |            if constexpr (const_count > 0) {
 3744|       |               for_each<N>([&]<size_t I>() {
 3745|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3746|       |                     return;
 3747|       |                  }
 3748|       |                  using V = std::variant_alternative_t<I, Variant>;
 3749|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3750|       |                     // run time substitute to compare to const value
 3751|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3752|       |                     auto copy_it{it};
 3753|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3754|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3755|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3756|       |                     const auto copy_depth{ctx.depth};
 3757|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3758|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3759|       |                     if (substitute == const_value) {
 3760|       |                        found_match = true;
 3761|       |                        if (!std::holds_alternative<V>(value)) {
 3762|       |                           value = V{};
 3763|       |                        }
 3764|       |                     }
 3765|       |                     else {
 3766|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3767|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3768|       |                           exhausted = true;
 3769|       |                        }
 3770|       |                        if constexpr (not Options.null_terminated) {
 3771|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3772|       |                              ctx.error = error_code::none;
 3773|       |                           }
 3774|       |                        }
 3775|       |                        it = copy_it;
 3776|       |                        rewind_depth<Options>(ctx, copy_depth);
 3777|       |                     }
 3778|       |                  }
 3779|       |               });
 3780|       |               if (found_match) {
 3781|       |                  return;
 3782|       |               }
 3783|       |            }
 3784|       |
 3785|       |            // Second pass: non-const types in this category
 3786|  1.95M|            if constexpr (non_const_count > 0) {
 3787|       |               // Track position within matching types for "is last" check.
 3788|       |               // We iterate over all variant indices but only process matching types,
 3789|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3790|       |               // the loop index directly corresponded to position in filtered set).
 3791|       |               // This has negligible cost: one increment per matching type.
 3792|  1.95M|               size_t non_const_idx = 0;
 3793|       |
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.95M|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  1.95M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  1.95M|                     auto copy_it{it};
 3801|  1.95M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  1.95M|                     if (!std::holds_alternative<V>(value)) {
 3803|  1.95M|                        value = V{};
 3804|  1.95M|                     }
 3805|  1.95M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  1.95M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|  1.95M|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|  1.95M|                     }
 3809|  1.95M|                     if (!bool(ctx.error)) {
 3810|  1.95M|                        found_match = true;
 3811|  1.95M|                     }
 3812|  1.95M|                     else if constexpr (not Options.null_terminated) {
 3813|  1.95M|                        constexpr bool is_complete_type =
 3814|  1.95M|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|  1.95M|                        if constexpr (is_complete_type) {
 3817|  1.95M|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|  1.95M|                              found_match = true;
 3819|  1.95M|                              ctx.error = error_code::none;
 3820|  1.95M|                           }
 3821|  1.95M|                           else {
 3822|  1.95M|                              it = copy_it;
 3823|  1.95M|                              rewind_depth<Options>(ctx, copy_depth);
 3824|  1.95M|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|  1.95M|                                  not variant_alternative_exhausted(ctx)) {
 3826|  1.95M|                                 ctx.error = error_code::none;
 3827|  1.95M|                              }
 3828|  1.95M|                           }
 3829|  1.95M|                        }
 3830|  1.95M|                        else {
 3831|  1.95M|                           it = copy_it;
 3832|  1.95M|                           rewind_depth<Options>(ctx, copy_depth);
 3833|  1.95M|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|  1.95M|                               not variant_alternative_exhausted(ctx)) {
 3835|  1.95M|                              ctx.error = error_code::none;
 3836|  1.95M|                           }
 3837|  1.95M|                        }
 3838|  1.95M|                     }
 3839|  1.95M|                     else {
 3840|  1.95M|                        it = copy_it;
 3841|  1.95M|                        rewind_depth<Options>(ctx, copy_depth);
 3842|  1.95M|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|  1.95M|                            not variant_alternative_exhausted(ctx)) {
 3844|  1.95M|                           ctx.error = error_code::none;
 3845|  1.95M|                        }
 3846|  1.95M|                     }
 3847|  1.95M|                     ++non_const_idx;
 3848|  1.95M|                  }
 3849|  1.95M|               });
 3850|  1.95M|               if (!found_match) {
  ------------------
  |  Branch (3850:20): [True: 1.55k, False: 1.95M]
  ------------------
 3851|  1.55k|                  if constexpr (non_const_count == 1) {
 3852|       |                     // Keep the specific error from the single type we tried
 3853|       |                  }
 3854|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3855|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3856|       |                     ctx.error = error_code::no_matching_variant_type;
 3857|       |                  }
 3858|  1.55k|               }
 3859|       |            }
 3860|       |            else {
 3861|       |               ctx.error = error_code::no_matching_variant_type;
 3862|       |            }
 3863|  1.95M|         }
 3864|  1.95M|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.95M]
  |  Branch (3795:38): [True: 0, False: 1.95M]
  |  Branch (3795:51): [True: 0, False: 1.95M]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.95M|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.95M|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.95M]
  |  Branch (3795:38): [True: 0, False: 1.95M]
  |  Branch (3795:51): [True: 0, False: 1.95M]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.95M|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  1.95M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  1.95M|                     auto copy_it{it};
 3801|  1.95M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  1.95M|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3802:26): [True: 1.75M, False: 202k]
  ------------------
 3803|  1.75M|                        value = V{};
 3804|  1.75M|                     }
 3805|  1.95M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  1.95M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3806:26): [True: 4.32k, False: 1.94M]
  |  Branch (3806:45): [True: 0, False: 4.32k]
  ------------------
 3807|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|      0|                     }
 3809|  1.95M|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3809:26): [True: 1.94M, False: 4.32k]
  ------------------
 3810|  1.94M|                        found_match = true;
 3811|  1.94M|                     }
 3812|  4.32k|                     else if constexpr (not Options.null_terminated) {
 3813|  4.32k|                        constexpr bool is_complete_type =
 3814|  4.32k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
  ------------------
  |  Branch (3814:28): [True: 4.32k, Folded]
  |  Branch (3814:40): [Folded, False: 0]
  |  Branch (3814:53): [Folded, False: 0]
  |  Branch (3814:68): [Folded, False: 0]
  |  Branch (3814:89): [Folded, False: 0]
  |  Branch (3814:103): [Folded, False: 0]
  ------------------
 3815|       |
 3816|  4.32k|                        if constexpr (is_complete_type) {
 3817|  4.32k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
  ------------------
  |  Branch (3817:32): [True: 2.76k, False: 1.55k]
  |  Branch (3817:72): [True: 2.76k, False: 0]
  |  Branch (3817:88): [True: 2.76k, False: 0]
  ------------------
 3818|  2.76k|                              found_match = true;
 3819|  2.76k|                              ctx.error = error_code::none;
 3820|  2.76k|                           }
 3821|  1.55k|                           else {
 3822|  1.55k|                              it = copy_it;
 3823|  1.55k|                              rewind_depth<Options>(ctx, copy_depth);
 3824|  1.55k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3824:35): [True: 0, False: 1.55k]
  |  Branch (3824:74): [True: 0, False: 0]
  ------------------
 3825|      0|                                  not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3825:35): [True: 0, False: 0]
  ------------------
 3826|      0|                                 ctx.error = error_code::none;
 3827|      0|                              }
 3828|  1.55k|                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|  1.95M|                     ++non_const_idx;
 3848|  1.95M|                  }
 3849|  1.95M|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERdTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  1.95M|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  1.95M|         else {
   60|  1.95M|            using V = std::remove_cvref_t<T>;
   61|  1.95M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  1.95M|                                             end);
   63|  1.95M|         }
   64|  1.95M|      }
_ZN3glz4fromILj10EdE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERPKcRdTkNS_10is_contextERNS_7contextES5_EEvOT1_OT2_OT0_T3_:
  767|  1.95M|      {
  768|       |         if constexpr (check_quoted_num(Opts)) {
  769|       |            if (skip_ws<Opts>(ctx, it, end)) {
  770|       |               return;
  771|       |            }
  772|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  773|       |               return;
  774|       |            }
  775|       |         }
  776|       |
  777|       |         if constexpr (!check_ws_handled(Opts)) {
  778|       |            if (skip_ws<Opts>(ctx, it, end)) {
  779|       |               return;
  780|       |            }
  781|       |         }
  782|       |
  783|  1.95M|         using V = std::decay_t<decltype(value)>;
  784|       |         if constexpr (int_t<V>) {
  785|       |            static_assert(sizeof(*it) == sizeof(char));
  786|       |
  787|       |            if constexpr (Opts.null_terminated) {
  788|       |               if (not glz::atoi(value, it)) [[unlikely]] {
  789|       |                  ctx.error = error_code::parse_number_failure;
  790|       |                  return;
  791|       |               }
  792|       |            }
  793|       |            else {
  794|       |               if (not glz::atoi(value, it, end)) [[unlikely]] {
  795|       |                  ctx.error = error_code::parse_number_failure;
  796|       |                  return;
  797|       |               }
  798|       |            }
  799|       |         }
  800|  1.95M|         else {
  801|       |// float128_t requires std::from_chars for floating-point, unavailable on older Apple platforms (iOS < 16.3)
  802|  1.95M|#if !defined(_LIBCPP_VERSION) || defined(_LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT)
  803|       |            if constexpr (is_float128<V>) {
  804|       |               auto [ptr, ec] = std::from_chars(it, end, value);
  805|       |               if (ec != std::errc()) {
  806|       |                  ctx.error = error_code::parse_number_failure;
  807|       |                  return;
  808|       |               }
  809|       |               it = ptr;
  810|       |            }
  811|       |            else
  812|       |#endif
  813|  1.95M|            {
  814|       |               if constexpr (std::is_volatile_v<std::remove_reference_t<decltype(value)>>) {
  815|       |                  // Hardware may interact with value changes, so we parse into a temporary and assign in one
  816|       |                  // place
  817|       |                  V temp;
  818|       |                  if constexpr (is_size_optimized(Opts)) {
  819|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, temp);
  820|       |                     if (ec != std::errc{}) [[unlikely]] {
  821|       |                        ctx.error = error_code::parse_number_failure;
  822|       |                        return;
  823|       |                     }
  824|       |                     it = ptr;
  825|       |                  }
  826|       |                  else {
  827|       |                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, temp);
  828|       |                     if (ec != std::errc()) [[unlikely]] {
  829|       |                        ctx.error = error_code::parse_number_failure;
  830|       |                        return;
  831|       |                     }
  832|       |                     it = ptr;
  833|       |                  }
  834|       |                  value = temp;
  835|       |               }
  836|  1.95M|               else {
  837|       |                  if constexpr (is_size_optimized(Opts)) {
  838|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, value);
  839|       |                     if (ec != std::errc{}) [[unlikely]] {
  840|       |                        ctx.error = error_code::parse_number_failure;
  841|       |                        return;
  842|       |                     }
  843|       |                     it = ptr;
  844|       |                  }
  845|  1.95M|                  else {
  846|  1.95M|                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, value);
  847|  1.95M|                     if (ec != std::errc()) [[unlikely]] {
  ------------------
  |  Branch (847:26): [True: 1.55k, False: 1.95M]
  ------------------
  848|  1.55k|                        ctx.error = error_code::parse_number_failure;
  849|  1.55k|                        return;
  850|  1.55k|                     }
  851|  1.95M|                     it = ptr;
  852|  1.95M|                  }
  853|  1.95M|               }
  854|  1.95M|            }
  855|  1.95M|         }
  856|       |
  857|       |         if constexpr (check_quoted_num(Opts)) {
  858|       |            if constexpr (not Opts.null_terminated) {
  859|       |               if (it == end) [[unlikely]] {
  860|       |                  ctx.error = error_code::unexpected_end;
  861|       |                  return;
  862|       |               }
  863|       |            }
  864|       |            if (match<'"'>(ctx, it)) {
  865|       |               return;
  866|       |            }
  867|       |            if constexpr (not Opts.null_terminated) {
  868|       |               if (it == end) {
  869|       |                  ctx.error = error_code::end_reached;
  870|       |                  return;
  871|       |               }
  872|       |            }
  873|       |         }
  874|  1.95M|         else {
  875|  1.95M|            if constexpr (not Opts.null_terminated) {
  876|  1.95M|               if (it == end) {
  ------------------
  |  Branch (876:20): [True: 2.76k, False: 1.95M]
  ------------------
  877|  2.76k|                  ctx.error = error_code::end_reached;
  878|  2.76k|                  return;
  879|  2.76k|               }
  880|  1.95M|            }
  881|  1.95M|         }
  882|  1.95M|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.95M, False: 1.55k]
  |  Branch (3795:38): [True: 0, False: 1.55k]
  |  Branch (3795:51): [True: 0, False: 1.55k]
  ------------------
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.55k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.55k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.95M, False: 1.55k]
  |  Branch (3795:38): [True: 0, False: 1.55k]
  |  Branch (3795:51): [True: 0, False: 1.55k]
  ------------------
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.55k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.55k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.95M, False: 1.55k]
  |  Branch (3795:38): [True: 0, False: 1.55k]
  |  Branch (3795:51): [True: 0, False: 1.55k]
  ------------------
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.55k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.55k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.95M, False: 1.55k]
  |  Branch (3795:38): [True: 0, False: 1.55k]
  |  Branch (3795:51): [True: 0, False: 1.55k]
  ------------------
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.55k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.55k|               });
_ZN3glz9read_jsonITkNS_14read_supportedIL_ZNS_4JSONEEEENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_9is_bufferERKNSt3__16vectorIcNS6_9allocatorIcEEEEQnt18is_input_streamingIu20__remove_reference_tIT0_EEEENS_9error_ctxERT_OSD_:
 5266|  11.0k|   {
 5267|  11.0k|      context ctx{};
 5268|  11.0k|      return read<opts{}>(value, std::forward<Buffer>(buffer), ctx);
 5269|  11.0k|   }
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  11.0k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  11.0k|         else {
   60|  11.0k|            using V = std::remove_cvref_t<T>;
   61|  11.0k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  11.0k|                                             end);
   63|  11.0k|         }
   64|  11.0k|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  11.0k|      {
  151|  11.0k|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  11.0k|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  11.0k|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  11.0k|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 4065|  11.0k|      {
 4066|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 4067|       |            read_adjacent<Options>(value, ctx, it, end);
 4068|       |         }
 4069|  11.0k|         else {
 4070|  11.0k|            read_deduced<Options>(value, ctx, it, end);
 4071|  11.0k|         }
 4072|  11.0k|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE12read_deducedITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 4076|  11.0k|      {
 4077|  11.0k|         constexpr auto Opts = ws_handled_off<Options>();
 4078|  11.0k|         if constexpr (variant_is_auto_deducible<T>()) {
 4079|  11.0k|            if constexpr (not check_ws_handled(Options)) {
 4080|  11.0k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (4080:20): [True: 0, False: 11.0k]
  ------------------
 4081|      0|                  return;
 4082|      0|               }
 4083|  11.0k|            }
 4084|       |
 4085|  11.0k|            switch (*it) {
 4086|     15|            case '\0':
  ------------------
  |  Branch (4086:13): [True: 15, False: 11.0k]
  ------------------
 4087|     15|               ctx.error = error_code::unexpected_end;
 4088|     15|               return;
 4089|  5.03k|            case '{': {
  ------------------
  |  Branch (4089:13): [True: 5.03k, False: 6.03k]
  ------------------
 4090|       |               // This branch consumes the brace itself and hands the object to a reader with
 4091|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 4092|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 4093|       |               // the reader below.
 4094|  5.03k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (4094:20): [True: 0, False: 5.03k]
  ------------------
 4095|      0|                  return;
 4096|      0|               }
 4097|       |
 4098|  5.03k|               ++it;
 4099|       |               if constexpr (not Opts.null_terminated) {
 4100|       |                  if (it == end) [[unlikely]] {
 4101|       |                     ctx.error = error_code::unexpected_end;
 4102|       |                     return;
 4103|       |                  }
 4104|       |               }
 4105|  5.03k|               using type_counts = variant_type_count<T>;
 4106|  5.03k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 4107|       |               if constexpr (n_object_candidates < 1) {
 4108|       |                  ctx.error = error_code::no_matching_variant_type;
 4109|       |                  return;
 4110|       |               }
 4111|  5.03k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 4112|  5.03k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 4113|  5.03k|                  using V = std::variant_alternative_t<first_idx, T>;
 4114|  5.03k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4114:23): [True: 5.03k, False: 0]
  ------------------
 4115|  5.03k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 4116|  5.03k|                  return;
 4117|       |               }
 4118|       |               else {
 4119|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 4120|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 4121|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 4122|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 4123|       |
 4124|       |                  // Track if we've encountered a tag and what value it had
 4125|       |                  std::optional<size_t> tag_specified_index{};
 4126|       |
 4127|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 4128|       |                     return;
 4129|       |                  }
 4130|       |                  // Once the reader knows which alternative this object holds it may have to read
 4131|       |                  // it again from here. Anchor the position rather than keep the pointer: the scan
 4132|       |                  // below skips values, and a streaming skip refills, which moves the window out
 4133|       |                  // from under a raw pointer (see rewind_anchor).
 4134|       |                  auto start = make_rewind_anchor(ctx, it);
 4135|       |                  bool first_key = true;
 4136|       |                  // Parse bifurcation for tagged variants:
 4137|       |                  //
 4138|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 4139|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 4140|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 4141|       |                  //
 4142|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 4143|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 4144|       |                  // it advances past the trailing comma so the object parser picks up at the
 4145|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 4146|       |                  //
 4147|       |                  // One exception: if the tag name is also a field on the resolved struct
 4148|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 4149|       |                  // the struct field. This override is applied inside each std::visit lambda.
 4150|       |                  //
 4151|       |                  // Either way the rewind can fail under a streaming read: the window only holds so
 4152|       |                  // much, and an object wider than it has no start left to return to.
 4153|       |                  auto position_after_tag = [&] {
 4154|       |                     if (first_key) {
 4155|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 4156|       |                        return true;
 4157|       |                     }
 4158|       |                     return start.rewind(ctx, it, end); // tag came later, re-parse from the beginning
 4159|       |                  };
 4160|       |                  // `first_key` also answers "were we reset to the object start", which is what
 4161|       |                  // position_after_tag does for every key but the first.
 4162|       |                  for (; *it != '}'; first_key = false) {
 4163|       |                     if (!first_key) {
 4164|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 4165|       |                           return;
 4166|       |                        }
 4167|       |                     }
 4168|       |
 4169|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4170|       |                        return;
 4171|       |                     }
 4172|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4173|       |                        return;
 4174|       |                     }
 4175|       |
 4176|       |                     auto* key_start = it;
 4177|       |                     skip_string_view(ctx, it, end);
 4178|       |                     if (bool(ctx.error)) [[unlikely]]
 4179|       |                        return;
 4180|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 4181|       |                        return;
 4182|       |                     const sv key = {key_start, size_t(it - key_start)};
 4183|       |
 4184|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4185|       |                        return;
 4186|       |                     }
 4187|       |
 4188|       |                     if constexpr (deduction_key_count > 0) {
 4189|       |                        // We first check if a tag is defined and see if the key matches the tag
 4190|       |                        if constexpr (not tag_v<T>.empty()) {
 4191|       |                           if (key == tag_v<T>) {
 4192|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 4193|       |                                 return;
 4194|       |                              }
 4195|       |
 4196|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 4197|       |
 4198|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 4199|       |                              if constexpr (std::integral<id_type>) {
 4200|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4201|       |                              }
 4202|       |                              else {
 4203|       |                                 // The id is turned into an index below and never leaves this
 4204|       |                                 // reader, so the view of the window it borrows cannot outlive it.
 4205|       |                                 parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4206|       |                              }
 4207|       |                              if (bool(ctx.error)) [[unlikely]]
 4208|       |                                 return;
 4209|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4210|       |                                 return;
 4211|       |                              }
 4212|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4213|       |                                 ctx.error = error_code::syntax_error;
 4214|       |                                 return;
 4215|       |                              }
 4216|       |
 4217|       |                              size_t type_index;
 4218|       |                              if constexpr (std::integral<id_type>) {
 4219|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4220|       |                              }
 4221|       |                              else {
 4222|       |                                 type_index = variant_id_to_index<T>::op(
 4223|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4224|       |                              }
 4225|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4226|       |                                 // Check if the deduced types include the tag-specified type
 4227|       |                                 // If not, the tag doesn't match the fields
 4228|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4229|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4230|       |                                 // Check if the tag-specified type is still possible
 4231|       |                                 const bool type_is_possible = possible_types[type_index];
 4232|       |                                 if (!type_is_possible) {
 4233|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4234|       |                                    ctx.error = error_code::no_matching_variant_type;
 4235|       |                                    return;
 4236|       |                                 }
 4237|       |
 4238|       |                                 if (!position_after_tag()) return;
 4239|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4240|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4241|       |                                 std::visit(
 4242|       |                                    [&](auto&& v) {
 4243|       |                                       using V = std::decay_t<decltype(v)>;
 4244|       |                                       constexpr bool is_object =
 4245|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4246|       |                                       if constexpr (variant_unit_alternative<V>) {
 4247|       |                                          // A unit alternative carries no data; its object holds only the
 4248|       |                                          // discriminator. Consume that body through an empty reflected object so
 4249|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4250|       |                                          detail::variant_unit_body unit_body{};
 4251|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4252|       |                                                                                             tag_literal>(unit_body,
 4253|       |                                                                                                          ctx, it, end);
 4254|       |                                       }
 4255|       |                                       else if constexpr (is_object) {
 4256|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4257|       |                                             // tag is a struct field, must re-parse
 4258|       |                                             if (!start.rewind(ctx, it, end)) return;
 4259|       |                                          }
 4260|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4261|       |                                                                                                           end);
 4262|       |                                       }
 4263|       |                                       else if constexpr (is_memory_object<V>) {
 4264|       |                                          if (!v) {
 4265|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4266|       |                                                if constexpr (requires { v.emplace(); }) {
 4267|       |                                                   v.emplace();
 4268|       |                                                }
 4269|       |                                                else {
 4270|       |                                                   v = typename V::value_type{};
 4271|       |                                                }
 4272|       |                                             }
 4273|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4274|       |                                                v = std::make_unique<typename V::element_type>();
 4275|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4276|       |                                                v = std::make_shared<typename V::element_type>();
 4277|       |                                             else if constexpr (constructible<V>) {
 4278|       |                                                v = meta_construct_v<V>();
 4279|       |                                             }
 4280|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4281|       |                                                                can_allocate_raw_pointer<Opts,
 4282|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4283|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4284|       |                                                   return;
 4285|       |                                                }
 4286|       |                                             }
 4287|       |                                             else {
 4288|       |                                                ctx.error = error_code::invalid_nullable_read;
 4289|       |                                                return;
 4290|       |                                                // Cannot read into unset nullable that is not std::optional,
 4291|       |                                                // std::unique_ptr, or std::shared_ptr
 4292|       |                                             }
 4293|       |                                          }
 4294|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4295|       |                                             // tag is a struct field, must re-parse
 4296|       |                                             if (!start.rewind(ctx, it, end)) return;
 4297|       |                                          }
 4298|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4299|       |                                             *v, ctx, it, end);
 4300|       |                                       }
 4301|       |                                       else if constexpr (custom_read<V>) {
 4302|       |                                          // Custom handlers parse the remaining body themselves and do not
 4303|       |                                          // accept the tag template parameter; the tag was already consumed.
 4304|       |                                          // This only works when the tag was the first key. If it came later,
 4305|       |                                          // we were reset to the object start and the custom handler would
 4306|       |                                          // absorb the tag, so error rather than corrupt the value.
 4307|       |                                          if (!first_key) {
 4308|       |                                             ctx.error = error_code::feature_not_supported;
 4309|       |                                             ctx.custom_error_message =
 4310|       |                                                "the tag must be the first key for a custom variant alternative";
 4311|       |                                             return;
 4312|       |                                          }
 4313|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4314|       |                                       }
 4315|       |                                    },
 4316|       |                                    value);
 4317|       |
 4318|       |                                 return; // we've decoded our target type
 4319|       |                              }
 4320|       |                              else [[unlikely]] {
 4321|       |                                 // Check if we have a default type (ids array shorter than variant)
 4322|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4323|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4324|       |                                 if constexpr (ids_size < variant_size) {
 4325|       |                                    // Use the first unlabeled type as the default
 4326|       |                                    const auto default_type_index = ids_size;
 4327|       |
 4328|       |                                    if (!position_after_tag()) return;
 4329|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4330|       |                                    if (value.index() != default_type_index)
 4331|       |                                       emplace_runtime_variant(value, default_type_index);
 4332|       |                                    std::visit(
 4333|       |                                       [&](auto&& v) {
 4334|       |                                          using V = std::decay_t<decltype(v)>;
 4335|       |                                          constexpr bool is_object =
 4336|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4337|       |                                          if constexpr (variant_unit_alternative<V>) {
 4338|       |                                             // A unit alternative carries no data; its object holds only the
 4339|       |                                             // discriminator. Consume that body through an empty reflected object so
 4340|       |                                             // unknown-key policy and terminator handling match every other
 4341|       |                                             // alternative.
 4342|       |                                             detail::variant_unit_body unit_body{};
 4343|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4344|       |                                                                                                tag_literal>(
 4345|       |                                                unit_body, ctx, it, end);
 4346|       |                                          }
 4347|       |                                          else if constexpr (is_object) {
 4348|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4349|       |                                                // tag is a struct field, must re-parse
 4350|       |                                                if (!start.rewind(ctx, it, end)) return;
 4351|       |                                             }
 4352|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4353|       |                                          }
 4354|       |                                          else if constexpr (is_memory_object<V>) {
 4355|       |                                             if (!v) {
 4356|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4357|       |                                                   if constexpr (requires { v.emplace(); }) {
 4358|       |                                                      v.emplace();
 4359|       |                                                   }
 4360|       |                                                   else {
 4361|       |                                                      v = typename V::value_type{};
 4362|       |                                                   }
 4363|       |                                                }
 4364|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4365|       |                                                   v = std::make_unique<typename V::element_type>();
 4366|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4367|       |                                                   v = std::make_shared<typename V::element_type>();
 4368|       |                                                else if constexpr (constructible<V>) {
 4369|       |                                                   v = meta_construct_v<V>();
 4370|       |                                                }
 4371|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4372|       |                                                                   can_allocate_raw_pointer<
 4373|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4374|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4375|       |                                                      return;
 4376|       |                                                   }
 4377|       |                                                }
 4378|       |                                                else {
 4379|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4380|       |                                                   return;
 4381|       |                                                }
 4382|       |                                             }
 4383|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4384|       |                                                // tag is a struct field, must re-parse
 4385|       |                                                if (!start.rewind(ctx, it, end)) return;
 4386|       |                                             }
 4387|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4388|       |                                                                                                              it, end);
 4389|       |                                          }
 4390|       |                                          else if constexpr (custom_read<V>) {
 4391|       |                                             // Custom handlers parse the remaining body themselves; this only
 4392|       |                                             // works when the tag was the first key (see above). If it came
 4393|       |                                             // later we were reset to the object start, so error rather than
 4394|       |                                             // let the custom handler absorb the tag.
 4395|       |                                             if (!first_key) {
 4396|       |                                                ctx.error = error_code::feature_not_supported;
 4397|       |                                                ctx.custom_error_message =
 4398|       |                                                   "the tag must be the first key for a custom variant alternative";
 4399|       |                                                return;
 4400|       |                                             }
 4401|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4402|       |                                          }
 4403|       |                                       },
 4404|       |                                       value);
 4405|       |
 4406|       |                                    return;
 4407|       |                                 }
 4408|       |                                 else {
 4409|       |                                    ctx.error = error_code::no_matching_variant_type;
 4410|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4411|       |                                    return;
 4412|       |                                 }
 4413|       |                              }
 4414|       |                           }
 4415|       |                        }
 4416|       |
 4417|       |                        // Inline decode_hash lookup for variant deduction
 4418|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4419|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4420|       |                        const auto deduction_index =
 4421|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4422|       |                              key.data(), key.data() + key.size(), key.size());
 4423|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4424|       |                           [[likely]] {
 4425|       |                           possible_types &= deduction_bits[deduction_index];
 4426|       |                        }
 4427|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4428|       |                           ctx.error = error_code::unknown_key;
 4429|       |                           return;
 4430|       |                        }
 4431|       |                     }
 4432|       |                     else if constexpr (not tag_v<T>.empty()) {
 4433|       |                        // empty object case for variant, if there are no normal elements
 4434|       |                        if (key == tag_v<T>) {
 4435|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4436|       |                              return;
 4437|       |                           }
 4438|       |
 4439|       |                           // The id is turned into an index below and never leaves this reader,
 4440|       |                           // so the view of the window it borrows cannot outlive that window.
 4441|       |                           std::string_view type_id{};
 4442|       |                           parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4443|       |                           if (bool(ctx.error)) [[unlikely]]
 4444|       |                              return;
 4445|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4446|       |                              return;
 4447|       |                           }
 4448|       |
 4449|       |                           const auto type_index = variant_id_to_index<T>::op(
 4450|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4451|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4452|       |                              if (!position_after_tag()) return;
 4453|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4454|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4455|       |                           }
 4456|       |                           else {
 4457|       |                              // Check if we have a default type (ids array shorter than variant)
 4458|       |                              constexpr auto ids_size = ids_v<T>.size();
 4459|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4460|       |                              if constexpr (ids_size < variant_size) {
 4461|       |                                 // Use the first unlabeled type as the default
 4462|       |                                 if (!position_after_tag()) return;
 4463|       |                                 const auto default_index = ids_size;
 4464|       |                                 tag_specified_index = default_index; // Store the default type index
 4465|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4466|       |                              }
 4467|       |                              else {
 4468|       |                                 ctx.error = error_code::no_matching_variant_type;
 4469|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4470|       |                                 return;
 4471|       |                              }
 4472|       |                           }
 4473|       |                           // Parse the type (handles tag skipping and unknown keys)
 4474|       |                           std::visit(
 4475|       |                              [&](auto&& v) {
 4476|       |                                 using V = std::decay_t<decltype(v)>;
 4477|       |                                 if constexpr (custom_read<V>) {
 4478|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4479|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4480|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4481|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4482|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4483|       |                                    // into its value, so error here rather than corrupt the result.
 4484|       |                                    if (!first_key) {
 4485|       |                                       ctx.error = error_code::feature_not_supported;
 4486|       |                                       ctx.custom_error_message =
 4487|       |                                          "the tag must be the first key for a custom variant alternative";
 4488|       |                                       return;
 4489|       |                                    }
 4490|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4491|       |                                 }
 4492|       |                                 else {
 4493|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4494|       |                                       // tag is a struct field, must re-parse
 4495|       |                                       if (!start.rewind(ctx, it, end)) return;
 4496|       |                                    }
 4497|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4498|       |                                 }
 4499|       |                              },
 4500|       |                              value);
 4501|       |                           return;
 4502|       |                        }
 4503|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4504|       |                           ctx.error = error_code::unknown_key;
 4505|       |                           return;
 4506|       |                        }
 4507|       |                        else {
 4508|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4509|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4510|       |                              return;
 4511|       |                           }
 4512|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4513|       |                           if (bool(ctx.error)) [[unlikely]]
 4514|       |                              return;
 4515|       |                           resync_window_end(ctx, end); // a streaming skip refills
 4516|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4517|       |                              return;
 4518|       |                           }
 4519|       |                           continue; // Continue loop to find the tag
 4520|       |                        }
 4521|       |                     }
 4522|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4523|       |                        ctx.error = error_code::unknown_key;
 4524|       |                        return;
 4525|       |                     }
 4526|       |
 4527|       |                     auto matching_types = possible_types.popcount();
 4528|       |                     if (matching_types == 0) {
 4529|       |                        ctx.error = error_code::no_matching_variant_type;
 4530|       |                        return;
 4531|       |                     }
 4532|       |                     // Only short-circuit for variants without tags
 4533|       |                     else if constexpr (tag_v<T>.empty()) {
 4534|       |                        if (matching_types == 1) {
 4535|       |                           if (!start.rewind(ctx, it, end)) return;
 4536|       |                           const auto type_index = possible_types.countr_zero();
 4537|       |
 4538|       |                           if (value.index() != static_cast<size_t>(type_index))
 4539|       |                              emplace_runtime_variant(value, type_index);
 4540|       |                           std::visit(
 4541|       |                              [&](auto&& v) {
 4542|       |                                 using V = std::decay_t<decltype(v)>;
 4543|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4544|       |                                 if constexpr (variant_unit_alternative<V>) {
 4545|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4546|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4547|       |                                    // terminator handling match every other alternative.
 4548|       |                                    detail::variant_unit_body unit_body{};
 4549|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4550|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4551|       |                                                                                                    end);
 4552|       |                                 }
 4553|       |                                 else if constexpr (is_object) {
 4554|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4555|       |                                 }
 4556|       |                                 else if constexpr (is_memory_object<V>) {
 4557|       |                                    if (!v) {
 4558|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4559|       |                                          if constexpr (requires { v.emplace(); }) {
 4560|       |                                             v.emplace();
 4561|       |                                          }
 4562|       |                                          else {
 4563|       |                                             v = typename V::value_type{};
 4564|       |                                          }
 4565|       |                                       }
 4566|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4567|       |                                          v = std::make_unique<typename V::element_type>();
 4568|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4569|       |                                          v = std::make_shared<typename V::element_type>();
 4570|       |                                       else if constexpr (constructible<V>) {
 4571|       |                                          v = meta_construct_v<V>();
 4572|       |                                       }
 4573|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4574|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4575|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4576|       |                                             return;
 4577|       |                                          }
 4578|       |                                       }
 4579|       |                                       else {
 4580|       |                                          ctx.error = error_code::invalid_nullable_read;
 4581|       |                                          return;
 4582|       |                                          // Cannot read into unset nullable that is not std::optional,
 4583|       |                                          // std::unique_ptr, or std::shared_ptr
 4584|       |                                       }
 4585|       |                                    }
 4586|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4587|       |                                       *v, ctx, it, end);
 4588|       |                                 }
 4589|       |                                 else if constexpr (custom_read<V>) {
 4590|       |                                    // Custom handlers parse the remaining body themselves.
 4591|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4592|       |                                 }
 4593|       |                              },
 4594|       |                              value);
 4595|       |
 4596|       |                           return; // we've decoded our target type
 4597|       |                        }
 4598|       |                     }
 4599|       |                     // For tagged variants, continue processing to validate tags
 4600|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4601|       |                        return;
 4602|       |                     }
 4603|       |
 4604|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4605|       |                     if (bool(ctx.error)) [[unlikely]]
 4606|       |                        return;
 4607|       |                     resync_window_end(ctx, end); // a streaming skip refills
 4608|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4609|       |                        return;
 4610|       |                     }
 4611|       |                  }
 4612|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4613|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4614|       |                     // After parsing all keys, check if we have multiple matching types
 4615|       |                     // If so, choose the one with the fewest fields
 4616|       |                     auto final_matching = possible_types.popcount();
 4617|       |                     if (final_matching == 0) {
 4618|       |                        ctx.error = error_code::no_matching_variant_type;
 4619|       |                     }
 4620|       |                     else if (final_matching == 1) {
 4621|       |                        // Single type remains after field deduction
 4622|       |                        const auto type_index = possible_types.countr_zero();
 4623|       |
 4624|       |                        // Validate against tag if one was specified
 4625|       |                        if (tag_specified_index.has_value() &&
 4626|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4627|       |                           ctx.error = error_code::no_matching_variant_type;
 4628|       |                           return;
 4629|       |                        }
 4630|       |
 4631|       |                        if (!start.rewind(ctx, it, end)) return;
 4632|       |                        if (value.index() != static_cast<size_t>(type_index))
 4633|       |                           emplace_runtime_variant(value, type_index);
 4634|       |                        std::visit(
 4635|       |                           [&](auto&& v) {
 4636|       |                              using V = std::decay_t<decltype(v)>;
 4637|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4638|       |                              if constexpr (variant_unit_alternative<V>) {
 4639|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4640|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4641|       |                                 // terminator handling match every other alternative.
 4642|       |                                 detail::variant_unit_body unit_body{};
 4643|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4644|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4645|       |                                                                                                 end);
 4646|       |                              }
 4647|       |                              else if constexpr (is_object) {
 4648|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4649|       |                              }
 4650|       |                              else if constexpr (is_memory_object<V>) {
 4651|       |                                 if (!v) {
 4652|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4653|       |                                       if constexpr (requires { v.emplace(); }) {
 4654|       |                                          v.emplace();
 4655|       |                                       }
 4656|       |                                       else {
 4657|       |                                          v = typename V::value_type{};
 4658|       |                                       }
 4659|       |                                    }
 4660|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4661|       |                                       v = std::make_unique<typename V::element_type>();
 4662|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4663|       |                                       v = std::make_shared<typename V::element_type>();
 4664|       |                                    else if constexpr (constructible<V>) {
 4665|       |                                       v = meta_construct_v<V>();
 4666|       |                                    }
 4667|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4668|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4669|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4670|       |                                          return;
 4671|       |                                       }
 4672|       |                                    }
 4673|       |                                    else {
 4674|       |                                       ctx.error = error_code::invalid_nullable_read;
 4675|       |                                       return;
 4676|       |                                    }
 4677|       |                                 }
 4678|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4679|       |                                                                                                               it, end);
 4680|       |                              }
 4681|       |                              else if constexpr (custom_read<V>) {
 4682|       |                                 // Custom handlers parse the remaining body themselves.
 4683|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4684|       |                              }
 4685|       |                           },
 4686|       |                           value);
 4687|       |                     }
 4688|       |                     else if (final_matching > 1) {
 4689|       |                        constexpr auto N = std::variant_size_v<T>;
 4690|       |
 4691|       |                        // Compile-time array of field counts for each variant type
 4692|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4693|       |                           return std::array<size_t, N> {
 4694|       |                              ([]<size_t J = I>() -> size_t {
 4695|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4696|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4697|       |                                    return reflect<V>::size;
 4698|       |                                 }
 4699|       |                                 else if constexpr (is_memory_object<V>) {
 4700|       |                                    using X = memory_type<V>;
 4701|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4702|       |                                       return reflect<X>::size;
 4703|       |                                    }
 4704|       |                                    else {
 4705|       |                                       return (std::numeric_limits<size_t>::max)();
 4706|       |                                    }
 4707|       |                                 }
 4708|       |                                 else {
 4709|       |                                    return (std::numeric_limits<size_t>::max)();
 4710|       |                                 }
 4711|       |                              }.template operator()<I>())...
 4712|       |                           };
 4713|       |                        }(std::make_index_sequence<N>{});
 4714|       |
 4715|       |                        // Find the type with minimum field count among the possible types
 4716|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4717|       |                        size_t chosen_index = N; // Invalid index initially
 4718|       |
 4719|       |                        for (size_t i = 0; i < N; ++i) {
 4720|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4721|       |                              min_fields = field_counts[i];
 4722|       |                              chosen_index = i;
 4723|       |                           }
 4724|       |                        }
 4725|       |
 4726|       |                        if (chosen_index < N) {
 4727|       |                           // Validate against tag if one was specified
 4728|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4729|       |                              ctx.error = error_code::no_matching_variant_type;
 4730|       |                              return;
 4731|       |                           }
 4732|       |
 4733|       |                           if (!start.rewind(ctx, it, end)) return;
 4734|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4735|       |                           std::visit(
 4736|       |                              [&](auto&& v) {
 4737|       |                                 using V = std::decay_t<decltype(v)>;
 4738|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4739|       |                                 if constexpr (variant_unit_alternative<V>) {
 4740|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4741|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4742|       |                                    // terminator handling match every other alternative.
 4743|       |                                    detail::variant_unit_body unit_body{};
 4744|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4745|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4746|       |                                                                                                    end);
 4747|       |                                 }
 4748|       |                                 else if constexpr (is_object) {
 4749|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4750|       |                                 }
 4751|       |                                 else if constexpr (is_memory_object<V>) {
 4752|       |                                    if (!v) {
 4753|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4754|       |                                          if constexpr (requires { v.emplace(); }) {
 4755|       |                                             v.emplace();
 4756|       |                                          }
 4757|       |                                          else {
 4758|       |                                             v = typename V::value_type{};
 4759|       |                                          }
 4760|       |                                       }
 4761|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4762|       |                                          v = std::make_unique<typename V::element_type>();
 4763|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4764|       |                                          v = std::make_shared<typename V::element_type>();
 4765|       |                                       else if constexpr (constructible<V>) {
 4766|       |                                          v = meta_construct_v<V>();
 4767|       |                                       }
 4768|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4769|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4770|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4771|       |                                             return;
 4772|       |                                          }
 4773|       |                                       }
 4774|       |                                       else {
 4775|       |                                          ctx.error = error_code::invalid_nullable_read;
 4776|       |                                          return;
 4777|       |                                       }
 4778|       |                                    }
 4779|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4780|       |                                       *v, ctx, it, end);
 4781|       |                                 }
 4782|       |                                 else if constexpr (custom_read<V>) {
 4783|       |                                    // Custom handlers parse the remaining body themselves.
 4784|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4785|       |                                 }
 4786|       |                              },
 4787|       |                              value);
 4788|       |                        }
 4789|       |                        else {
 4790|       |                           ctx.error = error_code::no_matching_variant_type;
 4791|       |                        }
 4792|       |                     }
 4793|       |                  }
 4794|       |                  else {
 4795|       |                     // For variants with 0 or 1 object types, use the original error handling
 4796|       |                     ctx.error = error_code::no_matching_variant_type;
 4797|       |                  }
 4798|       |               }
 4799|      0|               break;
 4800|  5.03k|            }
 4801|  2.14k|            case '[':
  ------------------
  |  Branch (4801:13): [True: 2.14k, False: 8.93k]
  ------------------
 4802|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4803|  2.14k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4804|  2.14k|               break;
 4805|  1.11k|            case '"': {
  ------------------
  |  Branch (4805:13): [True: 1.11k, False: 9.95k]
  ------------------
 4806|  1.11k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4807|  1.11k|               break;
 4808|  5.03k|            }
 4809|     82|            case 't':
  ------------------
  |  Branch (4809:13): [True: 82, False: 10.9k]
  ------------------
 4810|    188|            case 'f': {
  ------------------
  |  Branch (4810:13): [True: 106, False: 10.9k]
  ------------------
 4811|    188|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4812|    188|               break;
 4813|     82|            }
 4814|     72|            case 'n':
  ------------------
  |  Branch (4814:13): [True: 72, False: 11.0k]
  ------------------
 4815|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4816|       |                  ctx.error = error_code::no_matching_variant_type;
 4817|       |               }
 4818|     72|               else {
 4819|     72|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4820|     72|                  using V = std::variant_alternative_t<first_idx, T>;
 4821|     72|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4821:23): [True: 0, False: 72]
  ------------------
 4822|     72|                  match<"null", Opts>(ctx, it, end);
 4823|     72|               }
 4824|     72|               break;
 4825|  2.50k|            default: {
  ------------------
  |  Branch (4825:13): [True: 2.50k, False: 8.57k]
  ------------------
 4826|       |               // Not bool, string, object, or array so must be number or null
 4827|  2.50k|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4828|  2.50k|            }
 4829|  11.0k|            }
 4830|       |         }
 4831|       |         else {
 4832|       |            // For non-auto-deducible variants, try each type until one succeeds
 4833|       |            constexpr auto N = std::variant_size_v<T>;
 4834|       |            bool parsed = false;
 4835|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4836|       |
 4837|       |            for_each<N>([&]<size_t I>() {
 4838|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4839|       |
 4840|       |               auto copy_it = it;
 4841|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4842|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4843|       |               const auto copy_depth = ctx.depth;
 4844|       |
 4845|       |               // Try parsing as this type
 4846|       |               if (value.index() != I) {
 4847|       |                  emplace_runtime_variant(value, I);
 4848|       |               }
 4849|       |
 4850|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4851|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4852|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4853|       |               }
 4854|       |
 4855|       |               if (!bool(ctx.error)) {
 4856|       |                  parsed = true;
 4857|       |               }
 4858|       |               else if constexpr (not Options.null_terminated) {
 4859|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4860|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4861|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4862|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4863|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4864|       |                     parsed = true;
 4865|       |                     ctx.error = error_code::none;
 4866|       |                  }
 4867|       |                  else {
 4868|       |                     // Reset for next attempt (unless this is the last type)
 4869|       |                     it = copy_it;
 4870|       |                     rewind_depth<Options>(ctx, copy_depth);
 4871|       |                     if constexpr (I + 1 < N) {
 4872|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4873|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4874|       |                        }
 4875|       |                     }
 4876|       |                  }
 4877|       |               }
 4878|       |               else {
 4879|       |                  // Reset for next attempt (unless this is the last type)
 4880|       |                  it = copy_it;
 4881|       |                  rewind_depth<Options>(ctx, copy_depth);
 4882|       |                  if constexpr (I + 1 < N) {
 4883|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4884|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4885|       |                     }
 4886|       |                  }
 4887|       |               }
 4888|       |            });
 4889|       |         }
 4890|  11.0k|      }
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEERNS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES4_EEEETkNS_10is_contextERNS_7contextERPKcSD_EEvOT0_OT1_OT2_T3_:
   49|  25.3k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  25.3k|         else {
   60|  25.3k|            using V = std::remove_cvref_t<T>;
   61|  25.3k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  25.3k|                                             end);
   63|  25.3k|         }
   64|  25.3k|      }
_ZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_:
 3044|  25.3k|      {
 3045|  25.3k|         static constexpr auto num_members = reflect<T>::size;
 3046|       |
 3047|  25.3k|         static constexpr auto Opts = opening_handled_off<ws_handled_off<Options>()>();
 3048|       |         if constexpr (!check_opening_handled(Options)) {
 3049|       |            if constexpr (!check_ws_handled(Options)) {
 3050|       |               if (skip_ws<Opts>(ctx, it, end)) {
 3051|       |                  return;
 3052|       |               }
 3053|       |            }
 3054|       |            if (match_invalid_end<'{', Opts>(ctx, it, end)) {
 3055|       |               return;
 3056|       |            }
 3057|       |            if constexpr (not Opts.null_terminated) {
 3058|       |               if (it == end) [[unlikely]] {
 3059|       |                  ctx.error = error_code::unexpected_end;
 3060|       |                  return;
 3061|       |               }
 3062|       |            }
 3063|       |            // one nesting level (see enter_depth): counted in both modes so the limit binds,
 3064|       |            // released at each syntactic close below
 3065|       |            if (enter_depth(ctx)) [[unlikely]] {
 3066|       |               return;
 3067|       |            }
 3068|       |         }
 3069|  25.3k|         const auto ws_start = it;
 3070|  25.3k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3070:14): [True: 0, False: 25.3k]
  ------------------
 3071|      0|            return;
 3072|      0|         }
 3073|  25.3k|         const size_t ws_size = size_t(it - ws_start);
 3074|       |
 3075|       |         if constexpr ((glaze_object_t<T> || reflectable<T>) && num_members == 0 && Opts.error_on_unknown_keys) {
 3076|       |            if constexpr (not tag.sv().empty()) {
 3077|       |               if (*it == '"') {
 3078|       |                  ++it;
 3079|       |                  if constexpr (not Opts.null_terminated) {
 3080|       |                     if (it == end) [[unlikely]] {
 3081|       |                        ctx.error = error_code::unexpected_end;
 3082|       |                        return;
 3083|       |                     }
 3084|       |                  }
 3085|       |
 3086|       |                  const auto start = it;
 3087|       |                  skip_string_view(ctx, it, end);
 3088|       |                  if (bool(ctx.error)) [[unlikely]]
 3089|       |                     return;
 3090|       |                  if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3091|       |                     return;
 3092|       |                  const sv key{start, size_t(it - start)};
 3093|       |                  ++it;
 3094|       |                  if constexpr (not Opts.null_terminated) {
 3095|       |                     if (it == end) [[unlikely]] {
 3096|       |                        ctx.error = error_code::unexpected_end;
 3097|       |                        return;
 3098|       |                     }
 3099|       |                  }
 3100|       |
 3101|       |                  if (key == tag.sv()) {
 3102|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3103|       |                        return;
 3104|       |                     }
 3105|       |
 3106|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3107|       |                     if (bool(ctx.error)) [[unlikely]]
 3108|       |                        return;
 3109|       |
 3110|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3111|       |                        return;
 3112|       |                     }
 3113|       |                  }
 3114|       |                  else {
 3115|       |                     ctx.error = error_code::unknown_key;
 3116|       |                     return;
 3117|       |                  }
 3118|       |               }
 3119|       |            }
 3120|       |
 3121|       |            if (*it == '}') [[likely]] {
 3122|       |               --ctx.depth;
 3123|       |               if constexpr (glaze_object_t<T> || reflectable<T>) {
 3124|       |                  if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 3125|       |                     auto wrapper = self_constraint_v<T>(value);
 3126|       |                     from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 3127|       |                     if (bool(ctx.error)) {
 3128|       |                        return;
 3129|       |                     }
 3130|       |                  }
 3131|       |               }
 3132|       |               ++it;
 3133|       |               if constexpr (not Opts.null_terminated) {
 3134|       |                  if (it == end) {
 3135|       |                     ctx.error = error_code::end_reached;
 3136|       |                     return;
 3137|       |                  }
 3138|       |               }
 3139|       |               if constexpr (Opts.partial_read) {
 3140|       |                  ctx.error = error_code::partial_read_complete;
 3141|       |               }
 3142|       |               return;
 3143|       |            }
 3144|       |            ctx.error = error_code::unknown_key;
 3145|       |            return;
 3146|       |         }
 3147|  25.3k|         else {
 3148|  25.3k|            decltype(auto) fields = [&]() -> decltype(auto) {
 3149|  25.3k|               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 3150|  25.3k|                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 3151|  25.3k|                  return bit_array<num_members>{};
 3152|  25.3k|               }
 3153|  25.3k|               else {
 3154|  25.3k|                  return nullptr;
 3155|  25.3k|               }
 3156|  25.3k|            }();
 3157|       |
 3158|  25.3k|            size_t read_count{}; // for partial_read
 3159|       |
 3160|  25.3k|            bool first = true;
 3161|   896k|            while (true) {
  ------------------
  |  Branch (3161:20): [True: 873k, Folded]
  ------------------
 3162|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.partial_read) {
 3163|       |                  static constexpr bit_array<num_members> all_fields = [] {
 3164|       |                     bit_array<num_members> arr{};
 3165|       |                     for (size_t i = 0; i < num_members; ++i) {
 3166|       |                        arr[i] = true;
 3167|       |                     }
 3168|       |                     return arr;
 3169|       |                  }();
 3170|       |
 3171|       |                  if ((all_fields & fields) == all_fields) {
 3172|       |                     ctx.error = error_code::partial_read_complete;
 3173|       |                     --ctx.depth; // as above: an early success still closes this level
 3174|       |                     return;
 3175|       |                  }
 3176|       |               }
 3177|       |
 3178|       |               // Streaming refill point: at start of each iteration, ensure buffer has data
 3179|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 3180|       |                  if (ctx.stream.enabled()) {
 3181|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 3182|       |                     const size_t remaining = ctx.stream.size() - consumed;
 3183|       |                     // Refill when less than half of buffer remains to ensure space for next key-value pair
 3184|       |                     if (remaining <= ctx.stream.size() / 2 || it >= end) {
 3185|       |                        const char* new_it;
 3186|       |                        const char* new_end;
 3187|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 3188|       |                        it = new_it;
 3189|       |                        end = new_end;
 3190|       |                        if (it >= end && ctx.stream.at_eof()) {
 3191|       |                           ctx.error = error_code::unexpected_end;
 3192|       |                           return;
 3193|       |                        }
 3194|       |                     }
 3195|       |                  }
 3196|       |               }
 3197|       |
 3198|   873k|               if (*it == '}') {
  ------------------
  |  Branch (3198:20): [True: 2.10k, False: 871k]
  ------------------
 3199|  2.10k|                  --ctx.depth;
 3200|       |                  if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.error_on_missing_keys) {
 3201|       |                     constexpr auto req_fields = required_fields<T, Opts>();
 3202|       |                     if ((req_fields & fields) != req_fields) {
 3203|       |                        for (size_t i = 0; i < num_members; ++i) {
 3204|       |                           if (not fields[i] && req_fields[i]) {
 3205|       |                              ctx.custom_error_message = reflect<T>::keys[i];
 3206|       |                              // We just return the first missing key in order to avoid heap allocations
 3207|       |                              break;
 3208|       |                           }
 3209|       |                        }
 3210|       |
 3211|       |                        ctx.error = error_code::missing_key;
 3212|       |                        return;
 3213|       |                     }
 3214|       |                  }
 3215|       |                  if constexpr (glaze_object_t<T> || reflectable<T>) {
 3216|       |                     if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 3217|       |                        auto wrapper = self_constraint_v<T>(value);
 3218|       |                        from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 3219|       |                        if (bool(ctx.error)) {
 3220|       |                           return;
 3221|       |                        }
 3222|       |                     }
 3223|       |                  }
 3224|  2.10k|                  ++it; // Increment after checking for missing keys so errors are within buffer bounds
 3225|       |                  if constexpr (not Opts.null_terminated) {
 3226|       |                     if (it == end) {
 3227|       |                        ctx.error = error_code::end_reached;
 3228|       |                        return;
 3229|       |                     }
 3230|       |                  }
 3231|  2.10k|                  return;
 3232|  2.10k|               }
 3233|   871k|               else if (first) {
  ------------------
  |  Branch (3233:25): [True: 23.5k, False: 847k]
  ------------------
 3234|  23.5k|                  first = false;
 3235|  23.5k|               }
 3236|   847k|               else {
 3237|   847k|                  if (match_invalid_end<',', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3237:23): [True: 522, False: 847k]
  ------------------
 3238|    522|                     return;
 3239|    522|                  }
 3240|       |                  if constexpr (not Opts.null_terminated) {
 3241|       |                     if (it == end) [[unlikely]] {
 3242|       |                        ctx.error = error_code::unexpected_end;
 3243|       |                        return;
 3244|       |                     }
 3245|       |                  }
 3246|       |
 3247|       |                  if constexpr ((not Opts.minified) && (num_members > 1 || not Opts.error_on_unknown_keys) &&
 3248|       |                                (!Opts.comments)) {
 3249|       |                     if (ws_size && ws_size < size_t(end - it)) {
 3250|       |                        skip_matching_ws(ws_start, it, ws_size);
 3251|       |                     }
 3252|       |                  }
 3253|       |
 3254|   847k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3254:23): [True: 0, False: 847k]
  ------------------
 3255|      0|                     return;
 3256|      0|                  }
 3257|   847k|               }
 3258|       |
 3259|   870k|               constexpr auto reflection_type = glaze_object_t<T> || reflectable<T>;
  ------------------
  |  Branch (3259:49): [Folded, False: 0]
  |  Branch (3259:70): [Folded, False: 0]
  ------------------
 3260|       |
 3261|       |               if constexpr (reflection_type && (num_members == 0)) {
 3262|       |                  if constexpr (Opts.error_on_unknown_keys) {
 3263|       |                     static_assert(false_v<T>, "This should be unreachable");
 3264|       |                  }
 3265|       |                  else {
 3266|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 3267|       |                        return;
 3268|       |                     }
 3269|       |
 3270|       |                     // parsing to an empty object, but at this point the JSON presents keys
 3271|       |
 3272|       |                     // Unknown key handler does not unescape keys. Unknown escaped keys are
 3273|       |                     // handled by the user.
 3274|       |
 3275|       |                     const auto start = it;
 3276|       |                     skip_string_view(ctx, it, end);
 3277|       |                     if (bool(ctx.error)) [[unlikely]]
 3278|       |                        return;
 3279|       |                     if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3280|       |                        return;
 3281|       |                     const sv key{start, size_t(it - start)};
 3282|       |                     ++it;
 3283|       |                     if constexpr (not Opts.null_terminated) {
 3284|       |                        if (it == end) [[unlikely]] {
 3285|       |                           ctx.error = error_code::unexpected_end;
 3286|       |                           return;
 3287|       |                        }
 3288|       |                     }
 3289|       |
 3290|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3291|       |                        return;
 3292|       |                     }
 3293|       |
 3294|       |                     // Check if this key is the variant tag that should be skipped
 3295|       |                     if constexpr (not tag.sv().empty()) {
 3296|       |                        if (key == tag.sv()) {
 3297|       |                           // Skip the tag value
 3298|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3299|       |                           if (bool(ctx.error)) [[unlikely]]
 3300|       |                              return;
 3301|       |                           resync_window_end(ctx, end); // a streaming skip refills
 3302|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 3303|       |                              return;
 3304|       |                           }
 3305|       |                           continue;
 3306|       |                        }
 3307|       |                     }
 3308|       |
 3309|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3310|       |                     if (bool(ctx.error)) [[unlikely]]
 3311|       |                        return;
 3312|       |                     if constexpr (not Opts.null_terminated) {
 3313|       |                        if (it == end) [[unlikely]] {
 3314|       |                           ctx.error = error_code::unexpected_end;
 3315|       |                           return;
 3316|       |                        }
 3317|       |                     }
 3318|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3319|       |                        return;
 3320|       |                     }
 3321|       |                  }
 3322|       |               }
 3323|       |               else if constexpr (reflection_type) {
 3324|       |                  static_assert(bool(hash_info<T>.type));
 3325|       |
 3326|       |                  if (*it != '"') [[unlikely]] {
 3327|       |                     ctx.error = error_code::expected_quote;
 3328|       |                     return;
 3329|       |                  }
 3330|       |                  ++it;
 3331|       |                  if constexpr (not Opts.null_terminated) {
 3332|       |                     if (it == end) [[unlikely]] {
 3333|       |                        ctx.error = error_code::unexpected_end;
 3334|       |                        return;
 3335|       |                     }
 3336|       |                  }
 3337|       |
 3338|       |                  if constexpr (not tag.sv().empty() && not contains_tag<T, tag>()) {
 3339|       |                     // For tagged variants we first check to see if the key matches the tag
 3340|       |                     // We only need to do this if the tag is not part of the keys
 3341|       |
 3342|       |                     const auto start = it;
 3343|       |                     skip_string_view(ctx, it, end);
 3344|       |                     if (bool(ctx.error)) [[unlikely]]
 3345|       |                        return;
 3346|       |                     if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3347|       |                        return;
 3348|       |                     const sv key{start, size_t(it - start)};
 3349|       |                     ++it;
 3350|       |                     if constexpr (not Opts.null_terminated) {
 3351|       |                        if (it == end) [[unlikely]] {
 3352|       |                           ctx.error = error_code::unexpected_end;
 3353|       |                           return;
 3354|       |                        }
 3355|       |                     }
 3356|       |
 3357|       |                     if (key == tag.sv()) {
 3358|       |                        if (parse_ws_colon<Opts>(ctx, it, end)) {
 3359|       |                           return;
 3360|       |                        }
 3361|       |
 3362|       |                        parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3363|       |                        if (bool(ctx.error)) [[unlikely]]
 3364|       |                           return;
 3365|       |
 3366|       |                        if (skip_ws<Opts>(ctx, it, end)) {
 3367|       |                           return;
 3368|       |                        }
 3369|       |                        continue;
 3370|       |                     }
 3371|       |                     else {
 3372|       |                        it = start; // reset the iterator
 3373|       |                     }
 3374|       |                  }
 3375|       |
 3376|       |                  if constexpr (Opts.error_on_missing_keys || Opts.partial_read) {
 3377|       |                     size_t index = num_members;
 3378|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end, index);
 3379|       |                     if (bool(ctx.error)) [[unlikely]]
 3380|       |                        return;
 3381|       |                     if (index < num_members) {
 3382|       |                        fields[index] = true;
 3383|       |                     }
 3384|       |                  }
 3385|       |                  else {
 3386|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end);
 3387|       |                     if (bool(ctx.error)) [[unlikely]]
 3388|       |                        return;
 3389|       |                  }
 3390|       |               }
 3391|   870k|               else {
 3392|       |                  // For types like std::map, std::unordered_map
 3393|       |
 3394|   870k|                  auto reading = [&](auto&& key) {
 3395|   870k|                     if constexpr (Opts.partial_read) {
 3396|   870k|                        if (auto element = value.find(key); element != value.end()) {
 3397|   870k|                           ++read_count;
 3398|   870k|                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3399|   870k|                        }
 3400|   870k|                        else {
 3401|   870k|                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3402|   870k|                        }
 3403|   870k|                     }
 3404|   870k|                     else {
 3405|   870k|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3406|   870k|                     }
 3407|   870k|                  };
 3408|       |
 3409|       |                  // using Key = std::conditional_t<heterogeneous_map<T>, sv, typename T::key_type>;
 3410|   870k|                  using Key = typename T::key_type;
 3411|   870k|                  if constexpr (std::is_same_v<Key, std::string>) {
 3412|   870k|                     ctx.scratch.clear();
 3413|   870k|                     parse<JSON>::op<Opts>(ctx.scratch, ctx, it, end);
 3414|   870k|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3414:26): [True: 1.55k, False: 869k]
  ------------------
 3415|  1.55k|                        return;
 3416|       |
 3417|   869k|                     if (parse_ws_colon<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3417:26): [True: 764, False: 868k]
  ------------------
 3418|    764|                        return;
 3419|    764|                     }
 3420|       |
 3421|   868k|                     reading(ctx.scratch);
 3422|       |                     if constexpr (Opts.partial_read) {
 3423|       |                        if (read_count == value.size()) {
 3424|       |                           return;
 3425|       |                        }
 3426|       |                     }
 3427|   868k|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3427:26): [True: 20.3k, False: 848k]
  ------------------
 3428|  20.3k|                        return;
 3429|       |                  }
 3430|       |                  else if constexpr (str_t<Key>) {
 3431|       |                     Key key;
 3432|       |                     parse<JSON>::op<Opts>(key, ctx, it, end);
 3433|       |                     if (bool(ctx.error)) [[unlikely]]
 3434|       |                        return;
 3435|       |
 3436|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3437|       |                        return;
 3438|       |                     }
 3439|       |
 3440|       |                     reading(key);
 3441|       |                     if constexpr (Opts.partial_read) {
 3442|       |                        if (read_count == value.size()) {
 3443|       |                           return;
 3444|       |                        }
 3445|       |                     }
 3446|       |                     if (bool(ctx.error)) [[unlikely]]
 3447|       |                        return;
 3448|       |                  }
 3449|       |                  else {
 3450|       |                     Key key_value{};
 3451|       |                     if constexpr (is_named_enum<Key> || mimics_str_t<Key>) {
 3452|       |                        parse<JSON>::op<Opts>(key_value, ctx, it, end);
 3453|       |                     }
 3454|       |                     else if constexpr (std::is_arithmetic_v<Key>) {
 3455|       |                        // prefer over quoted_t below to avoid double parsing of quoted_t
 3456|       |                        parse<JSON>::op<opt_true<Opts, quoted_num_opt_tag{}>>(key_value, ctx, it, end);
 3457|       |                     }
 3458|       |                     else {
 3459|       |                        parse<JSON>::op<opt_false<Opts, raw_string_opt_tag{}>>(quoted_t<Key>{key_value}, ctx, it, end);
 3460|       |                     }
 3461|       |                     if (bool(ctx.error)) [[unlikely]]
 3462|       |                        return;
 3463|       |
 3464|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3465|       |                        return;
 3466|       |                     }
 3467|       |
 3468|       |                     reading(key_value);
 3469|       |                     if constexpr (Opts.partial_read) {
 3470|       |                        if (read_count == value.size()) {
 3471|       |                           return;
 3472|       |                        }
 3473|       |                     }
 3474|       |                     if (bool(ctx.error)) [[unlikely]]
 3475|       |                        return;
 3476|       |                  }
 3477|   870k|               }
 3478|       |
 3479|       |               // Streaming refill point: after parsing each key-value pair, refill if buffer is low
 3480|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 3481|       |                  if (ctx.stream.enabled()) {
 3482|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 3483|       |                     // Refill when less than 25% of buffer remains to ensure enough space for next element
 3484|       |                     if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 3485|       |                        const char* new_it;
 3486|       |                        const char* new_end;
 3487|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 3488|       |                        it = new_it;
 3489|       |                        end = new_end;
 3490|       |                        if (it >= end && ctx.stream.at_eof()) {
 3491|       |                           ctx.error = error_code::unexpected_end;
 3492|       |                           return;
 3493|       |                        }
 3494|       |                     }
 3495|       |                  }
 3496|       |               }
 3497|       |
 3498|   870k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3498:20): [True: 0, False: 870k]
  ------------------
 3499|      0|                  return;
 3500|      0|               }
 3501|   870k|            }
 3502|  25.3k|         }
 3503|  25.3k|      }
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlvE_clEv:
 3148|  25.3k|            decltype(auto) fields = [&]() -> decltype(auto) {
 3149|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 3150|       |                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 3151|       |                  return bit_array<num_members>{};
 3152|       |               }
 3153|  25.3k|               else {
 3154|  25.3k|                  return nullptr;
 3155|  25.3k|               }
 3156|  25.3k|            }();
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|   870k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|   870k|         else {
   60|   870k|            using V = std::remove_cvref_t<T>;
   61|   870k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|   870k|                                             end);
   63|   870k|         }
   64|   870k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEQntcl15check_is_paddedTL0__EEEvRT2_OT3_OT0_T1_:
 1043|   870k|      {
 1044|       |         if constexpr (check_string_as_number(Opts)) {
 1045|       |            auto start = it;
 1046|       |            skip_number<Opts>(ctx, it, end);
 1047|       |            if (bool(ctx.error)) [[unlikely]] {
 1048|       |               return;
 1049|       |            }
 1050|       |            if (start == it) [[unlikely]] {
 1051|       |               ctx.error = error_code::parse_number_failure;
 1052|       |               return;
 1053|       |            }
 1054|       |            value.append(start, size_t(it - start));
 1055|       |         }
 1056|   870k|         else {
 1057|   870k|            if constexpr (!check_opening_handled(Opts)) {
 1058|   870k|               if constexpr (!check_ws_handled(Opts)) {
 1059|   870k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (1059:23): [True: 0, False: 870k]
  ------------------
 1060|      0|                     return;
 1061|      0|                  }
 1062|   870k|               }
 1063|       |
 1064|   870k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (1064:20): [True: 389, False: 870k]
  ------------------
 1065|    389|                  return;
 1066|    389|               }
 1067|   870k|            }
 1068|       |
 1069|   870k|            if constexpr (not check_raw_string(Opts)) {
 1070|   870k|               static constexpr auto string_padding_bytes = 8;
 1071|       |
 1072|   870k|               if (size_t(end - it) >= 8) {
  ------------------
  |  Branch (1072:20): [True: 868k, False: 2.53k]
  ------------------
 1073|   868k|                  auto start = it;
 1074|   868k|                  uint64_t ascii_acc{};
 1075|   868k|                  const auto end8 = end - 8;
 1076|  4.47M|                  while (true) {
  ------------------
  |  Branch (1076:26): [True: 4.47M, Folded]
  ------------------
 1077|  4.47M|                     if (it >= end8) [[unlikely]] {
  ------------------
  |  Branch (1077:26): [True: 894, False: 4.47M]
  ------------------
 1078|    894|                        break;
 1079|    894|                     }
 1080|       |
 1081|  4.47M|                     uint64_t chunk;
 1082|  4.47M|                     std::memcpy(&chunk, it, 8);
 1083|       |                     if constexpr (std::endian::native == std::endian::big) {
 1084|       |                        chunk = std::byteswap(chunk);
 1085|       |                     }
 1086|  4.47M|                     ascii_acc |= chunk;
 1087|  4.47M|                     const uint64_t test_chars = has_quote(chunk);
 1088|  4.47M|                     if (test_chars) {
  ------------------
  |  Branch (1088:26): [True: 868k, False: 3.60M]
  ------------------
 1089|   868k|                        it += (countr_zero(test_chars) >> 3);
 1090|       |
 1091|   868k|                        auto* prev = it - 1;
 1092|   870k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1092:32): [True: 2.10k, False: 868k]
  ------------------
 1093|  2.10k|                           --prev;
 1094|  2.10k|                        }
 1095|   868k|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1095:29): [True: 867k, False: 1.16k]
  ------------------
 1096|   867k|                           goto continue_decode;
 1097|   867k|                        }
 1098|  1.16k|                        ++it; // skip the escaped quote
 1099|  1.16k|                     }
 1100|  3.60M|                     else {
 1101|  3.60M|                        it += 8;
 1102|  3.60M|                     }
 1103|  4.47M|                  }
 1104|       |
 1105|  2.53k|                  while (it[-1] == '\\') [[unlikely]] {
  ------------------
  |  Branch (1105:26): [True: 1.63k, False: 894]
  ------------------
 1106|       |                     // if we ended on an escape character then we need to rewind
 1107|       |                     // because we lost our context
 1108|  1.63k|                     --it;
 1109|  1.63k|                  }
 1110|       |
 1111|       |                  // The byte-wise tail keeps feeding the accumulator: it has to cover every byte of
 1112|       |                  // the string, or a non-ASCII byte reached here would be waved through unvalidated.
 1113|  4.85k|                  for (; it < end; ++it) {
  ------------------
  |  Branch (1113:26): [True: 4.66k, False: 190]
  ------------------
 1114|  4.66k|                     ascii_acc |= uint8_t(*it);
 1115|  4.66k|                     if (*it == '"') {
  ------------------
  |  Branch (1115:26): [True: 756, False: 3.91k]
  ------------------
 1116|    756|                        auto* prev = it - 1;
 1117|  1.54k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1117:32): [True: 790, False: 756]
  ------------------
 1118|    790|                           --prev;
 1119|    790|                        }
 1120|    756|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1120:29): [True: 704, False: 52]
  ------------------
 1121|    704|                           goto continue_decode;
 1122|    704|                        }
 1123|    756|                     }
 1124|  4.66k|                  }
 1125|       |
 1126|    190|                  ctx.error = error_code::unexpected_end;
 1127|    190|                  return;
 1128|       |
 1129|   868k|               continue_decode:
 1130|       |
 1131|   868k|                  if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (1131:23): [True: 198, False: 867k]
  ------------------
 1132|    198|                     return;
 1133|    198|                  }
 1134|       |
 1135|   867k|                  const auto available_padding = size_t(end - it);
 1136|   867k|                  auto n = size_t(it - start);
 1137|   867k|                  if (available_padding >= 8) [[likely]] {
  ------------------
  |  Branch (1137:23): [True: 867k, False: 780]
  ------------------
 1138|   867k|                     value.resize(n + string_padding_bytes);
 1139|       |
 1140|   867k|                     auto* p = value.data();
 1141|       |
 1142|  4.91M|                     while (true) {
  ------------------
  |  Branch (1142:29): [True: 4.91M, Folded]
  ------------------
 1143|  4.91M|                        if (start >= it) {
  ------------------
  |  Branch (1143:29): [True: 865k, False: 4.04M]
  ------------------
 1144|   865k|                           break;
 1145|   865k|                        }
 1146|       |
 1147|  4.04M|                        std::memcpy(p, start, 8);
 1148|  4.04M|                        uint64_t swar;
 1149|  4.04M|                        std::memcpy(&swar, p, 8);
 1150|       |                        if constexpr (std::endian::native == std::endian::big) {
 1151|       |                           swar = std::byteswap(swar);
 1152|       |                        }
 1153|       |
 1154|  4.04M|                        constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1155|  4.04M|                        const uint64_t lo7 = swar & lo7_mask;
 1156|  4.04M|                        const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1157|  4.04M|                        const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1158|  4.04M|                        uint64_t next = ~((backslash & less_32) | swar);
 1159|       |
 1160|  4.04M|                        next &= repeat_byte8(0b10000000);
 1161|  4.04M|                        if (next == 0) {
  ------------------
  |  Branch (1161:29): [True: 4.03M, False: 12.9k]
  ------------------
 1162|  4.03M|                           start += 8;
 1163|  4.03M|                           p += 8;
 1164|  4.03M|                           continue;
 1165|  4.03M|                        }
 1166|       |
 1167|  12.9k|                        next = countr_zero(next) >> 3;
 1168|  12.9k|                        start += next;
 1169|  12.9k|                        if (start >= it) {
  ------------------
  |  Branch (1169:29): [True: 1.21k, False: 11.7k]
  ------------------
 1170|  1.21k|                           break;
 1171|  1.21k|                        }
 1172|       |
 1173|  11.7k|                        if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1173:29): [True: 49, False: 11.6k]
  ------------------
 1174|     49|                           ctx.error = error_code::syntax_error;
 1175|     49|                           return;
 1176|     49|                        }
 1177|  11.6k|                        ++start; // skip the escape
 1178|  11.6k|                        if (*start == 'u') {
  ------------------
  |  Branch (1178:29): [True: 10.3k, False: 1.37k]
  ------------------
 1179|  10.3k|                           ++start;
 1180|  10.3k|                           p += next;
 1181|  10.3k|                           const auto mark = start;
 1182|  10.3k|                           const auto offset = handle_unicode_code_point(start, p, end);
 1183|  10.3k|                           if (offset == 0) [[unlikely]] {
  ------------------
  |  Branch (1183:32): [True: 58, False: 10.2k]
  ------------------
 1184|     58|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1185|     58|                              return;
 1186|     58|                           }
 1187|  10.2k|                           n += offset;
 1188|       |                           // escape + u + unicode code points
 1189|  10.2k|                           n -= 2 + uint32_t(start - mark);
 1190|  10.2k|                        }
 1191|  1.37k|                        else {
 1192|  1.37k|                           p += next;
 1193|  1.37k|                           *p = char_unescape_table[uint8_t(*start)];
 1194|  1.37k|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1194:32): [True: 15, False: 1.35k]
  ------------------
 1195|     15|                              ctx.error = error_code::invalid_escape;
 1196|     15|                              return;
 1197|     15|                           }
 1198|  1.35k|                           ++p;
 1199|  1.35k|                           ++start;
 1200|  1.35k|                           --n;
 1201|  1.35k|                        }
 1202|  11.6k|                     }
 1203|       |
 1204|   867k|                     value.resize(n);
 1205|   867k|                     ++it;
 1206|   867k|                  }
 1207|    780|                  else {
 1208|       |                     // For large inputs this case of running out of buffer is very rare
 1209|    780|                     value.resize(n);
 1210|    780|                     auto* p = value.data();
 1211|       |
 1212|    780|                     it = start;
 1213|  15.7k|                     while (it < end) [[likely]] {
  ------------------
  |  Branch (1213:29): [True: 15.7k, False: 0]
  ------------------
 1214|  15.7k|                        if (*it == '"') {
  ------------------
  |  Branch (1214:29): [True: 663, False: 15.1k]
  ------------------
 1215|    663|                           value.resize(size_t(p - value.data()));
 1216|    663|                           ++it;
 1217|    663|                           return;
 1218|    663|                        }
 1219|       |
 1220|  15.1k|                        if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1220:29): [True: 39, False: 15.0k]
  ------------------
 1221|     39|                           ctx.error = error_code::syntax_error;
 1222|     39|                           return;
 1223|     39|                        }
 1224|       |
 1225|  15.0k|                        *p = *it;
 1226|       |
 1227|  15.0k|                        if (*it == '\\') {
  ------------------
  |  Branch (1227:29): [True: 2.00k, False: 13.0k]
  ------------------
 1228|  2.00k|                           ++it; // skip the escape
 1229|  2.00k|                           if (*it == 'u') {
  ------------------
  |  Branch (1229:32): [True: 1.09k, False: 916]
  ------------------
 1230|  1.09k|                              ++it;
 1231|  1.09k|                              if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1231:35): [True: 67, False: 1.02k]
  ------------------
 1232|     67|                                 ctx.error = error_code::unicode_escape_conversion_failure;
 1233|     67|                                 return;
 1234|     67|                              }
 1235|  1.09k|                           }
 1236|    916|                           else {
 1237|    916|                              *p = char_unescape_table[uint8_t(*it)];
 1238|    916|                              if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1238:35): [True: 11, False: 905]
  ------------------
 1239|     11|                                 ctx.error = error_code::invalid_escape;
 1240|     11|                                 return;
 1241|     11|                              }
 1242|    905|                              ++p;
 1243|    905|                              ++it;
 1244|    905|                           }
 1245|  2.00k|                        }
 1246|  13.0k|                        else {
 1247|  13.0k|                           ++it;
 1248|  13.0k|                           ++p;
 1249|  13.0k|                        }
 1250|  15.0k|                     }
 1251|       |
 1252|      0|                     ctx.error = error_code::unexpected_end;
 1253|      0|                  }
 1254|   867k|               }
 1255|  2.53k|               else {
 1256|       |                  // For short strings
 1257|       |
 1258|  2.53k|                  std::array<char, 8> buffer{};
 1259|       |
 1260|  2.53k|                  auto* p = buffer.data();
 1261|  2.53k|                  const auto* const utf8_start = it;
 1262|       |
 1263|  5.01k|                  while (it < end) [[likely]] {
  ------------------
  |  Branch (1263:26): [True: 4.62k, False: 389]
  ------------------
 1264|  4.62k|                     *p = *it;
 1265|  4.62k|                     if (*it == '"') {
  ------------------
  |  Branch (1265:26): [True: 1.68k, False: 2.94k]
  ------------------
 1266|  1.68k|                        if (validate_utf8_span<Opts>(ctx, utf8_start, it)) [[unlikely]] {
  ------------------
  |  Branch (1266:29): [True: 70, False: 1.61k]
  ------------------
 1267|     70|                           return;
 1268|     70|                        }
 1269|  1.61k|                        const size_t n = size_t(p - buffer.data());
 1270|  1.61k|#if __has_cpp_attribute(assume) >= 202207L
 1271|  1.61k|                        [[assume(n <= sizeof(buffer))]];
 1272|  1.61k|#endif
 1273|  1.61k|                        value.assign(buffer.data(), n);
 1274|  1.61k|                        ++it;
 1275|       |                        if constexpr (not Opts.null_terminated) {
 1276|       |                           if (it == end) {
 1277|       |                              ctx.error = error_code::end_reached;
 1278|       |                              return;
 1279|       |                           }
 1280|       |                        }
 1281|  1.61k|                        return;
 1282|  1.68k|                     }
 1283|  2.94k|                     else if (*it == '\\') {
  ------------------
  |  Branch (1283:31): [True: 88, False: 2.85k]
  ------------------
 1284|     88|                        ++it; // skip the escape
 1285|       |                        if constexpr (not Opts.null_terminated) {
 1286|       |                           if (it == end) [[unlikely]] {
 1287|       |                              ctx.error = error_code::unexpected_end;
 1288|       |                              return;
 1289|       |                           }
 1290|       |                        }
 1291|     88|                        if (*it == 'u') {
  ------------------
  |  Branch (1291:29): [True: 44, False: 44]
  ------------------
 1292|     44|                           ++it;
 1293|       |                           if constexpr (not Opts.null_terminated) {
 1294|       |                              if (it == end) [[unlikely]] {
 1295|       |                                 ctx.error = error_code::unexpected_end;
 1296|       |                                 return;
 1297|       |                              }
 1298|       |                           }
 1299|     44|                           if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1299:32): [True: 9, False: 35]
  ------------------
 1300|      9|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1301|      9|                              return;
 1302|      9|                           }
 1303|     44|                        }
 1304|     44|                        else {
 1305|     44|                           *p = char_unescape_table[uint8_t(*it)];
 1306|     44|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1306:32): [True: 16, False: 28]
  ------------------
 1307|     16|                              ctx.error = error_code::invalid_escape;
 1308|     16|                              return;
 1309|     16|                           }
 1310|     28|                           ++p;
 1311|     28|                           ++it;
 1312|     28|                        }
 1313|     88|                     }
 1314|  2.85k|                     else if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1314:31): [True: 439, False: 2.41k]
  ------------------
 1315|    439|                        ctx.error = error_code::syntax_error;
 1316|    439|                        return;
 1317|    439|                     }
 1318|  2.41k|                     else {
 1319|  2.41k|                        ++it;
 1320|  2.41k|                        ++p;
 1321|  2.41k|                     }
 1322|  4.62k|                  }
 1323|       |
 1324|    389|                  ctx.error = error_code::unexpected_end;
 1325|    389|               }
 1326|       |            }
 1327|       |            else {
 1328|       |               // raw_string
 1329|       |               auto start = it;
 1330|       |               skip_string_view(ctx, it, end);
 1331|       |               if (bool(ctx.error)) [[unlikely]]
 1332|       |                  return;
 1333|       |
 1334|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1335|       |                  return;
 1336|       |               }
 1337|       |
 1338|       |               value.assign(start, size_t(it - start));
 1339|       |               ++it;
 1340|       |            }
 1341|   870k|         }
 1342|   870k|      }
_ZN3glz14parse_ws_colonITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT0_OT1_T2_:
  159|   869k|   {
  160|   869k|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (160:11): [True: 0, False: 869k]
  ------------------
  161|      0|         return true;
  162|      0|      }
  163|   869k|      if (match_invalid_end<':', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (163:11): [True: 764, False: 868k]
  ------------------
  164|    764|         return true;
  165|    764|      }
  166|   868k|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (166:11): [True: 0, False: 868k]
  ------------------
  167|      0|         return true;
  168|      0|      }
  169|   868k|      return false;
  170|   868k|   }
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlOT_E_clIRNSt3__112basic_stringIcNSS_11char_traitsIcEENSS_9allocatorIcEEEEEEDaSP_:
 3394|   868k|                  auto reading = [&](auto&& key) {
 3395|       |                     if constexpr (Opts.partial_read) {
 3396|       |                        if (auto element = value.find(key); element != value.end()) {
 3397|       |                           ++read_count;
 3398|       |                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3399|       |                        }
 3400|       |                        else {
 3401|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3402|       |                        }
 3403|       |                     }
 3404|   868k|                     else {
 3405|   868k|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3406|   868k|                     }
 3407|   868k|                  };
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  2.59M|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  2.59M|         else {
   60|  2.59M|            using V = std::remove_cvref_t<T>;
   61|  2.59M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  2.59M|                                             end);
   63|  2.59M|         }
   64|  2.59M|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  2.59M|      {
  151|  2.59M|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  2.59M|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  2.59M|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  2.59M|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 4065|  2.59M|      {
 4066|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 4067|       |            read_adjacent<Options>(value, ctx, it, end);
 4068|       |         }
 4069|  2.59M|         else {
 4070|  2.59M|            read_deduced<Options>(value, ctx, it, end);
 4071|  2.59M|         }
 4072|  2.59M|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE12read_deducedITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 4076|  2.59M|      {
 4077|  2.59M|         constexpr auto Opts = ws_handled_off<Options>();
 4078|  2.59M|         if constexpr (variant_is_auto_deducible<T>()) {
 4079|       |            if constexpr (not check_ws_handled(Options)) {
 4080|       |               if (skip_ws<Opts>(ctx, it, end)) {
 4081|       |                  return;
 4082|       |               }
 4083|       |            }
 4084|       |
 4085|  2.59M|            switch (*it) {
 4086|  1.57k|            case '\0':
  ------------------
  |  Branch (4086:13): [True: 1.57k, False: 2.59M]
  ------------------
 4087|  1.57k|               ctx.error = error_code::unexpected_end;
 4088|  1.57k|               return;
 4089|  20.2k|            case '{': {
  ------------------
  |  Branch (4089:13): [True: 20.2k, False: 2.57M]
  ------------------
 4090|       |               // This branch consumes the brace itself and hands the object to a reader with
 4091|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 4092|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 4093|       |               // the reader below.
 4094|  20.2k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (4094:20): [True: 9, False: 20.2k]
  ------------------
 4095|      9|                  return;
 4096|      9|               }
 4097|       |
 4098|  20.2k|               ++it;
 4099|       |               if constexpr (not Opts.null_terminated) {
 4100|       |                  if (it == end) [[unlikely]] {
 4101|       |                     ctx.error = error_code::unexpected_end;
 4102|       |                     return;
 4103|       |                  }
 4104|       |               }
 4105|  20.2k|               using type_counts = variant_type_count<T>;
 4106|  20.2k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 4107|       |               if constexpr (n_object_candidates < 1) {
 4108|       |                  ctx.error = error_code::no_matching_variant_type;
 4109|       |                  return;
 4110|       |               }
 4111|  20.2k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 4112|  20.2k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 4113|  20.2k|                  using V = std::variant_alternative_t<first_idx, T>;
 4114|  20.2k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4114:23): [True: 19.8k, False: 409]
  ------------------
 4115|  20.2k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 4116|  20.2k|                  return;
 4117|       |               }
 4118|       |               else {
 4119|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 4120|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 4121|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 4122|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 4123|       |
 4124|       |                  // Track if we've encountered a tag and what value it had
 4125|       |                  std::optional<size_t> tag_specified_index{};
 4126|       |
 4127|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 4128|       |                     return;
 4129|       |                  }
 4130|       |                  // Once the reader knows which alternative this object holds it may have to read
 4131|       |                  // it again from here. Anchor the position rather than keep the pointer: the scan
 4132|       |                  // below skips values, and a streaming skip refills, which moves the window out
 4133|       |                  // from under a raw pointer (see rewind_anchor).
 4134|       |                  auto start = make_rewind_anchor(ctx, it);
 4135|       |                  bool first_key = true;
 4136|       |                  // Parse bifurcation for tagged variants:
 4137|       |                  //
 4138|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 4139|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 4140|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 4141|       |                  //
 4142|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 4143|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 4144|       |                  // it advances past the trailing comma so the object parser picks up at the
 4145|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 4146|       |                  //
 4147|       |                  // One exception: if the tag name is also a field on the resolved struct
 4148|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 4149|       |                  // the struct field. This override is applied inside each std::visit lambda.
 4150|       |                  //
 4151|       |                  // Either way the rewind can fail under a streaming read: the window only holds so
 4152|       |                  // much, and an object wider than it has no start left to return to.
 4153|       |                  auto position_after_tag = [&] {
 4154|       |                     if (first_key) {
 4155|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 4156|       |                        return true;
 4157|       |                     }
 4158|       |                     return start.rewind(ctx, it, end); // tag came later, re-parse from the beginning
 4159|       |                  };
 4160|       |                  // `first_key` also answers "were we reset to the object start", which is what
 4161|       |                  // position_after_tag does for every key but the first.
 4162|       |                  for (; *it != '}'; first_key = false) {
 4163|       |                     if (!first_key) {
 4164|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 4165|       |                           return;
 4166|       |                        }
 4167|       |                     }
 4168|       |
 4169|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4170|       |                        return;
 4171|       |                     }
 4172|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4173|       |                        return;
 4174|       |                     }
 4175|       |
 4176|       |                     auto* key_start = it;
 4177|       |                     skip_string_view(ctx, it, end);
 4178|       |                     if (bool(ctx.error)) [[unlikely]]
 4179|       |                        return;
 4180|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 4181|       |                        return;
 4182|       |                     const sv key = {key_start, size_t(it - key_start)};
 4183|       |
 4184|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4185|       |                        return;
 4186|       |                     }
 4187|       |
 4188|       |                     if constexpr (deduction_key_count > 0) {
 4189|       |                        // We first check if a tag is defined and see if the key matches the tag
 4190|       |                        if constexpr (not tag_v<T>.empty()) {
 4191|       |                           if (key == tag_v<T>) {
 4192|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 4193|       |                                 return;
 4194|       |                              }
 4195|       |
 4196|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 4197|       |
 4198|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 4199|       |                              if constexpr (std::integral<id_type>) {
 4200|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4201|       |                              }
 4202|       |                              else {
 4203|       |                                 // The id is turned into an index below and never leaves this
 4204|       |                                 // reader, so the view of the window it borrows cannot outlive it.
 4205|       |                                 parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4206|       |                              }
 4207|       |                              if (bool(ctx.error)) [[unlikely]]
 4208|       |                                 return;
 4209|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4210|       |                                 return;
 4211|       |                              }
 4212|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4213|       |                                 ctx.error = error_code::syntax_error;
 4214|       |                                 return;
 4215|       |                              }
 4216|       |
 4217|       |                              size_t type_index;
 4218|       |                              if constexpr (std::integral<id_type>) {
 4219|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4220|       |                              }
 4221|       |                              else {
 4222|       |                                 type_index = variant_id_to_index<T>::op(
 4223|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4224|       |                              }
 4225|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4226|       |                                 // Check if the deduced types include the tag-specified type
 4227|       |                                 // If not, the tag doesn't match the fields
 4228|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4229|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4230|       |                                 // Check if the tag-specified type is still possible
 4231|       |                                 const bool type_is_possible = possible_types[type_index];
 4232|       |                                 if (!type_is_possible) {
 4233|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4234|       |                                    ctx.error = error_code::no_matching_variant_type;
 4235|       |                                    return;
 4236|       |                                 }
 4237|       |
 4238|       |                                 if (!position_after_tag()) return;
 4239|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4240|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4241|       |                                 std::visit(
 4242|       |                                    [&](auto&& v) {
 4243|       |                                       using V = std::decay_t<decltype(v)>;
 4244|       |                                       constexpr bool is_object =
 4245|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4246|       |                                       if constexpr (variant_unit_alternative<V>) {
 4247|       |                                          // A unit alternative carries no data; its object holds only the
 4248|       |                                          // discriminator. Consume that body through an empty reflected object so
 4249|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4250|       |                                          detail::variant_unit_body unit_body{};
 4251|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4252|       |                                                                                             tag_literal>(unit_body,
 4253|       |                                                                                                          ctx, it, end);
 4254|       |                                       }
 4255|       |                                       else if constexpr (is_object) {
 4256|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4257|       |                                             // tag is a struct field, must re-parse
 4258|       |                                             if (!start.rewind(ctx, it, end)) return;
 4259|       |                                          }
 4260|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4261|       |                                                                                                           end);
 4262|       |                                       }
 4263|       |                                       else if constexpr (is_memory_object<V>) {
 4264|       |                                          if (!v) {
 4265|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4266|       |                                                if constexpr (requires { v.emplace(); }) {
 4267|       |                                                   v.emplace();
 4268|       |                                                }
 4269|       |                                                else {
 4270|       |                                                   v = typename V::value_type{};
 4271|       |                                                }
 4272|       |                                             }
 4273|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4274|       |                                                v = std::make_unique<typename V::element_type>();
 4275|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4276|       |                                                v = std::make_shared<typename V::element_type>();
 4277|       |                                             else if constexpr (constructible<V>) {
 4278|       |                                                v = meta_construct_v<V>();
 4279|       |                                             }
 4280|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4281|       |                                                                can_allocate_raw_pointer<Opts,
 4282|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4283|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4284|       |                                                   return;
 4285|       |                                                }
 4286|       |                                             }
 4287|       |                                             else {
 4288|       |                                                ctx.error = error_code::invalid_nullable_read;
 4289|       |                                                return;
 4290|       |                                                // Cannot read into unset nullable that is not std::optional,
 4291|       |                                                // std::unique_ptr, or std::shared_ptr
 4292|       |                                             }
 4293|       |                                          }
 4294|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4295|       |                                             // tag is a struct field, must re-parse
 4296|       |                                             if (!start.rewind(ctx, it, end)) return;
 4297|       |                                          }
 4298|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4299|       |                                             *v, ctx, it, end);
 4300|       |                                       }
 4301|       |                                       else if constexpr (custom_read<V>) {
 4302|       |                                          // Custom handlers parse the remaining body themselves and do not
 4303|       |                                          // accept the tag template parameter; the tag was already consumed.
 4304|       |                                          // This only works when the tag was the first key. If it came later,
 4305|       |                                          // we were reset to the object start and the custom handler would
 4306|       |                                          // absorb the tag, so error rather than corrupt the value.
 4307|       |                                          if (!first_key) {
 4308|       |                                             ctx.error = error_code::feature_not_supported;
 4309|       |                                             ctx.custom_error_message =
 4310|       |                                                "the tag must be the first key for a custom variant alternative";
 4311|       |                                             return;
 4312|       |                                          }
 4313|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4314|       |                                       }
 4315|       |                                    },
 4316|       |                                    value);
 4317|       |
 4318|       |                                 return; // we've decoded our target type
 4319|       |                              }
 4320|       |                              else [[unlikely]] {
 4321|       |                                 // Check if we have a default type (ids array shorter than variant)
 4322|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4323|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4324|       |                                 if constexpr (ids_size < variant_size) {
 4325|       |                                    // Use the first unlabeled type as the default
 4326|       |                                    const auto default_type_index = ids_size;
 4327|       |
 4328|       |                                    if (!position_after_tag()) return;
 4329|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4330|       |                                    if (value.index() != default_type_index)
 4331|       |                                       emplace_runtime_variant(value, default_type_index);
 4332|       |                                    std::visit(
 4333|       |                                       [&](auto&& v) {
 4334|       |                                          using V = std::decay_t<decltype(v)>;
 4335|       |                                          constexpr bool is_object =
 4336|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4337|       |                                          if constexpr (variant_unit_alternative<V>) {
 4338|       |                                             // A unit alternative carries no data; its object holds only the
 4339|       |                                             // discriminator. Consume that body through an empty reflected object so
 4340|       |                                             // unknown-key policy and terminator handling match every other
 4341|       |                                             // alternative.
 4342|       |                                             detail::variant_unit_body unit_body{};
 4343|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4344|       |                                                                                                tag_literal>(
 4345|       |                                                unit_body, ctx, it, end);
 4346|       |                                          }
 4347|       |                                          else if constexpr (is_object) {
 4348|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4349|       |                                                // tag is a struct field, must re-parse
 4350|       |                                                if (!start.rewind(ctx, it, end)) return;
 4351|       |                                             }
 4352|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4353|       |                                          }
 4354|       |                                          else if constexpr (is_memory_object<V>) {
 4355|       |                                             if (!v) {
 4356|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4357|       |                                                   if constexpr (requires { v.emplace(); }) {
 4358|       |                                                      v.emplace();
 4359|       |                                                   }
 4360|       |                                                   else {
 4361|       |                                                      v = typename V::value_type{};
 4362|       |                                                   }
 4363|       |                                                }
 4364|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4365|       |                                                   v = std::make_unique<typename V::element_type>();
 4366|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4367|       |                                                   v = std::make_shared<typename V::element_type>();
 4368|       |                                                else if constexpr (constructible<V>) {
 4369|       |                                                   v = meta_construct_v<V>();
 4370|       |                                                }
 4371|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4372|       |                                                                   can_allocate_raw_pointer<
 4373|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4374|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4375|       |                                                      return;
 4376|       |                                                   }
 4377|       |                                                }
 4378|       |                                                else {
 4379|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4380|       |                                                   return;
 4381|       |                                                }
 4382|       |                                             }
 4383|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4384|       |                                                // tag is a struct field, must re-parse
 4385|       |                                                if (!start.rewind(ctx, it, end)) return;
 4386|       |                                             }
 4387|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4388|       |                                                                                                              it, end);
 4389|       |                                          }
 4390|       |                                          else if constexpr (custom_read<V>) {
 4391|       |                                             // Custom handlers parse the remaining body themselves; this only
 4392|       |                                             // works when the tag was the first key (see above). If it came
 4393|       |                                             // later we were reset to the object start, so error rather than
 4394|       |                                             // let the custom handler absorb the tag.
 4395|       |                                             if (!first_key) {
 4396|       |                                                ctx.error = error_code::feature_not_supported;
 4397|       |                                                ctx.custom_error_message =
 4398|       |                                                   "the tag must be the first key for a custom variant alternative";
 4399|       |                                                return;
 4400|       |                                             }
 4401|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4402|       |                                          }
 4403|       |                                       },
 4404|       |                                       value);
 4405|       |
 4406|       |                                    return;
 4407|       |                                 }
 4408|       |                                 else {
 4409|       |                                    ctx.error = error_code::no_matching_variant_type;
 4410|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4411|       |                                    return;
 4412|       |                                 }
 4413|       |                              }
 4414|       |                           }
 4415|       |                        }
 4416|       |
 4417|       |                        // Inline decode_hash lookup for variant deduction
 4418|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4419|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4420|       |                        const auto deduction_index =
 4421|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4422|       |                              key.data(), key.data() + key.size(), key.size());
 4423|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4424|       |                           [[likely]] {
 4425|       |                           possible_types &= deduction_bits[deduction_index];
 4426|       |                        }
 4427|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4428|       |                           ctx.error = error_code::unknown_key;
 4429|       |                           return;
 4430|       |                        }
 4431|       |                     }
 4432|       |                     else if constexpr (not tag_v<T>.empty()) {
 4433|       |                        // empty object case for variant, if there are no normal elements
 4434|       |                        if (key == tag_v<T>) {
 4435|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4436|       |                              return;
 4437|       |                           }
 4438|       |
 4439|       |                           // The id is turned into an index below and never leaves this reader,
 4440|       |                           // so the view of the window it borrows cannot outlive that window.
 4441|       |                           std::string_view type_id{};
 4442|       |                           parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4443|       |                           if (bool(ctx.error)) [[unlikely]]
 4444|       |                              return;
 4445|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4446|       |                              return;
 4447|       |                           }
 4448|       |
 4449|       |                           const auto type_index = variant_id_to_index<T>::op(
 4450|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4451|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4452|       |                              if (!position_after_tag()) return;
 4453|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4454|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4455|       |                           }
 4456|       |                           else {
 4457|       |                              // Check if we have a default type (ids array shorter than variant)
 4458|       |                              constexpr auto ids_size = ids_v<T>.size();
 4459|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4460|       |                              if constexpr (ids_size < variant_size) {
 4461|       |                                 // Use the first unlabeled type as the default
 4462|       |                                 if (!position_after_tag()) return;
 4463|       |                                 const auto default_index = ids_size;
 4464|       |                                 tag_specified_index = default_index; // Store the default type index
 4465|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4466|       |                              }
 4467|       |                              else {
 4468|       |                                 ctx.error = error_code::no_matching_variant_type;
 4469|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4470|       |                                 return;
 4471|       |                              }
 4472|       |                           }
 4473|       |                           // Parse the type (handles tag skipping and unknown keys)
 4474|       |                           std::visit(
 4475|       |                              [&](auto&& v) {
 4476|       |                                 using V = std::decay_t<decltype(v)>;
 4477|       |                                 if constexpr (custom_read<V>) {
 4478|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4479|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4480|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4481|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4482|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4483|       |                                    // into its value, so error here rather than corrupt the result.
 4484|       |                                    if (!first_key) {
 4485|       |                                       ctx.error = error_code::feature_not_supported;
 4486|       |                                       ctx.custom_error_message =
 4487|       |                                          "the tag must be the first key for a custom variant alternative";
 4488|       |                                       return;
 4489|       |                                    }
 4490|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4491|       |                                 }
 4492|       |                                 else {
 4493|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4494|       |                                       // tag is a struct field, must re-parse
 4495|       |                                       if (!start.rewind(ctx, it, end)) return;
 4496|       |                                    }
 4497|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4498|       |                                 }
 4499|       |                              },
 4500|       |                              value);
 4501|       |                           return;
 4502|       |                        }
 4503|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4504|       |                           ctx.error = error_code::unknown_key;
 4505|       |                           return;
 4506|       |                        }
 4507|       |                        else {
 4508|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4509|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4510|       |                              return;
 4511|       |                           }
 4512|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4513|       |                           if (bool(ctx.error)) [[unlikely]]
 4514|       |                              return;
 4515|       |                           resync_window_end(ctx, end); // a streaming skip refills
 4516|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4517|       |                              return;
 4518|       |                           }
 4519|       |                           continue; // Continue loop to find the tag
 4520|       |                        }
 4521|       |                     }
 4522|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4523|       |                        ctx.error = error_code::unknown_key;
 4524|       |                        return;
 4525|       |                     }
 4526|       |
 4527|       |                     auto matching_types = possible_types.popcount();
 4528|       |                     if (matching_types == 0) {
 4529|       |                        ctx.error = error_code::no_matching_variant_type;
 4530|       |                        return;
 4531|       |                     }
 4532|       |                     // Only short-circuit for variants without tags
 4533|       |                     else if constexpr (tag_v<T>.empty()) {
 4534|       |                        if (matching_types == 1) {
 4535|       |                           if (!start.rewind(ctx, it, end)) return;
 4536|       |                           const auto type_index = possible_types.countr_zero();
 4537|       |
 4538|       |                           if (value.index() != static_cast<size_t>(type_index))
 4539|       |                              emplace_runtime_variant(value, type_index);
 4540|       |                           std::visit(
 4541|       |                              [&](auto&& v) {
 4542|       |                                 using V = std::decay_t<decltype(v)>;
 4543|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4544|       |                                 if constexpr (variant_unit_alternative<V>) {
 4545|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4546|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4547|       |                                    // terminator handling match every other alternative.
 4548|       |                                    detail::variant_unit_body unit_body{};
 4549|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4550|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4551|       |                                                                                                    end);
 4552|       |                                 }
 4553|       |                                 else if constexpr (is_object) {
 4554|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4555|       |                                 }
 4556|       |                                 else if constexpr (is_memory_object<V>) {
 4557|       |                                    if (!v) {
 4558|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4559|       |                                          if constexpr (requires { v.emplace(); }) {
 4560|       |                                             v.emplace();
 4561|       |                                          }
 4562|       |                                          else {
 4563|       |                                             v = typename V::value_type{};
 4564|       |                                          }
 4565|       |                                       }
 4566|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4567|       |                                          v = std::make_unique<typename V::element_type>();
 4568|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4569|       |                                          v = std::make_shared<typename V::element_type>();
 4570|       |                                       else if constexpr (constructible<V>) {
 4571|       |                                          v = meta_construct_v<V>();
 4572|       |                                       }
 4573|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4574|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4575|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4576|       |                                             return;
 4577|       |                                          }
 4578|       |                                       }
 4579|       |                                       else {
 4580|       |                                          ctx.error = error_code::invalid_nullable_read;
 4581|       |                                          return;
 4582|       |                                          // Cannot read into unset nullable that is not std::optional,
 4583|       |                                          // std::unique_ptr, or std::shared_ptr
 4584|       |                                       }
 4585|       |                                    }
 4586|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4587|       |                                       *v, ctx, it, end);
 4588|       |                                 }
 4589|       |                                 else if constexpr (custom_read<V>) {
 4590|       |                                    // Custom handlers parse the remaining body themselves.
 4591|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4592|       |                                 }
 4593|       |                              },
 4594|       |                              value);
 4595|       |
 4596|       |                           return; // we've decoded our target type
 4597|       |                        }
 4598|       |                     }
 4599|       |                     // For tagged variants, continue processing to validate tags
 4600|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4601|       |                        return;
 4602|       |                     }
 4603|       |
 4604|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4605|       |                     if (bool(ctx.error)) [[unlikely]]
 4606|       |                        return;
 4607|       |                     resync_window_end(ctx, end); // a streaming skip refills
 4608|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4609|       |                        return;
 4610|       |                     }
 4611|       |                  }
 4612|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4613|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4614|       |                     // After parsing all keys, check if we have multiple matching types
 4615|       |                     // If so, choose the one with the fewest fields
 4616|       |                     auto final_matching = possible_types.popcount();
 4617|       |                     if (final_matching == 0) {
 4618|       |                        ctx.error = error_code::no_matching_variant_type;
 4619|       |                     }
 4620|       |                     else if (final_matching == 1) {
 4621|       |                        // Single type remains after field deduction
 4622|       |                        const auto type_index = possible_types.countr_zero();
 4623|       |
 4624|       |                        // Validate against tag if one was specified
 4625|       |                        if (tag_specified_index.has_value() &&
 4626|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4627|       |                           ctx.error = error_code::no_matching_variant_type;
 4628|       |                           return;
 4629|       |                        }
 4630|       |
 4631|       |                        if (!start.rewind(ctx, it, end)) return;
 4632|       |                        if (value.index() != static_cast<size_t>(type_index))
 4633|       |                           emplace_runtime_variant(value, type_index);
 4634|       |                        std::visit(
 4635|       |                           [&](auto&& v) {
 4636|       |                              using V = std::decay_t<decltype(v)>;
 4637|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4638|       |                              if constexpr (variant_unit_alternative<V>) {
 4639|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4640|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4641|       |                                 // terminator handling match every other alternative.
 4642|       |                                 detail::variant_unit_body unit_body{};
 4643|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4644|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4645|       |                                                                                                 end);
 4646|       |                              }
 4647|       |                              else if constexpr (is_object) {
 4648|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4649|       |                              }
 4650|       |                              else if constexpr (is_memory_object<V>) {
 4651|       |                                 if (!v) {
 4652|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4653|       |                                       if constexpr (requires { v.emplace(); }) {
 4654|       |                                          v.emplace();
 4655|       |                                       }
 4656|       |                                       else {
 4657|       |                                          v = typename V::value_type{};
 4658|       |                                       }
 4659|       |                                    }
 4660|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4661|       |                                       v = std::make_unique<typename V::element_type>();
 4662|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4663|       |                                       v = std::make_shared<typename V::element_type>();
 4664|       |                                    else if constexpr (constructible<V>) {
 4665|       |                                       v = meta_construct_v<V>();
 4666|       |                                    }
 4667|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4668|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4669|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4670|       |                                          return;
 4671|       |                                       }
 4672|       |                                    }
 4673|       |                                    else {
 4674|       |                                       ctx.error = error_code::invalid_nullable_read;
 4675|       |                                       return;
 4676|       |                                    }
 4677|       |                                 }
 4678|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4679|       |                                                                                                               it, end);
 4680|       |                              }
 4681|       |                              else if constexpr (custom_read<V>) {
 4682|       |                                 // Custom handlers parse the remaining body themselves.
 4683|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4684|       |                              }
 4685|       |                           },
 4686|       |                           value);
 4687|       |                     }
 4688|       |                     else if (final_matching > 1) {
 4689|       |                        constexpr auto N = std::variant_size_v<T>;
 4690|       |
 4691|       |                        // Compile-time array of field counts for each variant type
 4692|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4693|       |                           return std::array<size_t, N> {
 4694|       |                              ([]<size_t J = I>() -> size_t {
 4695|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4696|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4697|       |                                    return reflect<V>::size;
 4698|       |                                 }
 4699|       |                                 else if constexpr (is_memory_object<V>) {
 4700|       |                                    using X = memory_type<V>;
 4701|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4702|       |                                       return reflect<X>::size;
 4703|       |                                    }
 4704|       |                                    else {
 4705|       |                                       return (std::numeric_limits<size_t>::max)();
 4706|       |                                    }
 4707|       |                                 }
 4708|       |                                 else {
 4709|       |                                    return (std::numeric_limits<size_t>::max)();
 4710|       |                                 }
 4711|       |                              }.template operator()<I>())...
 4712|       |                           };
 4713|       |                        }(std::make_index_sequence<N>{});
 4714|       |
 4715|       |                        // Find the type with minimum field count among the possible types
 4716|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4717|       |                        size_t chosen_index = N; // Invalid index initially
 4718|       |
 4719|       |                        for (size_t i = 0; i < N; ++i) {
 4720|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4721|       |                              min_fields = field_counts[i];
 4722|       |                              chosen_index = i;
 4723|       |                           }
 4724|       |                        }
 4725|       |
 4726|       |                        if (chosen_index < N) {
 4727|       |                           // Validate against tag if one was specified
 4728|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4729|       |                              ctx.error = error_code::no_matching_variant_type;
 4730|       |                              return;
 4731|       |                           }
 4732|       |
 4733|       |                           if (!start.rewind(ctx, it, end)) return;
 4734|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4735|       |                           std::visit(
 4736|       |                              [&](auto&& v) {
 4737|       |                                 using V = std::decay_t<decltype(v)>;
 4738|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4739|       |                                 if constexpr (variant_unit_alternative<V>) {
 4740|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4741|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4742|       |                                    // terminator handling match every other alternative.
 4743|       |                                    detail::variant_unit_body unit_body{};
 4744|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4745|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4746|       |                                                                                                    end);
 4747|       |                                 }
 4748|       |                                 else if constexpr (is_object) {
 4749|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4750|       |                                 }
 4751|       |                                 else if constexpr (is_memory_object<V>) {
 4752|       |                                    if (!v) {
 4753|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4754|       |                                          if constexpr (requires { v.emplace(); }) {
 4755|       |                                             v.emplace();
 4756|       |                                          }
 4757|       |                                          else {
 4758|       |                                             v = typename V::value_type{};
 4759|       |                                          }
 4760|       |                                       }
 4761|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4762|       |                                          v = std::make_unique<typename V::element_type>();
 4763|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4764|       |                                          v = std::make_shared<typename V::element_type>();
 4765|       |                                       else if constexpr (constructible<V>) {
 4766|       |                                          v = meta_construct_v<V>();
 4767|       |                                       }
 4768|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4769|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4770|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4771|       |                                             return;
 4772|       |                                          }
 4773|       |                                       }
 4774|       |                                       else {
 4775|       |                                          ctx.error = error_code::invalid_nullable_read;
 4776|       |                                          return;
 4777|       |                                       }
 4778|       |                                    }
 4779|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4780|       |                                       *v, ctx, it, end);
 4781|       |                                 }
 4782|       |                                 else if constexpr (custom_read<V>) {
 4783|       |                                    // Custom handlers parse the remaining body themselves.
 4784|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4785|       |                                 }
 4786|       |                              },
 4787|       |                              value);
 4788|       |                        }
 4789|       |                        else {
 4790|       |                           ctx.error = error_code::no_matching_variant_type;
 4791|       |                        }
 4792|       |                     }
 4793|       |                  }
 4794|       |                  else {
 4795|       |                     // For variants with 0 or 1 object types, use the original error handling
 4796|       |                     ctx.error = error_code::no_matching_variant_type;
 4797|       |                  }
 4798|       |               }
 4799|      0|               break;
 4800|  20.2k|            }
 4801|   613k|            case '[':
  ------------------
  |  Branch (4801:13): [True: 613k, False: 1.98M]
  ------------------
 4802|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4803|   613k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4804|   613k|               break;
 4805|  5.26k|            case '"': {
  ------------------
  |  Branch (4805:13): [True: 5.26k, False: 2.58M]
  ------------------
 4806|  5.26k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4807|  5.26k|               break;
 4808|  20.2k|            }
 4809|    909|            case 't':
  ------------------
  |  Branch (4809:13): [True: 909, False: 2.59M]
  ------------------
 4810|  1.19k|            case 'f': {
  ------------------
  |  Branch (4810:13): [True: 290, False: 2.59M]
  ------------------
 4811|  1.19k|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4812|  1.19k|               break;
 4813|    909|            }
 4814|    590|            case 'n':
  ------------------
  |  Branch (4814:13): [True: 590, False: 2.59M]
  ------------------
 4815|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4816|       |                  ctx.error = error_code::no_matching_variant_type;
 4817|       |               }
 4818|    590|               else {
 4819|    590|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4820|    590|                  using V = std::variant_alternative_t<first_idx, T>;
 4821|    590|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4821:23): [True: 200, False: 390]
  ------------------
 4822|    590|                  match<"null", Opts>(ctx, it, end);
 4823|    590|               }
 4824|    590|               break;
 4825|  1.95M|            default: {
  ------------------
  |  Branch (4825:13): [True: 1.95M, False: 642k]
  ------------------
 4826|       |               // Not bool, string, object, or array so must be number or null
 4827|  1.95M|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4828|  1.95M|            }
 4829|  2.59M|            }
 4830|       |         }
 4831|       |         else {
 4832|       |            // For non-auto-deducible variants, try each type until one succeeds
 4833|       |            constexpr auto N = std::variant_size_v<T>;
 4834|       |            bool parsed = false;
 4835|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4836|       |
 4837|       |            for_each<N>([&]<size_t I>() {
 4838|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4839|       |
 4840|       |               auto copy_it = it;
 4841|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4842|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4843|       |               const auto copy_depth = ctx.depth;
 4844|       |
 4845|       |               // Try parsing as this type
 4846|       |               if (value.index() != I) {
 4847|       |                  emplace_runtime_variant(value, I);
 4848|       |               }
 4849|       |
 4850|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4851|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4852|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4853|       |               }
 4854|       |
 4855|       |               if (!bool(ctx.error)) {
 4856|       |                  parsed = true;
 4857|       |               }
 4858|       |               else if constexpr (not Options.null_terminated) {
 4859|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4860|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4861|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4862|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4863|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4864|       |                     parsed = true;
 4865|       |                     ctx.error = error_code::none;
 4866|       |                  }
 4867|       |                  else {
 4868|       |                     // Reset for next attempt (unless this is the last type)
 4869|       |                     it = copy_it;
 4870|       |                     rewind_depth<Options>(ctx, copy_depth);
 4871|       |                     if constexpr (I + 1 < N) {
 4872|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4873|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4874|       |                        }
 4875|       |                     }
 4876|       |                  }
 4877|       |               }
 4878|       |               else {
 4879|       |                  // Reset for next attempt (unless this is the last type)
 4880|       |                  it = copy_it;
 4881|       |                  rewind_depth<Options>(ctx, copy_depth);
 4882|       |                  if constexpr (I + 1 < N) {
 4883|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4884|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4885|       |                     }
 4886|       |                  }
 4887|       |               }
 4888|       |            });
 4889|       |         }
 4890|  2.59M|      }
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3725|   615k|      {
 3726|   615k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3727|       |
 3728|       |         if constexpr (category_count == 0) {
 3729|       |            ctx.error = error_code::no_matching_variant_type;
 3730|       |         }
 3731|   615k|         else {
 3732|   615k|            constexpr auto N = std::variant_size_v<Variant>;
 3733|   615k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3734|   615k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3735|       |
 3736|   615k|            bool found_match{};
 3737|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3738|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3739|       |            // so the budget stops it and the failure already in hand is reported.
 3740|   615k|            bool exhausted{};
 3741|       |
 3742|       |            // First pass: const glaze types in this category
 3743|       |            if constexpr (const_count > 0) {
 3744|       |               for_each<N>([&]<size_t I>() {
 3745|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3746|       |                     return;
 3747|       |                  }
 3748|       |                  using V = std::variant_alternative_t<I, Variant>;
 3749|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3750|       |                     // run time substitute to compare to const value
 3751|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3752|       |                     auto copy_it{it};
 3753|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3754|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3755|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3756|       |                     const auto copy_depth{ctx.depth};
 3757|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3758|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3759|       |                     if (substitute == const_value) {
 3760|       |                        found_match = true;
 3761|       |                        if (!std::holds_alternative<V>(value)) {
 3762|       |                           value = V{};
 3763|       |                        }
 3764|       |                     }
 3765|       |                     else {
 3766|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3767|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3768|       |                           exhausted = true;
 3769|       |                        }
 3770|       |                        if constexpr (not Options.null_terminated) {
 3771|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3772|       |                              ctx.error = error_code::none;
 3773|       |                           }
 3774|       |                        }
 3775|       |                        it = copy_it;
 3776|       |                        rewind_depth<Options>(ctx, copy_depth);
 3777|       |                     }
 3778|       |                  }
 3779|       |               });
 3780|       |               if (found_match) {
 3781|       |                  return;
 3782|       |               }
 3783|       |            }
 3784|       |
 3785|       |            // Second pass: non-const types in this category
 3786|   615k|            if constexpr (non_const_count > 0) {
 3787|       |               // Track position within matching types for "is last" check.
 3788|       |               // We iterate over all variant indices but only process matching types,
 3789|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3790|       |               // the loop index directly corresponded to position in filtered set).
 3791|       |               // This has negligible cost: one increment per matching type.
 3792|   615k|               size_t non_const_idx = 0;
 3793|       |
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3796|   615k|                     return;
 3797|   615k|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|   615k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|   615k|                     auto copy_it{it};
 3801|   615k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|   615k|                     if (!std::holds_alternative<V>(value)) {
 3803|   615k|                        value = V{};
 3804|   615k|                     }
 3805|   615k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|   615k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|   615k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|   615k|                     }
 3809|   615k|                     if (!bool(ctx.error)) {
 3810|   615k|                        found_match = true;
 3811|   615k|                     }
 3812|   615k|                     else if constexpr (not Options.null_terminated) {
 3813|   615k|                        constexpr bool is_complete_type =
 3814|   615k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|   615k|                        if constexpr (is_complete_type) {
 3817|   615k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|   615k|                              found_match = true;
 3819|   615k|                              ctx.error = error_code::none;
 3820|   615k|                           }
 3821|   615k|                           else {
 3822|   615k|                              it = copy_it;
 3823|   615k|                              rewind_depth<Options>(ctx, copy_depth);
 3824|   615k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|   615k|                                  not variant_alternative_exhausted(ctx)) {
 3826|   615k|                                 ctx.error = error_code::none;
 3827|   615k|                              }
 3828|   615k|                           }
 3829|   615k|                        }
 3830|   615k|                        else {
 3831|   615k|                           it = copy_it;
 3832|   615k|                           rewind_depth<Options>(ctx, copy_depth);
 3833|   615k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|   615k|                               not variant_alternative_exhausted(ctx)) {
 3835|   615k|                              ctx.error = error_code::none;
 3836|   615k|                           }
 3837|   615k|                        }
 3838|   615k|                     }
 3839|   615k|                     else {
 3840|   615k|                        it = copy_it;
 3841|   615k|                        rewind_depth<Options>(ctx, copy_depth);
 3842|   615k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|   615k|                            not variant_alternative_exhausted(ctx)) {
 3844|   615k|                           ctx.error = error_code::none;
 3845|   615k|                        }
 3846|   615k|                     }
 3847|   615k|                     ++non_const_idx;
 3848|   615k|                  }
 3849|   615k|               });
 3850|   615k|               if (!found_match) {
  ------------------
  |  Branch (3850:20): [True: 13.7k, False: 602k]
  ------------------
 3851|  13.7k|                  if constexpr (non_const_count == 1) {
 3852|       |                     // Keep the specific error from the single type we tried
 3853|       |                  }
 3854|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3855|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3856|       |                     ctx.error = error_code::no_matching_variant_type;
 3857|       |                  }
 3858|  13.7k|               }
 3859|       |            }
 3860|       |            else {
 3861|       |               ctx.error = error_code::no_matching_variant_type;
 3862|       |            }
 3863|   615k|         }
 3864|   615k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|   615k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|   615k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|   615k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|   615k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|   615k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|   615k|                     auto copy_it{it};
 3801|   615k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|   615k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3802:26): [True: 482k, False: 132k]
  ------------------
 3803|   482k|                        value = V{};
 3804|   482k|                     }
 3805|   615k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|   615k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3806:26): [True: 13.7k, False: 602k]
  |  Branch (3806:45): [True: 0, False: 13.7k]
  ------------------
 3807|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|      0|                     }
 3809|   615k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3809:26): [True: 602k, False: 13.7k]
  ------------------
 3810|   602k|                        found_match = true;
 3811|   602k|                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|  13.7k|                     else {
 3840|  13.7k|                        it = copy_it;
 3841|  13.7k|                        rewind_depth<Options>(ctx, copy_depth);
 3842|  13.7k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3842:29): [True: 0, False: 13.7k]
  |  Branch (3842:68): [True: 0, False: 0]
  ------------------
 3843|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3843:29): [True: 0, False: 0]
  ------------------
 3844|      0|                           ctx.error = error_code::none;
 3845|      0|                        }
 3846|  13.7k|                     }
 3847|   615k|                     ++non_const_idx;
 3848|   615k|                  }
 3849|   615k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS4_9allocatorIS9_EEEETkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
   49|   615k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|   615k|         else {
   60|   615k|            using V = std::remove_cvref_t<T>;
   61|   615k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|   615k|                                             end);
   63|   615k|         }
   64|   615k|      }
_ZN3glz4fromILj10ENSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS1_9allocatorIS6_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERS9_TkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
 2308|   615k|      {
 2309|   615k|         constexpr auto Opts = ws_handled_off<Options>();
 2310|       |         if constexpr (!check_ws_handled(Options)) {
 2311|       |            if (skip_ws<Opts>(ctx, it, end)) {
 2312|       |               return;
 2313|       |            }
 2314|       |         }
 2315|       |
 2316|   615k|         if (match_invalid_end<'[', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2316:14): [True: 0, False: 615k]
  ------------------
 2317|      0|            return;
 2318|      0|         }
 2319|       |         // one nesting level (see enter_depth): counted in both modes so the limit binds,
 2320|       |         // released at each syntactic close below
 2321|   615k|         if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (2321:14): [True: 3, False: 615k]
  ------------------
 2322|      3|            return;
 2323|      3|         }
 2324|       |
 2325|   615k|         const auto ws_start = it;
 2326|   615k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2326:14): [True: 0, False: 615k]
  ------------------
 2327|      0|            return;
 2328|      0|         }
 2329|       |
 2330|   615k|         if (*it == ']') {
  ------------------
  |  Branch (2330:14): [True: 4.84k, False: 611k]
  ------------------
 2331|  4.84k|            --ctx.depth;
 2332|  4.84k|            ++it;
 2333|  4.84k|            if constexpr ((resizable<T> || is_inplace_vector<T>) && not check_append_arrays(Opts)) {
 2334|  4.84k|               value.clear();
 2335|       |
 2336|       |               if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2337|       |                  value.shrink_to_fit();
 2338|       |               }
 2339|  4.84k|            }
 2340|  4.84k|            return;
 2341|  4.84k|         }
 2342|       |
 2343|   611k|         const size_t ws_size = size_t(it - ws_start);
 2344|       |
 2345|   611k|         static constexpr bool should_append = (resizable<T> || is_inplace_vector<T>) && check_append_arrays(Opts);
  ------------------
  |  Branch (2345:49): [True: 611k, Folded]
  |  Branch (2345:65): [Folded, False: 0]
  |  Branch (2345:90): [Folded, False: 0]
  ------------------
 2346|   611k|         if constexpr (not should_append) {
 2347|   611k|            const auto n = value.size();
 2348|       |
 2349|   611k|            auto value_it = value.begin();
 2350|       |
 2351|   618k|            for (size_t i = 0; i < n; ++i) {
  ------------------
  |  Branch (2351:32): [True: 138k, False: 480k]
  ------------------
 2352|   138k|               parse<JSON>::op<ws_handled<Opts>()>(*value_it++, ctx, it, end);
 2353|   138k|               if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2353:20): [True: 758, False: 137k]
  ------------------
 2354|    758|                  return;
 2355|   137k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2355:20): [True: 0, False: 137k]
  ------------------
 2356|      0|                  return;
 2357|      0|               }
 2358|   137k|               if (*it == ',') {
  ------------------
  |  Branch (2358:20): [True: 7.74k, False: 129k]
  ------------------
 2359|  7.74k|                  ++it;
 2360|       |
 2361|  7.74k|                  if constexpr (!Opts.minified && !Opts.comments) {
 2362|  7.74k|                     if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2362:26): [True: 4.53k, False: 3.20k]
  |  Branch (2362:37): [True: 4.09k, False: 434]
  ------------------
 2363|  4.09k|                        skip_matching_ws(ws_start, it, ws_size);
 2364|  4.09k|                     }
 2365|  7.74k|                  }
 2366|       |
 2367|  7.74k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2367:23): [True: 0, False: 7.74k]
  ------------------
 2368|      0|                     return;
 2369|      0|                  }
 2370|  7.74k|               }
 2371|   129k|               else if (*it == ']') {
  ------------------
  |  Branch (2371:25): [True: 129k, False: 75]
  ------------------
 2372|   129k|                  --ctx.depth;
 2373|   129k|                  ++it;
 2374|   129k|                  if constexpr (erasable<T>) {
 2375|   129k|                     value.erase(value_it,
 2376|   129k|                                 value.end()); // use erase rather than resize for non-default constructible elements
 2377|       |
 2378|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2379|       |                        value.shrink_to_fit();
 2380|       |                     }
 2381|   129k|                  }
 2382|   129k|                  return;
 2383|   129k|               }
 2384|     75|               else [[unlikely]] {
 2385|     75|                  ctx.error = error_code::expected_bracket;
 2386|     75|                  return;
 2387|     75|               }
 2388|   137k|            }
 2389|   611k|         }
 2390|       |
 2391|       |         if constexpr (Opts.partial_read) {
 2392|       |            // partial_read stops early on a success path, so give the level back like the
 2393|       |            // syntactic-close paths do; otherwise it accumulates across reads sharing a context.
 2394|       |            --ctx.depth;
 2395|       |            return;
 2396|       |         }
 2397|   611k|         else {
 2398|       |            // growing
 2399|   611k|            if constexpr (emplace_backable<T> || has_try_emplace_back<T>) {
 2400|  1.71M|               while (it < end) {
  ------------------
  |  Branch (2400:23): [True: 1.58M, False: 130k]
  ------------------
 2401|       |                  // Streaming refill point: at start of each iteration, ensure buffer has data
 2402|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2403|       |                     if (ctx.stream.enabled()) {
 2404|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2405|       |                        const size_t remaining = ctx.stream.size() - consumed;
 2406|       |                        // Refill when less than half of buffer remains to ensure space for next element
 2407|       |                        if (remaining <= ctx.stream.size() / 2 || it >= end) {
 2408|       |                           const char* new_it;
 2409|       |                           const char* new_end;
 2410|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2411|       |                           it = new_it;
 2412|       |                           end = new_end;
 2413|       |                           if (it >= end && ctx.stream.at_eof()) {
 2414|       |                              break; // No more data, exit loop normally
 2415|       |                           }
 2416|       |                        }
 2417|       |                     }
 2418|       |                  }
 2419|       |
 2420|       |                  if constexpr (has_try_emplace_back<T>) {
 2421|       |                     if (value.try_emplace_back())
 2422|       |                        parse<JSON>::op<ws_handled<Opts>()>(value.back(), ctx, it, end);
 2423|       |                     else
 2424|       |                        ctx.error = error_code::exceeded_static_array_size;
 2425|       |                  }
 2426|  1.58M|                  else {
 2427|  1.58M|                     parse<JSON>::op<ws_handled<Opts>()>(value.emplace_back(), ctx, it, end);
 2428|  1.58M|                  }
 2429|       |
 2430|  1.58M|                  if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2430:23): [True: 11.8k, False: 1.57M]
  ------------------
 2431|  11.8k|                     return;
 2432|       |
 2433|       |                  // Streaming refill point: after parsing each element, refill if buffer is low
 2434|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2435|       |                     if (ctx.stream.enabled()) {
 2436|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2437|       |                        // Refill when less than 25% of buffer remains to ensure enough space for next element
 2438|       |                        if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 2439|       |                           const char* new_it;
 2440|       |                           const char* new_end;
 2441|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2442|       |                           it = new_it;
 2443|       |                           end = new_end;
 2444|       |                           if (it >= end && ctx.stream.at_eof()) {
 2445|       |                              ctx.error = error_code::unexpected_end;
 2446|       |                              return;
 2447|       |                           }
 2448|       |                        }
 2449|       |                     }
 2450|       |                  }
 2451|       |
 2452|  1.57M|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2452:23): [True: 0, False: 1.57M]
  ------------------
 2453|      0|                     return;
 2454|      0|                  }
 2455|  1.57M|                  if (*it == ',') [[likely]] {
  ------------------
  |  Branch (2455:23): [True: 1.10M, False: 468k]
  ------------------
 2456|  1.10M|                     ++it;
 2457|       |
 2458|  1.10M|                     if constexpr (!Opts.minified && !Opts.comments) {
 2459|  1.10M|                        if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2459:29): [True: 15.4k, False: 1.09M]
  |  Branch (2459:40): [True: 14.7k, False: 648]
  ------------------
 2460|  14.7k|                           skip_matching_ws(ws_start, it, ws_size);
 2461|  14.7k|                        }
 2462|  1.10M|                     }
 2463|       |
 2464|  1.10M|                     if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2464:26): [True: 0, False: 1.10M]
  ------------------
 2465|      0|                        return;
 2466|      0|                     }
 2467|  1.10M|                  }
 2468|   468k|                  else if (*it == ']') {
  ------------------
  |  Branch (2468:28): [True: 467k, False: 1.00k]
  ------------------
 2469|   467k|                     --ctx.depth;
 2470|   467k|                     ++it;
 2471|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2472|       |                        value.shrink_to_fit();
 2473|       |                     }
 2474|   467k|                     return;
 2475|   467k|                  }
 2476|  1.00k|                  else [[unlikely]] {
 2477|  1.00k|                     ctx.error = error_code::expected_bracket;
 2478|  1.00k|                     return;
 2479|  1.00k|                  }
 2480|  1.57M|               }
 2481|       |
 2482|       |               // A valid array always returns from inside the loop upon reaching ']'.
 2483|       |               // For a null-terminated buffer the loop can only exit here by falling
 2484|       |               // through when `it` reaches the terminator without a closing bracket,
 2485|       |               // which means the input was truncated (e.g. "[", "[1," or "[1,2,").
 2486|       |               // Non-null-terminated buffers surface this through skip_ws/depth
 2487|       |               // tracking (or the streaming refill break), so this guard is limited
 2488|       |               // to the null-terminated case.
 2489|   130k|               if constexpr (Opts.null_terminated) {
 2490|   130k|                  ctx.error = error_code::unexpected_end;
 2491|   130k|               }
 2492|       |            }
 2493|       |            else {
 2494|       |               ctx.error = error_code::exceeded_static_array_size;
 2495|       |            }
 2496|   611k|         }
 2497|   611k|      }
_ZN3glz12rewind_depthITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10is_contextENS_7contextEEEvRT0_j:
 3697|  16.3k|   {
 3698|  16.3k|      if (ctx.error == error_code::exceeded_max_recursive_depth) [[unlikely]] {
  ------------------
  |  Branch (3698:11): [True: 1.19k, False: 15.1k]
  ------------------
 3699|  1.19k|         return;
 3700|  1.19k|      }
 3701|  15.1k|      if constexpr (Opts.null_terminated) {
 3702|  15.1k|         ctx.depth = depth;
 3703|       |      }
 3704|       |      else {
 3705|       |         if (ctx.error != error_code::end_reached && ctx.error != error_code::unexpected_end) {
 3706|       |            ctx.depth = depth;
 3707|       |         }
 3708|       |      }
 3709|  15.1k|   }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 602k, False: 13.7k]
  |  Branch (3795:38): [True: 0, False: 13.7k]
  |  Branch (3795:51): [True: 1.19k, False: 12.5k]
  ------------------
 3796|   603k|                     return;
 3797|   603k|                  }
 3798|  12.5k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  12.5k|               });
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3725|  6.38k|      {
 3726|  6.38k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3727|       |
 3728|       |         if constexpr (category_count == 0) {
 3729|       |            ctx.error = error_code::no_matching_variant_type;
 3730|       |         }
 3731|  6.38k|         else {
 3732|  6.38k|            constexpr auto N = std::variant_size_v<Variant>;
 3733|  6.38k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3734|  6.38k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3735|       |
 3736|  6.38k|            bool found_match{};
 3737|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3738|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3739|       |            // so the budget stops it and the failure already in hand is reported.
 3740|  6.38k|            bool exhausted{};
 3741|       |
 3742|       |            // First pass: const glaze types in this category
 3743|       |            if constexpr (const_count > 0) {
 3744|       |               for_each<N>([&]<size_t I>() {
 3745|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3746|       |                     return;
 3747|       |                  }
 3748|       |                  using V = std::variant_alternative_t<I, Variant>;
 3749|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3750|       |                     // run time substitute to compare to const value
 3751|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3752|       |                     auto copy_it{it};
 3753|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3754|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3755|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3756|       |                     const auto copy_depth{ctx.depth};
 3757|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3758|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3759|       |                     if (substitute == const_value) {
 3760|       |                        found_match = true;
 3761|       |                        if (!std::holds_alternative<V>(value)) {
 3762|       |                           value = V{};
 3763|       |                        }
 3764|       |                     }
 3765|       |                     else {
 3766|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3767|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3768|       |                           exhausted = true;
 3769|       |                        }
 3770|       |                        if constexpr (not Options.null_terminated) {
 3771|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3772|       |                              ctx.error = error_code::none;
 3773|       |                           }
 3774|       |                        }
 3775|       |                        it = copy_it;
 3776|       |                        rewind_depth<Options>(ctx, copy_depth);
 3777|       |                     }
 3778|       |                  }
 3779|       |               });
 3780|       |               if (found_match) {
 3781|       |                  return;
 3782|       |               }
 3783|       |            }
 3784|       |
 3785|       |            // Second pass: non-const types in this category
 3786|  6.38k|            if constexpr (non_const_count > 0) {
 3787|       |               // Track position within matching types for "is last" check.
 3788|       |               // We iterate over all variant indices but only process matching types,
 3789|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3790|       |               // the loop index directly corresponded to position in filtered set).
 3791|       |               // This has negligible cost: one increment per matching type.
 3792|  6.38k|               size_t non_const_idx = 0;
 3793|       |
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3796|  6.38k|                     return;
 3797|  6.38k|                  }
 3798|  6.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  6.38k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  6.38k|                     auto copy_it{it};
 3801|  6.38k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  6.38k|                     if (!std::holds_alternative<V>(value)) {
 3803|  6.38k|                        value = V{};
 3804|  6.38k|                     }
 3805|  6.38k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  6.38k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|  6.38k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|  6.38k|                     }
 3809|  6.38k|                     if (!bool(ctx.error)) {
 3810|  6.38k|                        found_match = true;
 3811|  6.38k|                     }
 3812|  6.38k|                     else if constexpr (not Options.null_terminated) {
 3813|  6.38k|                        constexpr bool is_complete_type =
 3814|  6.38k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|  6.38k|                        if constexpr (is_complete_type) {
 3817|  6.38k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|  6.38k|                              found_match = true;
 3819|  6.38k|                              ctx.error = error_code::none;
 3820|  6.38k|                           }
 3821|  6.38k|                           else {
 3822|  6.38k|                              it = copy_it;
 3823|  6.38k|                              rewind_depth<Options>(ctx, copy_depth);
 3824|  6.38k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|  6.38k|                                  not variant_alternative_exhausted(ctx)) {
 3826|  6.38k|                                 ctx.error = error_code::none;
 3827|  6.38k|                              }
 3828|  6.38k|                           }
 3829|  6.38k|                        }
 3830|  6.38k|                        else {
 3831|  6.38k|                           it = copy_it;
 3832|  6.38k|                           rewind_depth<Options>(ctx, copy_depth);
 3833|  6.38k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|  6.38k|                               not variant_alternative_exhausted(ctx)) {
 3835|  6.38k|                              ctx.error = error_code::none;
 3836|  6.38k|                           }
 3837|  6.38k|                        }
 3838|  6.38k|                     }
 3839|  6.38k|                     else {
 3840|  6.38k|                        it = copy_it;
 3841|  6.38k|                        rewind_depth<Options>(ctx, copy_depth);
 3842|  6.38k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|  6.38k|                            not variant_alternative_exhausted(ctx)) {
 3844|  6.38k|                           ctx.error = error_code::none;
 3845|  6.38k|                        }
 3846|  6.38k|                     }
 3847|  6.38k|                     ++non_const_idx;
 3848|  6.38k|                  }
 3849|  6.38k|               });
 3850|  6.38k|               if (!found_match) {
  ------------------
  |  Branch (3850:20): [True: 843, False: 5.53k]
  ------------------
 3851|    843|                  if constexpr (non_const_count == 1) {
 3852|       |                     // Keep the specific error from the single type we tried
 3853|       |                  }
 3854|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3855|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3856|       |                     ctx.error = error_code::no_matching_variant_type;
 3857|       |                  }
 3858|    843|               }
 3859|       |            }
 3860|       |            else {
 3861|       |               ctx.error = error_code::no_matching_variant_type;
 3862|       |            }
 3863|  6.38k|         }
 3864|  6.38k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 6.38k]
  |  Branch (3795:38): [True: 0, False: 6.38k]
  |  Branch (3795:51): [True: 0, False: 6.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  6.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  6.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 6.38k]
  |  Branch (3795:38): [True: 0, False: 6.38k]
  |  Branch (3795:51): [True: 0, False: 6.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  6.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  6.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 6.38k]
  |  Branch (3795:38): [True: 0, False: 6.38k]
  |  Branch (3795:51): [True: 0, False: 6.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  6.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  6.38k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  6.38k|                     auto copy_it{it};
 3801|  6.38k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  6.38k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3802:26): [True: 4.65k, False: 1.72k]
  ------------------
 3803|  4.65k|                        value = V{};
 3804|  4.65k|                     }
 3805|  6.38k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  6.38k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3806:26): [True: 843, False: 5.53k]
  |  Branch (3806:45): [True: 0, False: 843]
  ------------------
 3807|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|      0|                     }
 3809|  6.38k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3809:26): [True: 5.53k, False: 843]
  ------------------
 3810|  5.53k|                        found_match = true;
 3811|  5.53k|                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|    843|                     else {
 3840|    843|                        it = copy_it;
 3841|    843|                        rewind_depth<Options>(ctx, copy_depth);
 3842|    843|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3842:29): [True: 0, False: 843]
  |  Branch (3842:68): [True: 0, False: 0]
  ------------------
 3843|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3843:29): [True: 0, False: 0]
  ------------------
 3844|      0|                           ctx.error = error_code::none;
 3845|      0|                        }
 3846|    843|                     }
 3847|  6.38k|                     ++non_const_idx;
 3848|  6.38k|                  }
 3849|  6.38k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|  6.38k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  6.38k|         else {
   60|  6.38k|            using V = std::remove_cvref_t<T>;
   61|  6.38k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  6.38k|                                             end);
   63|  6.38k|         }
   64|  6.38k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEQntcl15check_is_paddedTL0__EEEvRT2_OT3_OT0_T1_:
 1043|  6.38k|      {
 1044|       |         if constexpr (check_string_as_number(Opts)) {
 1045|       |            auto start = it;
 1046|       |            skip_number<Opts>(ctx, it, end);
 1047|       |            if (bool(ctx.error)) [[unlikely]] {
 1048|       |               return;
 1049|       |            }
 1050|       |            if (start == it) [[unlikely]] {
 1051|       |               ctx.error = error_code::parse_number_failure;
 1052|       |               return;
 1053|       |            }
 1054|       |            value.append(start, size_t(it - start));
 1055|       |         }
 1056|  6.38k|         else {
 1057|  6.38k|            if constexpr (!check_opening_handled(Opts)) {
 1058|       |               if constexpr (!check_ws_handled(Opts)) {
 1059|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 1060|       |                     return;
 1061|       |                  }
 1062|       |               }
 1063|       |
 1064|  6.38k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (1064:20): [True: 0, False: 6.38k]
  ------------------
 1065|      0|                  return;
 1066|      0|               }
 1067|  6.38k|            }
 1068|       |
 1069|  6.38k|            if constexpr (not check_raw_string(Opts)) {
 1070|  6.38k|               static constexpr auto string_padding_bytes = 8;
 1071|       |
 1072|  6.38k|               if (size_t(end - it) >= 8) {
  ------------------
  |  Branch (1072:20): [True: 5.90k, False: 477]
  ------------------
 1073|  5.90k|                  auto start = it;
 1074|  5.90k|                  uint64_t ascii_acc{};
 1075|  5.90k|                  const auto end8 = end - 8;
 1076|  1.45M|                  while (true) {
  ------------------
  |  Branch (1076:26): [True: 1.45M, Folded]
  ------------------
 1077|  1.45M|                     if (it >= end8) [[unlikely]] {
  ------------------
  |  Branch (1077:26): [True: 537, False: 1.45M]
  ------------------
 1078|    537|                        break;
 1079|    537|                     }
 1080|       |
 1081|  1.45M|                     uint64_t chunk;
 1082|  1.45M|                     std::memcpy(&chunk, it, 8);
 1083|       |                     if constexpr (std::endian::native == std::endian::big) {
 1084|       |                        chunk = std::byteswap(chunk);
 1085|       |                     }
 1086|  1.45M|                     ascii_acc |= chunk;
 1087|  1.45M|                     const uint64_t test_chars = has_quote(chunk);
 1088|  1.45M|                     if (test_chars) {
  ------------------
  |  Branch (1088:26): [True: 7.07k, False: 1.44M]
  ------------------
 1089|  7.07k|                        it += (countr_zero(test_chars) >> 3);
 1090|       |
 1091|  7.07k|                        auto* prev = it - 1;
 1092|  9.33k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1092:32): [True: 2.25k, False: 7.07k]
  ------------------
 1093|  2.25k|                           --prev;
 1094|  2.25k|                        }
 1095|  7.07k|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1095:29): [True: 5.36k, False: 1.71k]
  ------------------
 1096|  5.36k|                           goto continue_decode;
 1097|  5.36k|                        }
 1098|  1.71k|                        ++it; // skip the escaped quote
 1099|  1.71k|                     }
 1100|  1.44M|                     else {
 1101|  1.44M|                        it += 8;
 1102|  1.44M|                     }
 1103|  1.45M|                  }
 1104|       |
 1105|  1.96k|                  while (it[-1] == '\\') [[unlikely]] {
  ------------------
  |  Branch (1105:26): [True: 1.42k, False: 537]
  ------------------
 1106|       |                     // if we ended on an escape character then we need to rewind
 1107|       |                     // because we lost our context
 1108|  1.42k|                     --it;
 1109|  1.42k|                  }
 1110|       |
 1111|       |                  // The byte-wise tail keeps feeding the accumulator: it has to cover every byte of
 1112|       |                  // the string, or a non-ASCII byte reached here would be waved through unvalidated.
 1113|  3.73k|                  for (; it < end; ++it) {
  ------------------
  |  Branch (1113:26): [True: 3.61k, False: 120]
  ------------------
 1114|  3.61k|                     ascii_acc |= uint8_t(*it);
 1115|  3.61k|                     if (*it == '"') {
  ------------------
  |  Branch (1115:26): [True: 479, False: 3.13k]
  ------------------
 1116|    479|                        auto* prev = it - 1;
 1117|  1.04k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1117:32): [True: 570, False: 479]
  ------------------
 1118|    570|                           --prev;
 1119|    570|                        }
 1120|    479|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1120:29): [True: 417, False: 62]
  ------------------
 1121|    417|                           goto continue_decode;
 1122|    417|                        }
 1123|    479|                     }
 1124|  3.61k|                  }
 1125|       |
 1126|    120|                  ctx.error = error_code::unexpected_end;
 1127|    120|                  return;
 1128|       |
 1129|  5.78k|               continue_decode:
 1130|       |
 1131|  5.78k|                  if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (1131:23): [True: 181, False: 5.60k]
  ------------------
 1132|    181|                     return;
 1133|    181|                  }
 1134|       |
 1135|  5.60k|                  const auto available_padding = size_t(end - it);
 1136|  5.60k|                  auto n = size_t(it - start);
 1137|  5.60k|                  if (available_padding >= 8) [[likely]] {
  ------------------
  |  Branch (1137:23): [True: 5.22k, False: 379]
  ------------------
 1138|  5.22k|                     value.resize(n + string_padding_bytes);
 1139|       |
 1140|  5.22k|                     auto* p = value.data();
 1141|       |
 1142|  29.6k|                     while (true) {
  ------------------
  |  Branch (1142:29): [True: 29.6k, Folded]
  ------------------
 1143|  29.6k|                        if (start >= it) {
  ------------------
  |  Branch (1143:29): [True: 4.83k, False: 24.7k]
  ------------------
 1144|  4.83k|                           break;
 1145|  4.83k|                        }
 1146|       |
 1147|  24.7k|                        std::memcpy(p, start, 8);
 1148|  24.7k|                        uint64_t swar;
 1149|  24.7k|                        std::memcpy(&swar, p, 8);
 1150|       |                        if constexpr (std::endian::native == std::endian::big) {
 1151|       |                           swar = std::byteswap(swar);
 1152|       |                        }
 1153|       |
 1154|  24.7k|                        constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1155|  24.7k|                        const uint64_t lo7 = swar & lo7_mask;
 1156|  24.7k|                        const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1157|  24.7k|                        const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1158|  24.7k|                        uint64_t next = ~((backslash & less_32) | swar);
 1159|       |
 1160|  24.7k|                        next &= repeat_byte8(0b10000000);
 1161|  24.7k|                        if (next == 0) {
  ------------------
  |  Branch (1161:29): [True: 22.4k, False: 2.32k]
  ------------------
 1162|  22.4k|                           start += 8;
 1163|  22.4k|                           p += 8;
 1164|  22.4k|                           continue;
 1165|  22.4k|                        }
 1166|       |
 1167|  2.32k|                        next = countr_zero(next) >> 3;
 1168|  2.32k|                        start += next;
 1169|  2.32k|                        if (start >= it) {
  ------------------
  |  Branch (1169:29): [True: 275, False: 2.04k]
  ------------------
 1170|    275|                           break;
 1171|    275|                        }
 1172|       |
 1173|  2.04k|                        if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1173:29): [True: 35, False: 2.01k]
  ------------------
 1174|     35|                           ctx.error = error_code::syntax_error;
 1175|     35|                           return;
 1176|     35|                        }
 1177|  2.01k|                        ++start; // skip the escape
 1178|  2.01k|                        if (*start == 'u') {
  ------------------
  |  Branch (1178:29): [True: 1.18k, False: 825]
  ------------------
 1179|  1.18k|                           ++start;
 1180|  1.18k|                           p += next;
 1181|  1.18k|                           const auto mark = start;
 1182|  1.18k|                           const auto offset = handle_unicode_code_point(start, p, end);
 1183|  1.18k|                           if (offset == 0) [[unlikely]] {
  ------------------
  |  Branch (1183:32): [True: 73, False: 1.11k]
  ------------------
 1184|     73|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1185|     73|                              return;
 1186|     73|                           }
 1187|  1.11k|                           n += offset;
 1188|       |                           // escape + u + unicode code points
 1189|  1.11k|                           n -= 2 + uint32_t(start - mark);
 1190|  1.11k|                        }
 1191|    825|                        else {
 1192|    825|                           p += next;
 1193|    825|                           *p = char_unescape_table[uint8_t(*start)];
 1194|    825|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1194:32): [True: 10, False: 815]
  ------------------
 1195|     10|                              ctx.error = error_code::invalid_escape;
 1196|     10|                              return;
 1197|     10|                           }
 1198|    815|                           ++p;
 1199|    815|                           ++start;
 1200|    815|                           --n;
 1201|    815|                        }
 1202|  2.01k|                     }
 1203|       |
 1204|  5.10k|                     value.resize(n);
 1205|  5.10k|                     ++it;
 1206|  5.10k|                  }
 1207|    379|                  else {
 1208|       |                     // For large inputs this case of running out of buffer is very rare
 1209|    379|                     value.resize(n);
 1210|    379|                     auto* p = value.data();
 1211|       |
 1212|    379|                     it = start;
 1213|  1.15M|                     while (it < end) [[likely]] {
  ------------------
  |  Branch (1213:29): [True: 1.15M, False: 0]
  ------------------
 1214|  1.15M|                        if (*it == '"') {
  ------------------
  |  Branch (1214:29): [True: 233, False: 1.15M]
  ------------------
 1215|    233|                           value.resize(size_t(p - value.data()));
 1216|    233|                           ++it;
 1217|    233|                           return;
 1218|    233|                        }
 1219|       |
 1220|  1.15M|                        if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1220:29): [True: 42, False: 1.15M]
  ------------------
 1221|     42|                           ctx.error = error_code::syntax_error;
 1222|     42|                           return;
 1223|     42|                        }
 1224|       |
 1225|  1.15M|                        *p = *it;
 1226|       |
 1227|  1.15M|                        if (*it == '\\') {
  ------------------
  |  Branch (1227:29): [True: 1.82k, False: 1.14M]
  ------------------
 1228|  1.82k|                           ++it; // skip the escape
 1229|  1.82k|                           if (*it == 'u') {
  ------------------
  |  Branch (1229:32): [True: 1.20k, False: 619]
  ------------------
 1230|  1.20k|                              ++it;
 1231|  1.20k|                              if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1231:35): [True: 83, False: 1.12k]
  ------------------
 1232|     83|                                 ctx.error = error_code::unicode_escape_conversion_failure;
 1233|     83|                                 return;
 1234|     83|                              }
 1235|  1.20k|                           }
 1236|    619|                           else {
 1237|    619|                              *p = char_unescape_table[uint8_t(*it)];
 1238|    619|                              if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1238:35): [True: 21, False: 598]
  ------------------
 1239|     21|                                 ctx.error = error_code::invalid_escape;
 1240|     21|                                 return;
 1241|     21|                              }
 1242|    598|                              ++p;
 1243|    598|                              ++it;
 1244|    598|                           }
 1245|  1.82k|                        }
 1246|  1.14M|                        else {
 1247|  1.14M|                           ++it;
 1248|  1.14M|                           ++p;
 1249|  1.14M|                        }
 1250|  1.15M|                     }
 1251|       |
 1252|      0|                     ctx.error = error_code::unexpected_end;
 1253|      0|                  }
 1254|  5.60k|               }
 1255|    477|               else {
 1256|       |                  // For short strings
 1257|       |
 1258|    477|                  std::array<char, 8> buffer{};
 1259|       |
 1260|    477|                  auto* p = buffer.data();
 1261|    477|                  const auto* const utf8_start = it;
 1262|       |
 1263|  1.03k|                  while (it < end) [[likely]] {
  ------------------
  |  Branch (1263:26): [True: 1.03k, False: 0]
  ------------------
 1264|  1.03k|                     *p = *it;
 1265|  1.03k|                     if (*it == '"') {
  ------------------
  |  Branch (1265:26): [True: 262, False: 770]
  ------------------
 1266|    262|                        if (validate_utf8_span<Opts>(ctx, utf8_start, it)) [[unlikely]] {
  ------------------
  |  Branch (1266:29): [True: 63, False: 199]
  ------------------
 1267|     63|                           return;
 1268|     63|                        }
 1269|    199|                        const size_t n = size_t(p - buffer.data());
 1270|    199|#if __has_cpp_attribute(assume) >= 202207L
 1271|    199|                        [[assume(n <= sizeof(buffer))]];
 1272|    199|#endif
 1273|    199|                        value.assign(buffer.data(), n);
 1274|    199|                        ++it;
 1275|       |                        if constexpr (not Opts.null_terminated) {
 1276|       |                           if (it == end) {
 1277|       |                              ctx.error = error_code::end_reached;
 1278|       |                              return;
 1279|       |                           }
 1280|       |                        }
 1281|    199|                        return;
 1282|    262|                     }
 1283|    770|                     else if (*it == '\\') {
  ------------------
  |  Branch (1283:31): [True: 91, False: 679]
  ------------------
 1284|     91|                        ++it; // skip the escape
 1285|       |                        if constexpr (not Opts.null_terminated) {
 1286|       |                           if (it == end) [[unlikely]] {
 1287|       |                              ctx.error = error_code::unexpected_end;
 1288|       |                              return;
 1289|       |                           }
 1290|       |                        }
 1291|     91|                        if (*it == 'u') {
  ------------------
  |  Branch (1291:29): [True: 54, False: 37]
  ------------------
 1292|     54|                           ++it;
 1293|       |                           if constexpr (not Opts.null_terminated) {
 1294|       |                              if (it == end) [[unlikely]] {
 1295|       |                                 ctx.error = error_code::unexpected_end;
 1296|       |                                 return;
 1297|       |                              }
 1298|       |                           }
 1299|     54|                           if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1299:32): [True: 15, False: 39]
  ------------------
 1300|     15|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1301|     15|                              return;
 1302|     15|                           }
 1303|     54|                        }
 1304|     37|                        else {
 1305|     37|                           *p = char_unescape_table[uint8_t(*it)];
 1306|     37|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1306:32): [True: 10, False: 27]
  ------------------
 1307|     10|                              ctx.error = error_code::invalid_escape;
 1308|     10|                              return;
 1309|     10|                           }
 1310|     27|                           ++p;
 1311|     27|                           ++it;
 1312|     27|                        }
 1313|     91|                     }
 1314|    679|                     else if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1314:31): [True: 190, False: 489]
  ------------------
 1315|    190|                        ctx.error = error_code::syntax_error;
 1316|    190|                        return;
 1317|    190|                     }
 1318|    489|                     else {
 1319|    489|                        ++it;
 1320|    489|                        ++p;
 1321|    489|                     }
 1322|  1.03k|                  }
 1323|       |
 1324|      0|                  ctx.error = error_code::unexpected_end;
 1325|      0|               }
 1326|       |            }
 1327|       |            else {
 1328|       |               // raw_string
 1329|       |               auto start = it;
 1330|       |               skip_string_view(ctx, it, end);
 1331|       |               if (bool(ctx.error)) [[unlikely]]
 1332|       |                  return;
 1333|       |
 1334|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1335|       |                  return;
 1336|       |               }
 1337|       |
 1338|       |               value.assign(start, size_t(it - start));
 1339|       |               ++it;
 1340|       |            }
 1341|  6.38k|         }
 1342|  6.38k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 5.53k, False: 843]
  |  Branch (3795:38): [True: 0, False: 843]
  |  Branch (3795:51): [True: 0, False: 843]
  ------------------
 3796|  5.53k|                     return;
 3797|  5.53k|                  }
 3798|    843|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    843|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 5.53k, False: 843]
  |  Branch (3795:38): [True: 0, False: 843]
  |  Branch (3795:51): [True: 0, False: 843]
  ------------------
 3796|  5.53k|                     return;
 3797|  5.53k|                  }
 3798|    843|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    843|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 5.53k, False: 843]
  |  Branch (3795:38): [True: 0, False: 843]
  |  Branch (3795:51): [True: 0, False: 843]
  ------------------
 3796|  5.53k|                     return;
 3797|  5.53k|                  }
 3798|    843|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    843|               });
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3725|  1.38k|      {
 3726|  1.38k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3727|       |
 3728|       |         if constexpr (category_count == 0) {
 3729|       |            ctx.error = error_code::no_matching_variant_type;
 3730|       |         }
 3731|  1.38k|         else {
 3732|  1.38k|            constexpr auto N = std::variant_size_v<Variant>;
 3733|  1.38k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3734|  1.38k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3735|       |
 3736|  1.38k|            bool found_match{};
 3737|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3738|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3739|       |            // so the budget stops it and the failure already in hand is reported.
 3740|  1.38k|            bool exhausted{};
 3741|       |
 3742|       |            // First pass: const glaze types in this category
 3743|       |            if constexpr (const_count > 0) {
 3744|       |               for_each<N>([&]<size_t I>() {
 3745|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3746|       |                     return;
 3747|       |                  }
 3748|       |                  using V = std::variant_alternative_t<I, Variant>;
 3749|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3750|       |                     // run time substitute to compare to const value
 3751|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3752|       |                     auto copy_it{it};
 3753|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3754|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3755|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3756|       |                     const auto copy_depth{ctx.depth};
 3757|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3758|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3759|       |                     if (substitute == const_value) {
 3760|       |                        found_match = true;
 3761|       |                        if (!std::holds_alternative<V>(value)) {
 3762|       |                           value = V{};
 3763|       |                        }
 3764|       |                     }
 3765|       |                     else {
 3766|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3767|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3768|       |                           exhausted = true;
 3769|       |                        }
 3770|       |                        if constexpr (not Options.null_terminated) {
 3771|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3772|       |                              ctx.error = error_code::none;
 3773|       |                           }
 3774|       |                        }
 3775|       |                        it = copy_it;
 3776|       |                        rewind_depth<Options>(ctx, copy_depth);
 3777|       |                     }
 3778|       |                  }
 3779|       |               });
 3780|       |               if (found_match) {
 3781|       |                  return;
 3782|       |               }
 3783|       |            }
 3784|       |
 3785|       |            // Second pass: non-const types in this category
 3786|  1.38k|            if constexpr (non_const_count > 0) {
 3787|       |               // Track position within matching types for "is last" check.
 3788|       |               // We iterate over all variant indices but only process matching types,
 3789|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3790|       |               // the loop index directly corresponded to position in filtered set).
 3791|       |               // This has negligible cost: one increment per matching type.
 3792|  1.38k|               size_t non_const_idx = 0;
 3793|       |
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3796|  1.38k|                     return;
 3797|  1.38k|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  1.38k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  1.38k|                     auto copy_it{it};
 3801|  1.38k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  1.38k|                     if (!std::holds_alternative<V>(value)) {
 3803|  1.38k|                        value = V{};
 3804|  1.38k|                     }
 3805|  1.38k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  1.38k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|  1.38k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|  1.38k|                     }
 3809|  1.38k|                     if (!bool(ctx.error)) {
 3810|  1.38k|                        found_match = true;
 3811|  1.38k|                     }
 3812|  1.38k|                     else if constexpr (not Options.null_terminated) {
 3813|  1.38k|                        constexpr bool is_complete_type =
 3814|  1.38k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|  1.38k|                        if constexpr (is_complete_type) {
 3817|  1.38k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|  1.38k|                              found_match = true;
 3819|  1.38k|                              ctx.error = error_code::none;
 3820|  1.38k|                           }
 3821|  1.38k|                           else {
 3822|  1.38k|                              it = copy_it;
 3823|  1.38k|                              rewind_depth<Options>(ctx, copy_depth);
 3824|  1.38k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|  1.38k|                                  not variant_alternative_exhausted(ctx)) {
 3826|  1.38k|                                 ctx.error = error_code::none;
 3827|  1.38k|                              }
 3828|  1.38k|                           }
 3829|  1.38k|                        }
 3830|  1.38k|                        else {
 3831|  1.38k|                           it = copy_it;
 3832|  1.38k|                           rewind_depth<Options>(ctx, copy_depth);
 3833|  1.38k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|  1.38k|                               not variant_alternative_exhausted(ctx)) {
 3835|  1.38k|                              ctx.error = error_code::none;
 3836|  1.38k|                           }
 3837|  1.38k|                        }
 3838|  1.38k|                     }
 3839|  1.38k|                     else {
 3840|  1.38k|                        it = copy_it;
 3841|  1.38k|                        rewind_depth<Options>(ctx, copy_depth);
 3842|  1.38k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|  1.38k|                            not variant_alternative_exhausted(ctx)) {
 3844|  1.38k|                           ctx.error = error_code::none;
 3845|  1.38k|                        }
 3846|  1.38k|                     }
 3847|  1.38k|                     ++non_const_idx;
 3848|  1.38k|                  }
 3849|  1.38k|               });
 3850|  1.38k|               if (!found_match) {
  ------------------
  |  Branch (3850:20): [True: 257, False: 1.13k]
  ------------------
 3851|    257|                  if constexpr (non_const_count == 1) {
 3852|       |                     // Keep the specific error from the single type we tried
 3853|       |                  }
 3854|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3855|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3856|       |                     ctx.error = error_code::no_matching_variant_type;
 3857|       |                  }
 3858|    257|               }
 3859|       |            }
 3860|       |            else {
 3861|       |               ctx.error = error_code::no_matching_variant_type;
 3862|       |            }
 3863|  1.38k|         }
 3864|  1.38k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.38k]
  |  Branch (3795:38): [True: 0, False: 1.38k]
  |  Branch (3795:51): [True: 0, False: 1.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.38k]
  |  Branch (3795:38): [True: 0, False: 1.38k]
  |  Branch (3795:51): [True: 0, False: 1.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.38k]
  |  Branch (3795:38): [True: 0, False: 1.38k]
  |  Branch (3795:51): [True: 0, False: 1.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.38k]
  |  Branch (3795:38): [True: 0, False: 1.38k]
  |  Branch (3795:51): [True: 0, False: 1.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  1.38k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  1.38k|                     auto copy_it{it};
 3801|  1.38k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  1.38k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3802:26): [True: 1.19k, False: 194]
  ------------------
 3803|  1.19k|                        value = V{};
 3804|  1.19k|                     }
 3805|  1.38k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  1.38k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3806:26): [True: 257, False: 1.13k]
  |  Branch (3806:45): [True: 0, False: 257]
  ------------------
 3807|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|      0|                     }
 3809|  1.38k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3809:26): [True: 1.13k, False: 257]
  ------------------
 3810|  1.13k|                        found_match = true;
 3811|  1.13k|                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|    257|                     else {
 3840|    257|                        it = copy_it;
 3841|    257|                        rewind_depth<Options>(ctx, copy_depth);
 3842|    257|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3842:29): [True: 0, False: 257]
  |  Branch (3842:68): [True: 0, False: 0]
  ------------------
 3843|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3843:29): [True: 0, False: 0]
  ------------------
 3844|      0|                           ctx.error = error_code::none;
 3845|      0|                        }
 3846|    257|                     }
 3847|  1.38k|                     ++non_const_idx;
 3848|  1.38k|                  }
 3849|  1.38k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  1.38k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  1.38k|         else {
   60|  1.38k|            using V = std::remove_cvref_t<T>;
   61|  1.38k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  1.38k|                                             end);
   63|  1.38k|         }
   64|  1.38k|      }
_ZN3glz4fromILj10EbE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEETkNS_6bool_tERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
  669|  1.38k|      {
  670|       |         if constexpr (check_quoted_num(Opts)) {
  671|       |            if (skip_ws<Opts>(ctx, it, end)) {
  672|       |               return;
  673|       |            }
  674|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  675|       |               return;
  676|       |            }
  677|       |         }
  678|       |
  679|       |         if constexpr (!check_ws_handled(Opts)) {
  680|       |            if (skip_ws<Opts>(ctx, it, end)) {
  681|       |               return;
  682|       |            }
  683|       |         }
  684|       |
  685|       |         if constexpr (check_bools_as_numbers(Opts)) {
  686|       |            if (*it == '1') {
  687|       |               value = true;
  688|       |               ++it;
  689|       |            }
  690|       |            else if (*it == '0') {
  691|       |               value = false;
  692|       |               ++it;
  693|       |            }
  694|       |            else {
  695|       |               ctx.error = error_code::syntax_error;
  696|       |               return;
  697|       |            }
  698|       |         }
  699|  1.38k|         else {
  700|  1.38k|            if constexpr (not check_is_padded(Opts)) {
  701|  1.38k|               if (size_t(end - it) < 4) [[unlikely]] {
  ------------------
  |  Branch (701:20): [True: 44, False: 1.34k]
  ------------------
  702|     44|                  ctx.error = error_code::expected_true_or_false;
  703|     44|                  return;
  704|     44|               }
  705|  1.38k|            }
  706|       |
  707|  1.34k|            uint32_t c;
  708|  1.38k|            static constexpr uint32_t u_true = 0b01100101'01110101'01110010'01110100;
  709|  1.38k|            static constexpr uint32_t u_fals = 0b01110011'01101100'01100001'01100110;
  710|  1.38k|            std::memcpy(&c, it, 4);
  711|       |            if constexpr (std::endian::native == std::endian::big) {
  712|       |               c = std::byteswap(c);
  713|       |            }
  714|  1.38k|            it += 4;
  715|  1.38k|            if (c == u_true) {
  ------------------
  |  Branch (715:17): [True: 862, False: 525]
  ------------------
  716|    862|               value = true;
  717|    862|            }
  718|    525|            else if (it == end) [[unlikely]] {
  ------------------
  |  Branch (718:22): [True: 25, False: 500]
  ------------------
  719|     25|               ctx.error = error_code::unexpected_end;
  720|     25|               return;
  721|     25|            }
  722|    500|            else {
  723|    500|               if (c == u_fals && (*it == 'e')) [[likely]] {
  ------------------
  |  Branch (723:20): [True: 282, False: 218]
  |  Branch (723:35): [True: 268, False: 14]
  ------------------
  724|    268|                  value = false;
  725|    268|                  ++it;
  726|    268|               }
  727|    232|               else [[unlikely]] {
  728|    232|                  ctx.error = error_code::expected_true_or_false;
  729|    232|                  return;
  730|    232|               }
  731|    500|            }
  732|  1.38k|         }
  733|       |
  734|       |         if constexpr (check_quoted_num(Opts)) {
  735|       |            if constexpr (not Opts.null_terminated) {
  736|       |               if (it == end) [[unlikely]] {
  737|       |                  ctx.error = error_code::unexpected_end;
  738|       |                  return;
  739|       |               }
  740|       |            }
  741|       |            if (match<'"'>(ctx, it)) {
  742|       |               return;
  743|       |            }
  744|       |            if constexpr (not Opts.null_terminated) {
  745|       |               if (it == end) {
  746|       |                  ctx.error = error_code::end_reached;
  747|       |                  return;
  748|       |               }
  749|       |            }
  750|       |         }
  751|  1.38k|         else {
  752|       |            if constexpr (not Opts.null_terminated) {
  753|       |               if (it == end) {
  754|       |                  ctx.error = error_code::end_reached;
  755|       |                  return;
  756|       |               }
  757|       |            }
  758|  1.38k|         }
  759|  1.38k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.13k, False: 257]
  |  Branch (3795:38): [True: 0, False: 257]
  |  Branch (3795:51): [True: 0, False: 257]
  ------------------
 3796|  1.13k|                     return;
 3797|  1.13k|                  }
 3798|    257|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    257|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.13k, False: 257]
  |  Branch (3795:38): [True: 0, False: 257]
  |  Branch (3795:51): [True: 0, False: 257]
  ------------------
 3796|  1.13k|                     return;
 3797|  1.13k|                  }
 3798|    257|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    257|               });
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3725|  1.95M|      {
 3726|  1.95M|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3727|       |
 3728|       |         if constexpr (category_count == 0) {
 3729|       |            ctx.error = error_code::no_matching_variant_type;
 3730|       |         }
 3731|  1.95M|         else {
 3732|  1.95M|            constexpr auto N = std::variant_size_v<Variant>;
 3733|  1.95M|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3734|  1.95M|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3735|       |
 3736|  1.95M|            bool found_match{};
 3737|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3738|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3739|       |            // so the budget stops it and the failure already in hand is reported.
 3740|  1.95M|            bool exhausted{};
 3741|       |
 3742|       |            // First pass: const glaze types in this category
 3743|       |            if constexpr (const_count > 0) {
 3744|       |               for_each<N>([&]<size_t I>() {
 3745|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3746|       |                     return;
 3747|       |                  }
 3748|       |                  using V = std::variant_alternative_t<I, Variant>;
 3749|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3750|       |                     // run time substitute to compare to const value
 3751|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3752|       |                     auto copy_it{it};
 3753|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3754|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3755|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3756|       |                     const auto copy_depth{ctx.depth};
 3757|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3758|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3759|       |                     if (substitute == const_value) {
 3760|       |                        found_match = true;
 3761|       |                        if (!std::holds_alternative<V>(value)) {
 3762|       |                           value = V{};
 3763|       |                        }
 3764|       |                     }
 3765|       |                     else {
 3766|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3767|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3768|       |                           exhausted = true;
 3769|       |                        }
 3770|       |                        if constexpr (not Options.null_terminated) {
 3771|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3772|       |                              ctx.error = error_code::none;
 3773|       |                           }
 3774|       |                        }
 3775|       |                        it = copy_it;
 3776|       |                        rewind_depth<Options>(ctx, copy_depth);
 3777|       |                     }
 3778|       |                  }
 3779|       |               });
 3780|       |               if (found_match) {
 3781|       |                  return;
 3782|       |               }
 3783|       |            }
 3784|       |
 3785|       |            // Second pass: non-const types in this category
 3786|  1.95M|            if constexpr (non_const_count > 0) {
 3787|       |               // Track position within matching types for "is last" check.
 3788|       |               // We iterate over all variant indices but only process matching types,
 3789|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3790|       |               // the loop index directly corresponded to position in filtered set).
 3791|       |               // This has negligible cost: one increment per matching type.
 3792|  1.95M|               size_t non_const_idx = 0;
 3793|       |
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.95M|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  1.95M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  1.95M|                     auto copy_it{it};
 3801|  1.95M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  1.95M|                     if (!std::holds_alternative<V>(value)) {
 3803|  1.95M|                        value = V{};
 3804|  1.95M|                     }
 3805|  1.95M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  1.95M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|  1.95M|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|  1.95M|                     }
 3809|  1.95M|                     if (!bool(ctx.error)) {
 3810|  1.95M|                        found_match = true;
 3811|  1.95M|                     }
 3812|  1.95M|                     else if constexpr (not Options.null_terminated) {
 3813|  1.95M|                        constexpr bool is_complete_type =
 3814|  1.95M|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|  1.95M|                        if constexpr (is_complete_type) {
 3817|  1.95M|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|  1.95M|                              found_match = true;
 3819|  1.95M|                              ctx.error = error_code::none;
 3820|  1.95M|                           }
 3821|  1.95M|                           else {
 3822|  1.95M|                              it = copy_it;
 3823|  1.95M|                              rewind_depth<Options>(ctx, copy_depth);
 3824|  1.95M|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|  1.95M|                                  not variant_alternative_exhausted(ctx)) {
 3826|  1.95M|                                 ctx.error = error_code::none;
 3827|  1.95M|                              }
 3828|  1.95M|                           }
 3829|  1.95M|                        }
 3830|  1.95M|                        else {
 3831|  1.95M|                           it = copy_it;
 3832|  1.95M|                           rewind_depth<Options>(ctx, copy_depth);
 3833|  1.95M|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|  1.95M|                               not variant_alternative_exhausted(ctx)) {
 3835|  1.95M|                              ctx.error = error_code::none;
 3836|  1.95M|                           }
 3837|  1.95M|                        }
 3838|  1.95M|                     }
 3839|  1.95M|                     else {
 3840|  1.95M|                        it = copy_it;
 3841|  1.95M|                        rewind_depth<Options>(ctx, copy_depth);
 3842|  1.95M|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|  1.95M|                            not variant_alternative_exhausted(ctx)) {
 3844|  1.95M|                           ctx.error = error_code::none;
 3845|  1.95M|                        }
 3846|  1.95M|                     }
 3847|  1.95M|                     ++non_const_idx;
 3848|  1.95M|                  }
 3849|  1.95M|               });
 3850|  1.95M|               if (!found_match) {
  ------------------
  |  Branch (3850:20): [True: 1.55k, False: 1.95M]
  ------------------
 3851|  1.55k|                  if constexpr (non_const_count == 1) {
 3852|       |                     // Keep the specific error from the single type we tried
 3853|       |                  }
 3854|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3855|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3856|       |                     ctx.error = error_code::no_matching_variant_type;
 3857|       |                  }
 3858|  1.55k|               }
 3859|       |            }
 3860|       |            else {
 3861|       |               ctx.error = error_code::no_matching_variant_type;
 3862|       |            }
 3863|  1.95M|         }
 3864|  1.95M|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.95M]
  |  Branch (3795:38): [True: 0, False: 1.95M]
  |  Branch (3795:51): [True: 0, False: 1.95M]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.95M|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.95M|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.95M]
  |  Branch (3795:38): [True: 0, False: 1.95M]
  |  Branch (3795:51): [True: 0, False: 1.95M]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.95M|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  1.95M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  1.95M|                     auto copy_it{it};
 3801|  1.95M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  1.95M|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3802:26): [True: 1.75M, False: 202k]
  ------------------
 3803|  1.75M|                        value = V{};
 3804|  1.75M|                     }
 3805|  1.95M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  1.95M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3806:26): [True: 1.55k, False: 1.95M]
  |  Branch (3806:45): [True: 0, False: 1.55k]
  ------------------
 3807|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|      0|                     }
 3809|  1.95M|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3809:26): [True: 1.95M, False: 1.55k]
  ------------------
 3810|  1.95M|                        found_match = true;
 3811|  1.95M|                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|  1.55k|                     else {
 3840|  1.55k|                        it = copy_it;
 3841|  1.55k|                        rewind_depth<Options>(ctx, copy_depth);
 3842|  1.55k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3842:29): [True: 0, False: 1.55k]
  |  Branch (3842:68): [True: 0, False: 0]
  ------------------
 3843|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3843:29): [True: 0, False: 0]
  ------------------
 3844|      0|                           ctx.error = error_code::none;
 3845|      0|                        }
 3846|  1.55k|                     }
 3847|  1.95M|                     ++non_const_idx;
 3848|  1.95M|                  }
 3849|  1.95M|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERdTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  1.95M|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  1.95M|         else {
   60|  1.95M|            using V = std::remove_cvref_t<T>;
   61|  1.95M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  1.95M|                                             end);
   63|  1.95M|         }
   64|  1.95M|      }
_ZN3glz4fromILj10EdE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERPKcRdTkNS_10is_contextERNS_7contextES5_EEvOT1_OT2_OT0_T3_:
  767|  1.95M|      {
  768|       |         if constexpr (check_quoted_num(Opts)) {
  769|       |            if (skip_ws<Opts>(ctx, it, end)) {
  770|       |               return;
  771|       |            }
  772|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  773|       |               return;
  774|       |            }
  775|       |         }
  776|       |
  777|       |         if constexpr (!check_ws_handled(Opts)) {
  778|       |            if (skip_ws<Opts>(ctx, it, end)) {
  779|       |               return;
  780|       |            }
  781|       |         }
  782|       |
  783|  1.95M|         using V = std::decay_t<decltype(value)>;
  784|       |         if constexpr (int_t<V>) {
  785|       |            static_assert(sizeof(*it) == sizeof(char));
  786|       |
  787|       |            if constexpr (Opts.null_terminated) {
  788|       |               if (not glz::atoi(value, it)) [[unlikely]] {
  789|       |                  ctx.error = error_code::parse_number_failure;
  790|       |                  return;
  791|       |               }
  792|       |            }
  793|       |            else {
  794|       |               if (not glz::atoi(value, it, end)) [[unlikely]] {
  795|       |                  ctx.error = error_code::parse_number_failure;
  796|       |                  return;
  797|       |               }
  798|       |            }
  799|       |         }
  800|  1.95M|         else {
  801|       |// float128_t requires std::from_chars for floating-point, unavailable on older Apple platforms (iOS < 16.3)
  802|  1.95M|#if !defined(_LIBCPP_VERSION) || defined(_LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT)
  803|       |            if constexpr (is_float128<V>) {
  804|       |               auto [ptr, ec] = std::from_chars(it, end, value);
  805|       |               if (ec != std::errc()) {
  806|       |                  ctx.error = error_code::parse_number_failure;
  807|       |                  return;
  808|       |               }
  809|       |               it = ptr;
  810|       |            }
  811|       |            else
  812|       |#endif
  813|  1.95M|            {
  814|       |               if constexpr (std::is_volatile_v<std::remove_reference_t<decltype(value)>>) {
  815|       |                  // Hardware may interact with value changes, so we parse into a temporary and assign in one
  816|       |                  // place
  817|       |                  V temp;
  818|       |                  if constexpr (is_size_optimized(Opts)) {
  819|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, temp);
  820|       |                     if (ec != std::errc{}) [[unlikely]] {
  821|       |                        ctx.error = error_code::parse_number_failure;
  822|       |                        return;
  823|       |                     }
  824|       |                     it = ptr;
  825|       |                  }
  826|       |                  else {
  827|       |                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, temp);
  828|       |                     if (ec != std::errc()) [[unlikely]] {
  829|       |                        ctx.error = error_code::parse_number_failure;
  830|       |                        return;
  831|       |                     }
  832|       |                     it = ptr;
  833|       |                  }
  834|       |                  value = temp;
  835|       |               }
  836|  1.95M|               else {
  837|       |                  if constexpr (is_size_optimized(Opts)) {
  838|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, value);
  839|       |                     if (ec != std::errc{}) [[unlikely]] {
  840|       |                        ctx.error = error_code::parse_number_failure;
  841|       |                        return;
  842|       |                     }
  843|       |                     it = ptr;
  844|       |                  }
  845|  1.95M|                  else {
  846|  1.95M|                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, value);
  847|  1.95M|                     if (ec != std::errc()) [[unlikely]] {
  ------------------
  |  Branch (847:26): [True: 1.55k, False: 1.95M]
  ------------------
  848|  1.55k|                        ctx.error = error_code::parse_number_failure;
  849|  1.55k|                        return;
  850|  1.55k|                     }
  851|  1.95M|                     it = ptr;
  852|  1.95M|                  }
  853|  1.95M|               }
  854|  1.95M|            }
  855|  1.95M|         }
  856|       |
  857|       |         if constexpr (check_quoted_num(Opts)) {
  858|       |            if constexpr (not Opts.null_terminated) {
  859|       |               if (it == end) [[unlikely]] {
  860|       |                  ctx.error = error_code::unexpected_end;
  861|       |                  return;
  862|       |               }
  863|       |            }
  864|       |            if (match<'"'>(ctx, it)) {
  865|       |               return;
  866|       |            }
  867|       |            if constexpr (not Opts.null_terminated) {
  868|       |               if (it == end) {
  869|       |                  ctx.error = error_code::end_reached;
  870|       |                  return;
  871|       |               }
  872|       |            }
  873|       |         }
  874|  1.95M|         else {
  875|       |            if constexpr (not Opts.null_terminated) {
  876|       |               if (it == end) {
  877|       |                  ctx.error = error_code::end_reached;
  878|       |                  return;
  879|       |               }
  880|       |            }
  881|  1.95M|         }
  882|  1.95M|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.95M, False: 1.55k]
  |  Branch (3795:38): [True: 0, False: 1.55k]
  |  Branch (3795:51): [True: 0, False: 1.55k]
  ------------------
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.55k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.55k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.95M, False: 1.55k]
  |  Branch (3795:38): [True: 0, False: 1.55k]
  |  Branch (3795:51): [True: 0, False: 1.55k]
  ------------------
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.55k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.55k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.95M, False: 1.55k]
  |  Branch (3795:38): [True: 0, False: 1.55k]
  |  Branch (3795:51): [True: 0, False: 1.55k]
  ------------------
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.55k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.55k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.95M, False: 1.55k]
  |  Branch (3795:38): [True: 0, False: 1.55k]
  |  Branch (3795:51): [True: 0, False: 1.55k]
  ------------------
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.55k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.55k|               });
_ZN3glz9read_jsonITkNS_14read_supportedIL_ZNS_4JSONEEEENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_9is_bufferERNSt3__16vectorIcNS6_9allocatorIcEEEEQnt18is_input_streamingIu20__remove_reference_tIT0_EEEENS_9error_ctxERT_OSC_:
 5266|  11.0k|   {
 5267|  11.0k|      context ctx{};
 5268|  11.0k|      return read<opts{}>(value, std::forward<Buffer>(buffer), ctx);
 5269|  11.0k|   }
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  11.0k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  11.0k|         else {
   60|  11.0k|            using V = std::remove_cvref_t<T>;
   61|  11.0k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  11.0k|                                             end);
   63|  11.0k|         }
   64|  11.0k|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  11.0k|      {
  151|  11.0k|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  11.0k|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  11.0k|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  11.0k|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 4065|  11.0k|      {
 4066|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 4067|       |            read_adjacent<Options>(value, ctx, it, end);
 4068|       |         }
 4069|  11.0k|         else {
 4070|  11.0k|            read_deduced<Options>(value, ctx, it, end);
 4071|  11.0k|         }
 4072|  11.0k|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE12read_deducedITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 4076|  11.0k|      {
 4077|  11.0k|         constexpr auto Opts = ws_handled_off<Options>();
 4078|  11.0k|         if constexpr (variant_is_auto_deducible<T>()) {
 4079|  11.0k|            if constexpr (not check_ws_handled(Options)) {
 4080|  11.0k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (4080:20): [True: 0, False: 11.0k]
  ------------------
 4081|      0|                  return;
 4082|      0|               }
 4083|  11.0k|            }
 4084|       |
 4085|  11.0k|            switch (*it) {
 4086|     15|            case '\0':
  ------------------
  |  Branch (4086:13): [True: 15, False: 11.0k]
  ------------------
 4087|     15|               ctx.error = error_code::unexpected_end;
 4088|     15|               return;
 4089|  5.03k|            case '{': {
  ------------------
  |  Branch (4089:13): [True: 5.03k, False: 6.03k]
  ------------------
 4090|       |               // This branch consumes the brace itself and hands the object to a reader with
 4091|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 4092|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 4093|       |               // the reader below.
 4094|  5.03k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (4094:20): [True: 0, False: 5.03k]
  ------------------
 4095|      0|                  return;
 4096|      0|               }
 4097|       |
 4098|  5.03k|               ++it;
 4099|       |               if constexpr (not Opts.null_terminated) {
 4100|       |                  if (it == end) [[unlikely]] {
 4101|       |                     ctx.error = error_code::unexpected_end;
 4102|       |                     return;
 4103|       |                  }
 4104|       |               }
 4105|  5.03k|               using type_counts = variant_type_count<T>;
 4106|  5.03k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 4107|       |               if constexpr (n_object_candidates < 1) {
 4108|       |                  ctx.error = error_code::no_matching_variant_type;
 4109|       |                  return;
 4110|       |               }
 4111|  5.03k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 4112|  5.03k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 4113|  5.03k|                  using V = std::variant_alternative_t<first_idx, T>;
 4114|  5.03k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4114:23): [True: 5.03k, False: 0]
  ------------------
 4115|  5.03k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 4116|  5.03k|                  return;
 4117|       |               }
 4118|       |               else {
 4119|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 4120|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 4121|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 4122|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 4123|       |
 4124|       |                  // Track if we've encountered a tag and what value it had
 4125|       |                  std::optional<size_t> tag_specified_index{};
 4126|       |
 4127|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 4128|       |                     return;
 4129|       |                  }
 4130|       |                  // Once the reader knows which alternative this object holds it may have to read
 4131|       |                  // it again from here. Anchor the position rather than keep the pointer: the scan
 4132|       |                  // below skips values, and a streaming skip refills, which moves the window out
 4133|       |                  // from under a raw pointer (see rewind_anchor).
 4134|       |                  auto start = make_rewind_anchor(ctx, it);
 4135|       |                  bool first_key = true;
 4136|       |                  // Parse bifurcation for tagged variants:
 4137|       |                  //
 4138|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 4139|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 4140|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 4141|       |                  //
 4142|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 4143|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 4144|       |                  // it advances past the trailing comma so the object parser picks up at the
 4145|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 4146|       |                  //
 4147|       |                  // One exception: if the tag name is also a field on the resolved struct
 4148|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 4149|       |                  // the struct field. This override is applied inside each std::visit lambda.
 4150|       |                  //
 4151|       |                  // Either way the rewind can fail under a streaming read: the window only holds so
 4152|       |                  // much, and an object wider than it has no start left to return to.
 4153|       |                  auto position_after_tag = [&] {
 4154|       |                     if (first_key) {
 4155|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 4156|       |                        return true;
 4157|       |                     }
 4158|       |                     return start.rewind(ctx, it, end); // tag came later, re-parse from the beginning
 4159|       |                  };
 4160|       |                  // `first_key` also answers "were we reset to the object start", which is what
 4161|       |                  // position_after_tag does for every key but the first.
 4162|       |                  for (; *it != '}'; first_key = false) {
 4163|       |                     if (!first_key) {
 4164|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 4165|       |                           return;
 4166|       |                        }
 4167|       |                     }
 4168|       |
 4169|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4170|       |                        return;
 4171|       |                     }
 4172|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4173|       |                        return;
 4174|       |                     }
 4175|       |
 4176|       |                     auto* key_start = it;
 4177|       |                     skip_string_view(ctx, it, end);
 4178|       |                     if (bool(ctx.error)) [[unlikely]]
 4179|       |                        return;
 4180|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 4181|       |                        return;
 4182|       |                     const sv key = {key_start, size_t(it - key_start)};
 4183|       |
 4184|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4185|       |                        return;
 4186|       |                     }
 4187|       |
 4188|       |                     if constexpr (deduction_key_count > 0) {
 4189|       |                        // We first check if a tag is defined and see if the key matches the tag
 4190|       |                        if constexpr (not tag_v<T>.empty()) {
 4191|       |                           if (key == tag_v<T>) {
 4192|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 4193|       |                                 return;
 4194|       |                              }
 4195|       |
 4196|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 4197|       |
 4198|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 4199|       |                              if constexpr (std::integral<id_type>) {
 4200|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4201|       |                              }
 4202|       |                              else {
 4203|       |                                 // The id is turned into an index below and never leaves this
 4204|       |                                 // reader, so the view of the window it borrows cannot outlive it.
 4205|       |                                 parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4206|       |                              }
 4207|       |                              if (bool(ctx.error)) [[unlikely]]
 4208|       |                                 return;
 4209|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4210|       |                                 return;
 4211|       |                              }
 4212|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4213|       |                                 ctx.error = error_code::syntax_error;
 4214|       |                                 return;
 4215|       |                              }
 4216|       |
 4217|       |                              size_t type_index;
 4218|       |                              if constexpr (std::integral<id_type>) {
 4219|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4220|       |                              }
 4221|       |                              else {
 4222|       |                                 type_index = variant_id_to_index<T>::op(
 4223|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4224|       |                              }
 4225|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4226|       |                                 // Check if the deduced types include the tag-specified type
 4227|       |                                 // If not, the tag doesn't match the fields
 4228|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4229|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4230|       |                                 // Check if the tag-specified type is still possible
 4231|       |                                 const bool type_is_possible = possible_types[type_index];
 4232|       |                                 if (!type_is_possible) {
 4233|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4234|       |                                    ctx.error = error_code::no_matching_variant_type;
 4235|       |                                    return;
 4236|       |                                 }
 4237|       |
 4238|       |                                 if (!position_after_tag()) return;
 4239|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4240|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4241|       |                                 std::visit(
 4242|       |                                    [&](auto&& v) {
 4243|       |                                       using V = std::decay_t<decltype(v)>;
 4244|       |                                       constexpr bool is_object =
 4245|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4246|       |                                       if constexpr (variant_unit_alternative<V>) {
 4247|       |                                          // A unit alternative carries no data; its object holds only the
 4248|       |                                          // discriminator. Consume that body through an empty reflected object so
 4249|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4250|       |                                          detail::variant_unit_body unit_body{};
 4251|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4252|       |                                                                                             tag_literal>(unit_body,
 4253|       |                                                                                                          ctx, it, end);
 4254|       |                                       }
 4255|       |                                       else if constexpr (is_object) {
 4256|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4257|       |                                             // tag is a struct field, must re-parse
 4258|       |                                             if (!start.rewind(ctx, it, end)) return;
 4259|       |                                          }
 4260|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4261|       |                                                                                                           end);
 4262|       |                                       }
 4263|       |                                       else if constexpr (is_memory_object<V>) {
 4264|       |                                          if (!v) {
 4265|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4266|       |                                                if constexpr (requires { v.emplace(); }) {
 4267|       |                                                   v.emplace();
 4268|       |                                                }
 4269|       |                                                else {
 4270|       |                                                   v = typename V::value_type{};
 4271|       |                                                }
 4272|       |                                             }
 4273|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4274|       |                                                v = std::make_unique<typename V::element_type>();
 4275|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4276|       |                                                v = std::make_shared<typename V::element_type>();
 4277|       |                                             else if constexpr (constructible<V>) {
 4278|       |                                                v = meta_construct_v<V>();
 4279|       |                                             }
 4280|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4281|       |                                                                can_allocate_raw_pointer<Opts,
 4282|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4283|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4284|       |                                                   return;
 4285|       |                                                }
 4286|       |                                             }
 4287|       |                                             else {
 4288|       |                                                ctx.error = error_code::invalid_nullable_read;
 4289|       |                                                return;
 4290|       |                                                // Cannot read into unset nullable that is not std::optional,
 4291|       |                                                // std::unique_ptr, or std::shared_ptr
 4292|       |                                             }
 4293|       |                                          }
 4294|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4295|       |                                             // tag is a struct field, must re-parse
 4296|       |                                             if (!start.rewind(ctx, it, end)) return;
 4297|       |                                          }
 4298|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4299|       |                                             *v, ctx, it, end);
 4300|       |                                       }
 4301|       |                                       else if constexpr (custom_read<V>) {
 4302|       |                                          // Custom handlers parse the remaining body themselves and do not
 4303|       |                                          // accept the tag template parameter; the tag was already consumed.
 4304|       |                                          // This only works when the tag was the first key. If it came later,
 4305|       |                                          // we were reset to the object start and the custom handler would
 4306|       |                                          // absorb the tag, so error rather than corrupt the value.
 4307|       |                                          if (!first_key) {
 4308|       |                                             ctx.error = error_code::feature_not_supported;
 4309|       |                                             ctx.custom_error_message =
 4310|       |                                                "the tag must be the first key for a custom variant alternative";
 4311|       |                                             return;
 4312|       |                                          }
 4313|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4314|       |                                       }
 4315|       |                                    },
 4316|       |                                    value);
 4317|       |
 4318|       |                                 return; // we've decoded our target type
 4319|       |                              }
 4320|       |                              else [[unlikely]] {
 4321|       |                                 // Check if we have a default type (ids array shorter than variant)
 4322|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4323|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4324|       |                                 if constexpr (ids_size < variant_size) {
 4325|       |                                    // Use the first unlabeled type as the default
 4326|       |                                    const auto default_type_index = ids_size;
 4327|       |
 4328|       |                                    if (!position_after_tag()) return;
 4329|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4330|       |                                    if (value.index() != default_type_index)
 4331|       |                                       emplace_runtime_variant(value, default_type_index);
 4332|       |                                    std::visit(
 4333|       |                                       [&](auto&& v) {
 4334|       |                                          using V = std::decay_t<decltype(v)>;
 4335|       |                                          constexpr bool is_object =
 4336|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4337|       |                                          if constexpr (variant_unit_alternative<V>) {
 4338|       |                                             // A unit alternative carries no data; its object holds only the
 4339|       |                                             // discriminator. Consume that body through an empty reflected object so
 4340|       |                                             // unknown-key policy and terminator handling match every other
 4341|       |                                             // alternative.
 4342|       |                                             detail::variant_unit_body unit_body{};
 4343|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4344|       |                                                                                                tag_literal>(
 4345|       |                                                unit_body, ctx, it, end);
 4346|       |                                          }
 4347|       |                                          else if constexpr (is_object) {
 4348|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4349|       |                                                // tag is a struct field, must re-parse
 4350|       |                                                if (!start.rewind(ctx, it, end)) return;
 4351|       |                                             }
 4352|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4353|       |                                          }
 4354|       |                                          else if constexpr (is_memory_object<V>) {
 4355|       |                                             if (!v) {
 4356|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4357|       |                                                   if constexpr (requires { v.emplace(); }) {
 4358|       |                                                      v.emplace();
 4359|       |                                                   }
 4360|       |                                                   else {
 4361|       |                                                      v = typename V::value_type{};
 4362|       |                                                   }
 4363|       |                                                }
 4364|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4365|       |                                                   v = std::make_unique<typename V::element_type>();
 4366|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4367|       |                                                   v = std::make_shared<typename V::element_type>();
 4368|       |                                                else if constexpr (constructible<V>) {
 4369|       |                                                   v = meta_construct_v<V>();
 4370|       |                                                }
 4371|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4372|       |                                                                   can_allocate_raw_pointer<
 4373|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4374|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4375|       |                                                      return;
 4376|       |                                                   }
 4377|       |                                                }
 4378|       |                                                else {
 4379|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4380|       |                                                   return;
 4381|       |                                                }
 4382|       |                                             }
 4383|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4384|       |                                                // tag is a struct field, must re-parse
 4385|       |                                                if (!start.rewind(ctx, it, end)) return;
 4386|       |                                             }
 4387|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4388|       |                                                                                                              it, end);
 4389|       |                                          }
 4390|       |                                          else if constexpr (custom_read<V>) {
 4391|       |                                             // Custom handlers parse the remaining body themselves; this only
 4392|       |                                             // works when the tag was the first key (see above). If it came
 4393|       |                                             // later we were reset to the object start, so error rather than
 4394|       |                                             // let the custom handler absorb the tag.
 4395|       |                                             if (!first_key) {
 4396|       |                                                ctx.error = error_code::feature_not_supported;
 4397|       |                                                ctx.custom_error_message =
 4398|       |                                                   "the tag must be the first key for a custom variant alternative";
 4399|       |                                                return;
 4400|       |                                             }
 4401|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4402|       |                                          }
 4403|       |                                       },
 4404|       |                                       value);
 4405|       |
 4406|       |                                    return;
 4407|       |                                 }
 4408|       |                                 else {
 4409|       |                                    ctx.error = error_code::no_matching_variant_type;
 4410|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4411|       |                                    return;
 4412|       |                                 }
 4413|       |                              }
 4414|       |                           }
 4415|       |                        }
 4416|       |
 4417|       |                        // Inline decode_hash lookup for variant deduction
 4418|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4419|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4420|       |                        const auto deduction_index =
 4421|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4422|       |                              key.data(), key.data() + key.size(), key.size());
 4423|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4424|       |                           [[likely]] {
 4425|       |                           possible_types &= deduction_bits[deduction_index];
 4426|       |                        }
 4427|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4428|       |                           ctx.error = error_code::unknown_key;
 4429|       |                           return;
 4430|       |                        }
 4431|       |                     }
 4432|       |                     else if constexpr (not tag_v<T>.empty()) {
 4433|       |                        // empty object case for variant, if there are no normal elements
 4434|       |                        if (key == tag_v<T>) {
 4435|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4436|       |                              return;
 4437|       |                           }
 4438|       |
 4439|       |                           // The id is turned into an index below and never leaves this reader,
 4440|       |                           // so the view of the window it borrows cannot outlive that window.
 4441|       |                           std::string_view type_id{};
 4442|       |                           parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4443|       |                           if (bool(ctx.error)) [[unlikely]]
 4444|       |                              return;
 4445|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4446|       |                              return;
 4447|       |                           }
 4448|       |
 4449|       |                           const auto type_index = variant_id_to_index<T>::op(
 4450|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4451|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4452|       |                              if (!position_after_tag()) return;
 4453|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4454|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4455|       |                           }
 4456|       |                           else {
 4457|       |                              // Check if we have a default type (ids array shorter than variant)
 4458|       |                              constexpr auto ids_size = ids_v<T>.size();
 4459|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4460|       |                              if constexpr (ids_size < variant_size) {
 4461|       |                                 // Use the first unlabeled type as the default
 4462|       |                                 if (!position_after_tag()) return;
 4463|       |                                 const auto default_index = ids_size;
 4464|       |                                 tag_specified_index = default_index; // Store the default type index
 4465|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4466|       |                              }
 4467|       |                              else {
 4468|       |                                 ctx.error = error_code::no_matching_variant_type;
 4469|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4470|       |                                 return;
 4471|       |                              }
 4472|       |                           }
 4473|       |                           // Parse the type (handles tag skipping and unknown keys)
 4474|       |                           std::visit(
 4475|       |                              [&](auto&& v) {
 4476|       |                                 using V = std::decay_t<decltype(v)>;
 4477|       |                                 if constexpr (custom_read<V>) {
 4478|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4479|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4480|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4481|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4482|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4483|       |                                    // into its value, so error here rather than corrupt the result.
 4484|       |                                    if (!first_key) {
 4485|       |                                       ctx.error = error_code::feature_not_supported;
 4486|       |                                       ctx.custom_error_message =
 4487|       |                                          "the tag must be the first key for a custom variant alternative";
 4488|       |                                       return;
 4489|       |                                    }
 4490|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4491|       |                                 }
 4492|       |                                 else {
 4493|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4494|       |                                       // tag is a struct field, must re-parse
 4495|       |                                       if (!start.rewind(ctx, it, end)) return;
 4496|       |                                    }
 4497|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4498|       |                                 }
 4499|       |                              },
 4500|       |                              value);
 4501|       |                           return;
 4502|       |                        }
 4503|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4504|       |                           ctx.error = error_code::unknown_key;
 4505|       |                           return;
 4506|       |                        }
 4507|       |                        else {
 4508|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4509|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4510|       |                              return;
 4511|       |                           }
 4512|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4513|       |                           if (bool(ctx.error)) [[unlikely]]
 4514|       |                              return;
 4515|       |                           resync_window_end(ctx, end); // a streaming skip refills
 4516|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4517|       |                              return;
 4518|       |                           }
 4519|       |                           continue; // Continue loop to find the tag
 4520|       |                        }
 4521|       |                     }
 4522|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4523|       |                        ctx.error = error_code::unknown_key;
 4524|       |                        return;
 4525|       |                     }
 4526|       |
 4527|       |                     auto matching_types = possible_types.popcount();
 4528|       |                     if (matching_types == 0) {
 4529|       |                        ctx.error = error_code::no_matching_variant_type;
 4530|       |                        return;
 4531|       |                     }
 4532|       |                     // Only short-circuit for variants without tags
 4533|       |                     else if constexpr (tag_v<T>.empty()) {
 4534|       |                        if (matching_types == 1) {
 4535|       |                           if (!start.rewind(ctx, it, end)) return;
 4536|       |                           const auto type_index = possible_types.countr_zero();
 4537|       |
 4538|       |                           if (value.index() != static_cast<size_t>(type_index))
 4539|       |                              emplace_runtime_variant(value, type_index);
 4540|       |                           std::visit(
 4541|       |                              [&](auto&& v) {
 4542|       |                                 using V = std::decay_t<decltype(v)>;
 4543|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4544|       |                                 if constexpr (variant_unit_alternative<V>) {
 4545|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4546|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4547|       |                                    // terminator handling match every other alternative.
 4548|       |                                    detail::variant_unit_body unit_body{};
 4549|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4550|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4551|       |                                                                                                    end);
 4552|       |                                 }
 4553|       |                                 else if constexpr (is_object) {
 4554|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4555|       |                                 }
 4556|       |                                 else if constexpr (is_memory_object<V>) {
 4557|       |                                    if (!v) {
 4558|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4559|       |                                          if constexpr (requires { v.emplace(); }) {
 4560|       |                                             v.emplace();
 4561|       |                                          }
 4562|       |                                          else {
 4563|       |                                             v = typename V::value_type{};
 4564|       |                                          }
 4565|       |                                       }
 4566|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4567|       |                                          v = std::make_unique<typename V::element_type>();
 4568|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4569|       |                                          v = std::make_shared<typename V::element_type>();
 4570|       |                                       else if constexpr (constructible<V>) {
 4571|       |                                          v = meta_construct_v<V>();
 4572|       |                                       }
 4573|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4574|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4575|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4576|       |                                             return;
 4577|       |                                          }
 4578|       |                                       }
 4579|       |                                       else {
 4580|       |                                          ctx.error = error_code::invalid_nullable_read;
 4581|       |                                          return;
 4582|       |                                          // Cannot read into unset nullable that is not std::optional,
 4583|       |                                          // std::unique_ptr, or std::shared_ptr
 4584|       |                                       }
 4585|       |                                    }
 4586|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4587|       |                                       *v, ctx, it, end);
 4588|       |                                 }
 4589|       |                                 else if constexpr (custom_read<V>) {
 4590|       |                                    // Custom handlers parse the remaining body themselves.
 4591|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4592|       |                                 }
 4593|       |                              },
 4594|       |                              value);
 4595|       |
 4596|       |                           return; // we've decoded our target type
 4597|       |                        }
 4598|       |                     }
 4599|       |                     // For tagged variants, continue processing to validate tags
 4600|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4601|       |                        return;
 4602|       |                     }
 4603|       |
 4604|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4605|       |                     if (bool(ctx.error)) [[unlikely]]
 4606|       |                        return;
 4607|       |                     resync_window_end(ctx, end); // a streaming skip refills
 4608|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4609|       |                        return;
 4610|       |                     }
 4611|       |                  }
 4612|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4613|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4614|       |                     // After parsing all keys, check if we have multiple matching types
 4615|       |                     // If so, choose the one with the fewest fields
 4616|       |                     auto final_matching = possible_types.popcount();
 4617|       |                     if (final_matching == 0) {
 4618|       |                        ctx.error = error_code::no_matching_variant_type;
 4619|       |                     }
 4620|       |                     else if (final_matching == 1) {
 4621|       |                        // Single type remains after field deduction
 4622|       |                        const auto type_index = possible_types.countr_zero();
 4623|       |
 4624|       |                        // Validate against tag if one was specified
 4625|       |                        if (tag_specified_index.has_value() &&
 4626|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4627|       |                           ctx.error = error_code::no_matching_variant_type;
 4628|       |                           return;
 4629|       |                        }
 4630|       |
 4631|       |                        if (!start.rewind(ctx, it, end)) return;
 4632|       |                        if (value.index() != static_cast<size_t>(type_index))
 4633|       |                           emplace_runtime_variant(value, type_index);
 4634|       |                        std::visit(
 4635|       |                           [&](auto&& v) {
 4636|       |                              using V = std::decay_t<decltype(v)>;
 4637|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4638|       |                              if constexpr (variant_unit_alternative<V>) {
 4639|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4640|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4641|       |                                 // terminator handling match every other alternative.
 4642|       |                                 detail::variant_unit_body unit_body{};
 4643|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4644|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4645|       |                                                                                                 end);
 4646|       |                              }
 4647|       |                              else if constexpr (is_object) {
 4648|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4649|       |                              }
 4650|       |                              else if constexpr (is_memory_object<V>) {
 4651|       |                                 if (!v) {
 4652|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4653|       |                                       if constexpr (requires { v.emplace(); }) {
 4654|       |                                          v.emplace();
 4655|       |                                       }
 4656|       |                                       else {
 4657|       |                                          v = typename V::value_type{};
 4658|       |                                       }
 4659|       |                                    }
 4660|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4661|       |                                       v = std::make_unique<typename V::element_type>();
 4662|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4663|       |                                       v = std::make_shared<typename V::element_type>();
 4664|       |                                    else if constexpr (constructible<V>) {
 4665|       |                                       v = meta_construct_v<V>();
 4666|       |                                    }
 4667|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4668|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4669|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4670|       |                                          return;
 4671|       |                                       }
 4672|       |                                    }
 4673|       |                                    else {
 4674|       |                                       ctx.error = error_code::invalid_nullable_read;
 4675|       |                                       return;
 4676|       |                                    }
 4677|       |                                 }
 4678|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4679|       |                                                                                                               it, end);
 4680|       |                              }
 4681|       |                              else if constexpr (custom_read<V>) {
 4682|       |                                 // Custom handlers parse the remaining body themselves.
 4683|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4684|       |                              }
 4685|       |                           },
 4686|       |                           value);
 4687|       |                     }
 4688|       |                     else if (final_matching > 1) {
 4689|       |                        constexpr auto N = std::variant_size_v<T>;
 4690|       |
 4691|       |                        // Compile-time array of field counts for each variant type
 4692|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4693|       |                           return std::array<size_t, N> {
 4694|       |                              ([]<size_t J = I>() -> size_t {
 4695|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4696|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4697|       |                                    return reflect<V>::size;
 4698|       |                                 }
 4699|       |                                 else if constexpr (is_memory_object<V>) {
 4700|       |                                    using X = memory_type<V>;
 4701|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4702|       |                                       return reflect<X>::size;
 4703|       |                                    }
 4704|       |                                    else {
 4705|       |                                       return (std::numeric_limits<size_t>::max)();
 4706|       |                                    }
 4707|       |                                 }
 4708|       |                                 else {
 4709|       |                                    return (std::numeric_limits<size_t>::max)();
 4710|       |                                 }
 4711|       |                              }.template operator()<I>())...
 4712|       |                           };
 4713|       |                        }(std::make_index_sequence<N>{});
 4714|       |
 4715|       |                        // Find the type with minimum field count among the possible types
 4716|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4717|       |                        size_t chosen_index = N; // Invalid index initially
 4718|       |
 4719|       |                        for (size_t i = 0; i < N; ++i) {
 4720|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4721|       |                              min_fields = field_counts[i];
 4722|       |                              chosen_index = i;
 4723|       |                           }
 4724|       |                        }
 4725|       |
 4726|       |                        if (chosen_index < N) {
 4727|       |                           // Validate against tag if one was specified
 4728|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4729|       |                              ctx.error = error_code::no_matching_variant_type;
 4730|       |                              return;
 4731|       |                           }
 4732|       |
 4733|       |                           if (!start.rewind(ctx, it, end)) return;
 4734|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4735|       |                           std::visit(
 4736|       |                              [&](auto&& v) {
 4737|       |                                 using V = std::decay_t<decltype(v)>;
 4738|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4739|       |                                 if constexpr (variant_unit_alternative<V>) {
 4740|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4741|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4742|       |                                    // terminator handling match every other alternative.
 4743|       |                                    detail::variant_unit_body unit_body{};
 4744|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4745|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4746|       |                                                                                                    end);
 4747|       |                                 }
 4748|       |                                 else if constexpr (is_object) {
 4749|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4750|       |                                 }
 4751|       |                                 else if constexpr (is_memory_object<V>) {
 4752|       |                                    if (!v) {
 4753|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4754|       |                                          if constexpr (requires { v.emplace(); }) {
 4755|       |                                             v.emplace();
 4756|       |                                          }
 4757|       |                                          else {
 4758|       |                                             v = typename V::value_type{};
 4759|       |                                          }
 4760|       |                                       }
 4761|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4762|       |                                          v = std::make_unique<typename V::element_type>();
 4763|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4764|       |                                          v = std::make_shared<typename V::element_type>();
 4765|       |                                       else if constexpr (constructible<V>) {
 4766|       |                                          v = meta_construct_v<V>();
 4767|       |                                       }
 4768|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4769|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4770|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4771|       |                                             return;
 4772|       |                                          }
 4773|       |                                       }
 4774|       |                                       else {
 4775|       |                                          ctx.error = error_code::invalid_nullable_read;
 4776|       |                                          return;
 4777|       |                                       }
 4778|       |                                    }
 4779|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4780|       |                                       *v, ctx, it, end);
 4781|       |                                 }
 4782|       |                                 else if constexpr (custom_read<V>) {
 4783|       |                                    // Custom handlers parse the remaining body themselves.
 4784|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4785|       |                                 }
 4786|       |                              },
 4787|       |                              value);
 4788|       |                        }
 4789|       |                        else {
 4790|       |                           ctx.error = error_code::no_matching_variant_type;
 4791|       |                        }
 4792|       |                     }
 4793|       |                  }
 4794|       |                  else {
 4795|       |                     // For variants with 0 or 1 object types, use the original error handling
 4796|       |                     ctx.error = error_code::no_matching_variant_type;
 4797|       |                  }
 4798|       |               }
 4799|      0|               break;
 4800|  5.03k|            }
 4801|  2.14k|            case '[':
  ------------------
  |  Branch (4801:13): [True: 2.14k, False: 8.93k]
  ------------------
 4802|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4803|  2.14k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4804|  2.14k|               break;
 4805|  1.11k|            case '"': {
  ------------------
  |  Branch (4805:13): [True: 1.11k, False: 9.95k]
  ------------------
 4806|  1.11k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4807|  1.11k|               break;
 4808|  5.03k|            }
 4809|     82|            case 't':
  ------------------
  |  Branch (4809:13): [True: 82, False: 10.9k]
  ------------------
 4810|    188|            case 'f': {
  ------------------
  |  Branch (4810:13): [True: 106, False: 10.9k]
  ------------------
 4811|    188|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4812|    188|               break;
 4813|     82|            }
 4814|     72|            case 'n':
  ------------------
  |  Branch (4814:13): [True: 72, False: 11.0k]
  ------------------
 4815|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4816|       |                  ctx.error = error_code::no_matching_variant_type;
 4817|       |               }
 4818|     72|               else {
 4819|     72|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4820|     72|                  using V = std::variant_alternative_t<first_idx, T>;
 4821|     72|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4821:23): [True: 0, False: 72]
  ------------------
 4822|     72|                  match<"null", Opts>(ctx, it, end);
 4823|     72|               }
 4824|     72|               break;
 4825|  2.50k|            default: {
  ------------------
  |  Branch (4825:13): [True: 2.50k, False: 8.57k]
  ------------------
 4826|       |               // Not bool, string, object, or array so must be number or null
 4827|  2.50k|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4828|  2.50k|            }
 4829|  11.0k|            }
 4830|       |         }
 4831|       |         else {
 4832|       |            // For non-auto-deducible variants, try each type until one succeeds
 4833|       |            constexpr auto N = std::variant_size_v<T>;
 4834|       |            bool parsed = false;
 4835|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4836|       |
 4837|       |            for_each<N>([&]<size_t I>() {
 4838|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4839|       |
 4840|       |               auto copy_it = it;
 4841|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4842|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4843|       |               const auto copy_depth = ctx.depth;
 4844|       |
 4845|       |               // Try parsing as this type
 4846|       |               if (value.index() != I) {
 4847|       |                  emplace_runtime_variant(value, I);
 4848|       |               }
 4849|       |
 4850|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4851|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4852|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4853|       |               }
 4854|       |
 4855|       |               if (!bool(ctx.error)) {
 4856|       |                  parsed = true;
 4857|       |               }
 4858|       |               else if constexpr (not Options.null_terminated) {
 4859|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4860|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4861|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4862|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4863|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4864|       |                     parsed = true;
 4865|       |                     ctx.error = error_code::none;
 4866|       |                  }
 4867|       |                  else {
 4868|       |                     // Reset for next attempt (unless this is the last type)
 4869|       |                     it = copy_it;
 4870|       |                     rewind_depth<Options>(ctx, copy_depth);
 4871|       |                     if constexpr (I + 1 < N) {
 4872|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4873|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4874|       |                        }
 4875|       |                     }
 4876|       |                  }
 4877|       |               }
 4878|       |               else {
 4879|       |                  // Reset for next attempt (unless this is the last type)
 4880|       |                  it = copy_it;
 4881|       |                  rewind_depth<Options>(ctx, copy_depth);
 4882|       |                  if constexpr (I + 1 < N) {
 4883|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4884|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4885|       |                     }
 4886|       |                  }
 4887|       |               }
 4888|       |            });
 4889|       |         }
 4890|  11.0k|      }
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj33EEERNS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES4_EEEETkNS_10is_contextERNS_7contextERPKcSD_EEvOT0_OT1_OT2_T3_:
   49|  25.3k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  25.3k|         else {
   60|  25.3k|            using V = std::remove_cvref_t<T>;
   61|  25.3k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  25.3k|                                             end);
   63|  25.3k|         }
   64|  25.3k|      }
_ZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj33EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_:
 3044|  25.3k|      {
 3045|  25.3k|         static constexpr auto num_members = reflect<T>::size;
 3046|       |
 3047|  25.3k|         static constexpr auto Opts = opening_handled_off<ws_handled_off<Options>()>();
 3048|       |         if constexpr (!check_opening_handled(Options)) {
 3049|       |            if constexpr (!check_ws_handled(Options)) {
 3050|       |               if (skip_ws<Opts>(ctx, it, end)) {
 3051|       |                  return;
 3052|       |               }
 3053|       |            }
 3054|       |            if (match_invalid_end<'{', Opts>(ctx, it, end)) {
 3055|       |               return;
 3056|       |            }
 3057|       |            if constexpr (not Opts.null_terminated) {
 3058|       |               if (it == end) [[unlikely]] {
 3059|       |                  ctx.error = error_code::unexpected_end;
 3060|       |                  return;
 3061|       |               }
 3062|       |            }
 3063|       |            // one nesting level (see enter_depth): counted in both modes so the limit binds,
 3064|       |            // released at each syntactic close below
 3065|       |            if (enter_depth(ctx)) [[unlikely]] {
 3066|       |               return;
 3067|       |            }
 3068|       |         }
 3069|  25.3k|         const auto ws_start = it;
 3070|  25.3k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3070:14): [True: 0, False: 25.3k]
  ------------------
 3071|      0|            return;
 3072|      0|         }
 3073|  25.3k|         const size_t ws_size = size_t(it - ws_start);
 3074|       |
 3075|       |         if constexpr ((glaze_object_t<T> || reflectable<T>) && num_members == 0 && Opts.error_on_unknown_keys) {
 3076|       |            if constexpr (not tag.sv().empty()) {
 3077|       |               if (*it == '"') {
 3078|       |                  ++it;
 3079|       |                  if constexpr (not Opts.null_terminated) {
 3080|       |                     if (it == end) [[unlikely]] {
 3081|       |                        ctx.error = error_code::unexpected_end;
 3082|       |                        return;
 3083|       |                     }
 3084|       |                  }
 3085|       |
 3086|       |                  const auto start = it;
 3087|       |                  skip_string_view(ctx, it, end);
 3088|       |                  if (bool(ctx.error)) [[unlikely]]
 3089|       |                     return;
 3090|       |                  if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3091|       |                     return;
 3092|       |                  const sv key{start, size_t(it - start)};
 3093|       |                  ++it;
 3094|       |                  if constexpr (not Opts.null_terminated) {
 3095|       |                     if (it == end) [[unlikely]] {
 3096|       |                        ctx.error = error_code::unexpected_end;
 3097|       |                        return;
 3098|       |                     }
 3099|       |                  }
 3100|       |
 3101|       |                  if (key == tag.sv()) {
 3102|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3103|       |                        return;
 3104|       |                     }
 3105|       |
 3106|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3107|       |                     if (bool(ctx.error)) [[unlikely]]
 3108|       |                        return;
 3109|       |
 3110|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3111|       |                        return;
 3112|       |                     }
 3113|       |                  }
 3114|       |                  else {
 3115|       |                     ctx.error = error_code::unknown_key;
 3116|       |                     return;
 3117|       |                  }
 3118|       |               }
 3119|       |            }
 3120|       |
 3121|       |            if (*it == '}') [[likely]] {
 3122|       |               --ctx.depth;
 3123|       |               if constexpr (glaze_object_t<T> || reflectable<T>) {
 3124|       |                  if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 3125|       |                     auto wrapper = self_constraint_v<T>(value);
 3126|       |                     from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 3127|       |                     if (bool(ctx.error)) {
 3128|       |                        return;
 3129|       |                     }
 3130|       |                  }
 3131|       |               }
 3132|       |               ++it;
 3133|       |               if constexpr (not Opts.null_terminated) {
 3134|       |                  if (it == end) {
 3135|       |                     ctx.error = error_code::end_reached;
 3136|       |                     return;
 3137|       |                  }
 3138|       |               }
 3139|       |               if constexpr (Opts.partial_read) {
 3140|       |                  ctx.error = error_code::partial_read_complete;
 3141|       |               }
 3142|       |               return;
 3143|       |            }
 3144|       |            ctx.error = error_code::unknown_key;
 3145|       |            return;
 3146|       |         }
 3147|  25.3k|         else {
 3148|  25.3k|            decltype(auto) fields = [&]() -> decltype(auto) {
 3149|  25.3k|               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 3150|  25.3k|                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 3151|  25.3k|                  return bit_array<num_members>{};
 3152|  25.3k|               }
 3153|  25.3k|               else {
 3154|  25.3k|                  return nullptr;
 3155|  25.3k|               }
 3156|  25.3k|            }();
 3157|       |
 3158|  25.3k|            size_t read_count{}; // for partial_read
 3159|       |
 3160|  25.3k|            bool first = true;
 3161|   896k|            while (true) {
  ------------------
  |  Branch (3161:20): [True: 873k, Folded]
  ------------------
 3162|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.partial_read) {
 3163|       |                  static constexpr bit_array<num_members> all_fields = [] {
 3164|       |                     bit_array<num_members> arr{};
 3165|       |                     for (size_t i = 0; i < num_members; ++i) {
 3166|       |                        arr[i] = true;
 3167|       |                     }
 3168|       |                     return arr;
 3169|       |                  }();
 3170|       |
 3171|       |                  if ((all_fields & fields) == all_fields) {
 3172|       |                     ctx.error = error_code::partial_read_complete;
 3173|       |                     --ctx.depth; // as above: an early success still closes this level
 3174|       |                     return;
 3175|       |                  }
 3176|       |               }
 3177|       |
 3178|       |               // Streaming refill point: at start of each iteration, ensure buffer has data
 3179|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 3180|       |                  if (ctx.stream.enabled()) {
 3181|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 3182|       |                     const size_t remaining = ctx.stream.size() - consumed;
 3183|       |                     // Refill when less than half of buffer remains to ensure space for next key-value pair
 3184|       |                     if (remaining <= ctx.stream.size() / 2 || it >= end) {
 3185|       |                        const char* new_it;
 3186|       |                        const char* new_end;
 3187|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 3188|       |                        it = new_it;
 3189|       |                        end = new_end;
 3190|       |                        if (it >= end && ctx.stream.at_eof()) {
 3191|       |                           ctx.error = error_code::unexpected_end;
 3192|       |                           return;
 3193|       |                        }
 3194|       |                     }
 3195|       |                  }
 3196|       |               }
 3197|       |
 3198|   873k|               if (*it == '}') {
  ------------------
  |  Branch (3198:20): [True: 2.10k, False: 871k]
  ------------------
 3199|  2.10k|                  --ctx.depth;
 3200|       |                  if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.error_on_missing_keys) {
 3201|       |                     constexpr auto req_fields = required_fields<T, Opts>();
 3202|       |                     if ((req_fields & fields) != req_fields) {
 3203|       |                        for (size_t i = 0; i < num_members; ++i) {
 3204|       |                           if (not fields[i] && req_fields[i]) {
 3205|       |                              ctx.custom_error_message = reflect<T>::keys[i];
 3206|       |                              // We just return the first missing key in order to avoid heap allocations
 3207|       |                              break;
 3208|       |                           }
 3209|       |                        }
 3210|       |
 3211|       |                        ctx.error = error_code::missing_key;
 3212|       |                        return;
 3213|       |                     }
 3214|       |                  }
 3215|       |                  if constexpr (glaze_object_t<T> || reflectable<T>) {
 3216|       |                     if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 3217|       |                        auto wrapper = self_constraint_v<T>(value);
 3218|       |                        from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 3219|       |                        if (bool(ctx.error)) {
 3220|       |                           return;
 3221|       |                        }
 3222|       |                     }
 3223|       |                  }
 3224|  2.10k|                  ++it; // Increment after checking for missing keys so errors are within buffer bounds
 3225|       |                  if constexpr (not Opts.null_terminated) {
 3226|       |                     if (it == end) {
 3227|       |                        ctx.error = error_code::end_reached;
 3228|       |                        return;
 3229|       |                     }
 3230|       |                  }
 3231|  2.10k|                  return;
 3232|  2.10k|               }
 3233|   871k|               else if (first) {
  ------------------
  |  Branch (3233:25): [True: 23.5k, False: 847k]
  ------------------
 3234|  23.5k|                  first = false;
 3235|  23.5k|               }
 3236|   847k|               else {
 3237|   847k|                  if (match_invalid_end<',', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3237:23): [True: 522, False: 847k]
  ------------------
 3238|    522|                     return;
 3239|    522|                  }
 3240|       |                  if constexpr (not Opts.null_terminated) {
 3241|       |                     if (it == end) [[unlikely]] {
 3242|       |                        ctx.error = error_code::unexpected_end;
 3243|       |                        return;
 3244|       |                     }
 3245|       |                  }
 3246|       |
 3247|       |                  if constexpr ((not Opts.minified) && (num_members > 1 || not Opts.error_on_unknown_keys) &&
 3248|       |                                (!Opts.comments)) {
 3249|       |                     if (ws_size && ws_size < size_t(end - it)) {
 3250|       |                        skip_matching_ws(ws_start, it, ws_size);
 3251|       |                     }
 3252|       |                  }
 3253|       |
 3254|   847k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3254:23): [True: 0, False: 847k]
  ------------------
 3255|      0|                     return;
 3256|      0|                  }
 3257|   847k|               }
 3258|       |
 3259|   870k|               constexpr auto reflection_type = glaze_object_t<T> || reflectable<T>;
  ------------------
  |  Branch (3259:49): [Folded, False: 0]
  |  Branch (3259:70): [Folded, False: 0]
  ------------------
 3260|       |
 3261|       |               if constexpr (reflection_type && (num_members == 0)) {
 3262|       |                  if constexpr (Opts.error_on_unknown_keys) {
 3263|       |                     static_assert(false_v<T>, "This should be unreachable");
 3264|       |                  }
 3265|       |                  else {
 3266|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 3267|       |                        return;
 3268|       |                     }
 3269|       |
 3270|       |                     // parsing to an empty object, but at this point the JSON presents keys
 3271|       |
 3272|       |                     // Unknown key handler does not unescape keys. Unknown escaped keys are
 3273|       |                     // handled by the user.
 3274|       |
 3275|       |                     const auto start = it;
 3276|       |                     skip_string_view(ctx, it, end);
 3277|       |                     if (bool(ctx.error)) [[unlikely]]
 3278|       |                        return;
 3279|       |                     if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3280|       |                        return;
 3281|       |                     const sv key{start, size_t(it - start)};
 3282|       |                     ++it;
 3283|       |                     if constexpr (not Opts.null_terminated) {
 3284|       |                        if (it == end) [[unlikely]] {
 3285|       |                           ctx.error = error_code::unexpected_end;
 3286|       |                           return;
 3287|       |                        }
 3288|       |                     }
 3289|       |
 3290|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3291|       |                        return;
 3292|       |                     }
 3293|       |
 3294|       |                     // Check if this key is the variant tag that should be skipped
 3295|       |                     if constexpr (not tag.sv().empty()) {
 3296|       |                        if (key == tag.sv()) {
 3297|       |                           // Skip the tag value
 3298|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3299|       |                           if (bool(ctx.error)) [[unlikely]]
 3300|       |                              return;
 3301|       |                           resync_window_end(ctx, end); // a streaming skip refills
 3302|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 3303|       |                              return;
 3304|       |                           }
 3305|       |                           continue;
 3306|       |                        }
 3307|       |                     }
 3308|       |
 3309|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3310|       |                     if (bool(ctx.error)) [[unlikely]]
 3311|       |                        return;
 3312|       |                     if constexpr (not Opts.null_terminated) {
 3313|       |                        if (it == end) [[unlikely]] {
 3314|       |                           ctx.error = error_code::unexpected_end;
 3315|       |                           return;
 3316|       |                        }
 3317|       |                     }
 3318|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3319|       |                        return;
 3320|       |                     }
 3321|       |                  }
 3322|       |               }
 3323|       |               else if constexpr (reflection_type) {
 3324|       |                  static_assert(bool(hash_info<T>.type));
 3325|       |
 3326|       |                  if (*it != '"') [[unlikely]] {
 3327|       |                     ctx.error = error_code::expected_quote;
 3328|       |                     return;
 3329|       |                  }
 3330|       |                  ++it;
 3331|       |                  if constexpr (not Opts.null_terminated) {
 3332|       |                     if (it == end) [[unlikely]] {
 3333|       |                        ctx.error = error_code::unexpected_end;
 3334|       |                        return;
 3335|       |                     }
 3336|       |                  }
 3337|       |
 3338|       |                  if constexpr (not tag.sv().empty() && not contains_tag<T, tag>()) {
 3339|       |                     // For tagged variants we first check to see if the key matches the tag
 3340|       |                     // We only need to do this if the tag is not part of the keys
 3341|       |
 3342|       |                     const auto start = it;
 3343|       |                     skip_string_view(ctx, it, end);
 3344|       |                     if (bool(ctx.error)) [[unlikely]]
 3345|       |                        return;
 3346|       |                     if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3347|       |                        return;
 3348|       |                     const sv key{start, size_t(it - start)};
 3349|       |                     ++it;
 3350|       |                     if constexpr (not Opts.null_terminated) {
 3351|       |                        if (it == end) [[unlikely]] {
 3352|       |                           ctx.error = error_code::unexpected_end;
 3353|       |                           return;
 3354|       |                        }
 3355|       |                     }
 3356|       |
 3357|       |                     if (key == tag.sv()) {
 3358|       |                        if (parse_ws_colon<Opts>(ctx, it, end)) {
 3359|       |                           return;
 3360|       |                        }
 3361|       |
 3362|       |                        parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3363|       |                        if (bool(ctx.error)) [[unlikely]]
 3364|       |                           return;
 3365|       |
 3366|       |                        if (skip_ws<Opts>(ctx, it, end)) {
 3367|       |                           return;
 3368|       |                        }
 3369|       |                        continue;
 3370|       |                     }
 3371|       |                     else {
 3372|       |                        it = start; // reset the iterator
 3373|       |                     }
 3374|       |                  }
 3375|       |
 3376|       |                  if constexpr (Opts.error_on_missing_keys || Opts.partial_read) {
 3377|       |                     size_t index = num_members;
 3378|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end, index);
 3379|       |                     if (bool(ctx.error)) [[unlikely]]
 3380|       |                        return;
 3381|       |                     if (index < num_members) {
 3382|       |                        fields[index] = true;
 3383|       |                     }
 3384|       |                  }
 3385|       |                  else {
 3386|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end);
 3387|       |                     if (bool(ctx.error)) [[unlikely]]
 3388|       |                        return;
 3389|       |                  }
 3390|       |               }
 3391|   870k|               else {
 3392|       |                  // For types like std::map, std::unordered_map
 3393|       |
 3394|   870k|                  auto reading = [&](auto&& key) {
 3395|   870k|                     if constexpr (Opts.partial_read) {
 3396|   870k|                        if (auto element = value.find(key); element != value.end()) {
 3397|   870k|                           ++read_count;
 3398|   870k|                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3399|   870k|                        }
 3400|   870k|                        else {
 3401|   870k|                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3402|   870k|                        }
 3403|   870k|                     }
 3404|   870k|                     else {
 3405|   870k|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3406|   870k|                     }
 3407|   870k|                  };
 3408|       |
 3409|       |                  // using Key = std::conditional_t<heterogeneous_map<T>, sv, typename T::key_type>;
 3410|   870k|                  using Key = typename T::key_type;
 3411|   870k|                  if constexpr (std::is_same_v<Key, std::string>) {
 3412|   870k|                     ctx.scratch.clear();
 3413|   870k|                     parse<JSON>::op<Opts>(ctx.scratch, ctx, it, end);
 3414|   870k|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3414:26): [True: 1.55k, False: 869k]
  ------------------
 3415|  1.55k|                        return;
 3416|       |
 3417|   869k|                     if (parse_ws_colon<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3417:26): [True: 764, False: 868k]
  ------------------
 3418|    764|                        return;
 3419|    764|                     }
 3420|       |
 3421|   868k|                     reading(ctx.scratch);
 3422|       |                     if constexpr (Opts.partial_read) {
 3423|       |                        if (read_count == value.size()) {
 3424|       |                           return;
 3425|       |                        }
 3426|       |                     }
 3427|   868k|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3427:26): [True: 20.3k, False: 848k]
  ------------------
 3428|  20.3k|                        return;
 3429|       |                  }
 3430|       |                  else if constexpr (str_t<Key>) {
 3431|       |                     Key key;
 3432|       |                     parse<JSON>::op<Opts>(key, ctx, it, end);
 3433|       |                     if (bool(ctx.error)) [[unlikely]]
 3434|       |                        return;
 3435|       |
 3436|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3437|       |                        return;
 3438|       |                     }
 3439|       |
 3440|       |                     reading(key);
 3441|       |                     if constexpr (Opts.partial_read) {
 3442|       |                        if (read_count == value.size()) {
 3443|       |                           return;
 3444|       |                        }
 3445|       |                     }
 3446|       |                     if (bool(ctx.error)) [[unlikely]]
 3447|       |                        return;
 3448|       |                  }
 3449|       |                  else {
 3450|       |                     Key key_value{};
 3451|       |                     if constexpr (is_named_enum<Key> || mimics_str_t<Key>) {
 3452|       |                        parse<JSON>::op<Opts>(key_value, ctx, it, end);
 3453|       |                     }
 3454|       |                     else if constexpr (std::is_arithmetic_v<Key>) {
 3455|       |                        // prefer over quoted_t below to avoid double parsing of quoted_t
 3456|       |                        parse<JSON>::op<opt_true<Opts, quoted_num_opt_tag{}>>(key_value, ctx, it, end);
 3457|       |                     }
 3458|       |                     else {
 3459|       |                        parse<JSON>::op<opt_false<Opts, raw_string_opt_tag{}>>(quoted_t<Key>{key_value}, ctx, it, end);
 3460|       |                     }
 3461|       |                     if (bool(ctx.error)) [[unlikely]]
 3462|       |                        return;
 3463|       |
 3464|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3465|       |                        return;
 3466|       |                     }
 3467|       |
 3468|       |                     reading(key_value);
 3469|       |                     if constexpr (Opts.partial_read) {
 3470|       |                        if (read_count == value.size()) {
 3471|       |                           return;
 3472|       |                        }
 3473|       |                     }
 3474|       |                     if (bool(ctx.error)) [[unlikely]]
 3475|       |                        return;
 3476|       |                  }
 3477|   870k|               }
 3478|       |
 3479|       |               // Streaming refill point: after parsing each key-value pair, refill if buffer is low
 3480|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 3481|       |                  if (ctx.stream.enabled()) {
 3482|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 3483|       |                     // Refill when less than 25% of buffer remains to ensure enough space for next element
 3484|       |                     if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 3485|       |                        const char* new_it;
 3486|       |                        const char* new_end;
 3487|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 3488|       |                        it = new_it;
 3489|       |                        end = new_end;
 3490|       |                        if (it >= end && ctx.stream.at_eof()) {
 3491|       |                           ctx.error = error_code::unexpected_end;
 3492|       |                           return;
 3493|       |                        }
 3494|       |                     }
 3495|       |                  }
 3496|       |               }
 3497|       |
 3498|   870k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3498:20): [True: 0, False: 870k]
  ------------------
 3499|      0|                  return;
 3500|      0|               }
 3501|   870k|            }
 3502|  25.3k|         }
 3503|  25.3k|      }
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj33EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlvE_clEv:
 3148|  25.3k|            decltype(auto) fields = [&]() -> decltype(auto) {
 3149|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 3150|       |                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 3151|       |                  return bit_array<num_members>{};
 3152|       |               }
 3153|  25.3k|               else {
 3154|  25.3k|                  return nullptr;
 3155|  25.3k|               }
 3156|  25.3k|            }();
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|   870k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|   870k|         else {
   60|   870k|            using V = std::remove_cvref_t<T>;
   61|   870k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|   870k|                                             end);
   63|   870k|         }
   64|   870k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEQcl15check_is_paddedTL0__EEEvRT2_OT3_OT0_T1_:
  892|   870k|      {
  893|       |         if constexpr (check_string_as_number(Opts)) {
  894|       |            auto start = it;
  895|       |            skip_number<Opts>(ctx, it, end);
  896|       |            if (bool(ctx.error)) [[unlikely]] {
  897|       |               return;
  898|       |            }
  899|       |            value.append(start, size_t(it - start));
  900|       |         }
  901|   870k|         else {
  902|   870k|            if constexpr (!check_opening_handled(Opts)) {
  903|   870k|               if constexpr (!check_ws_handled(Opts)) {
  904|   870k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (904:23): [True: 0, False: 870k]
  ------------------
  905|      0|                     return;
  906|      0|                  }
  907|   870k|               }
  908|       |
  909|   870k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (909:20): [True: 389, False: 870k]
  ------------------
  910|    389|                  return;
  911|    389|               }
  912|   870k|            }
  913|       |
  914|   870k|            if constexpr (not check_raw_string(Opts)) {
  915|   870k|               static constexpr auto string_padding_bytes = 8;
  916|       |
  917|   870k|               auto start = it;
  918|   870k|               uint64_t ascii_acc{};
  919|  4.47M|               while (true) {
  ------------------
  |  Branch (919:23): [True: 4.47M, Folded]
  ------------------
  920|  4.47M|                  if (it >= end) [[unlikely]] {
  ------------------
  |  Branch (920:23): [True: 629, False: 4.47M]
  ------------------
  921|    629|                     ctx.error = error_code::unexpected_end;
  922|    629|                     return;
  923|    629|                  }
  924|       |
  925|  4.47M|                  uint64_t chunk;
  926|  4.47M|                  std::memcpy(&chunk, it, 8);
  927|       |                  if constexpr (std::endian::native == std::endian::big) {
  928|       |                     chunk = std::byteswap(chunk);
  929|       |                  }
  930|  4.47M|                  ascii_acc |= chunk;
  931|  4.47M|                  const uint64_t test_chars = has_quote(chunk);
  932|  4.47M|                  if (test_chars) {
  ------------------
  |  Branch (932:23): [True: 871k, False: 3.60M]
  ------------------
  933|   871k|                     it += (countr_zero(test_chars) >> 3);
  934|       |
  935|   871k|                     auto* prev = it - 1;
  936|   874k|                     while (*prev == '\\') {
  ------------------
  |  Branch (936:29): [True: 2.91k, False: 871k]
  ------------------
  937|  2.91k|                        --prev;
  938|  2.91k|                     }
  939|   871k|                     if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (939:26): [True: 869k, False: 1.22k]
  ------------------
  940|   869k|                        break;
  941|   869k|                     }
  942|  1.22k|                     ++it; // skip the escaped quote
  943|  1.22k|                  }
  944|  3.60M|                  else {
  945|  3.60M|                     it += 8;
  946|  3.60M|                  }
  947|  4.47M|               }
  948|       |
  949|   870k|               if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (949:20): [True: 270, False: 870k]
  ------------------
  950|    270|                  return;
  951|    270|               }
  952|       |
  953|   870k|               auto n = size_t(it - start);
  954|   870k|               value.resize(n + string_padding_bytes);
  955|       |
  956|   870k|               auto* p = value.data();
  957|       |
  958|  4.92M|               while (true) {
  ------------------
  |  Branch (958:23): [True: 4.92M, Folded]
  ------------------
  959|  4.92M|                  if (start >= it) {
  ------------------
  |  Branch (959:23): [True: 866k, False: 4.05M]
  ------------------
  960|   866k|                     break;
  961|   866k|                  }
  962|       |
  963|  4.05M|                  std::memcpy(p, start, 8);
  964|  4.05M|                  uint64_t swar;
  965|  4.05M|                  std::memcpy(&swar, p, 8);
  966|       |                  if constexpr (std::endian::native == std::endian::big) {
  967|       |                     swar = std::byteswap(swar);
  968|       |                  }
  969|       |
  970|  4.05M|                  constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
  971|  4.05M|                  const uint64_t lo7 = swar & lo7_mask;
  972|  4.05M|                  const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
  973|  4.05M|                  const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
  974|  4.05M|                  uint64_t next = ~((backslash & less_32) | swar);
  975|       |
  976|  4.05M|                  next &= repeat_byte8(0b10000000);
  977|  4.05M|                  if (next == 0) {
  ------------------
  |  Branch (977:23): [True: 4.03M, False: 16.3k]
  ------------------
  978|  4.03M|                     start += 8;
  979|  4.03M|                     p += 8;
  980|  4.03M|                     continue;
  981|  4.03M|                  }
  982|       |
  983|  16.3k|                  next = countr_zero(next) >> 3;
  984|  16.3k|                  start += next;
  985|  16.3k|                  if (start >= it) {
  ------------------
  |  Branch (985:23): [True: 2.52k, False: 13.8k]
  ------------------
  986|  2.52k|                     break;
  987|  2.52k|                  }
  988|       |
  989|  13.8k|                  if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (989:23): [True: 96, False: 13.7k]
  ------------------
  990|     96|                     ctx.error = error_code::syntax_error;
  991|     96|                     return;
  992|     96|                  }
  993|  13.7k|                  ++start; // skip the escape
  994|  13.7k|                  if (*start == 'u') {
  ------------------
  |  Branch (994:23): [True: 11.3k, False: 2.30k]
  ------------------
  995|  11.3k|                     ++start;
  996|  11.3k|                     p += next;
  997|  11.3k|                     const auto mark = start;
  998|  11.3k|                     const auto offset = handle_unicode_code_point(start, p, end);
  999|  11.3k|                     if (offset == 0) [[unlikely]] {
  ------------------
  |  Branch (999:26): [True: 131, False: 11.2k]
  ------------------
 1000|    131|                        ctx.error = error_code::unicode_escape_conversion_failure;
 1001|    131|                        return;
 1002|    131|                     }
 1003|  11.2k|                     n += offset;
 1004|       |                     // escape + u + unicode code points
 1005|  11.2k|                     n -= 2 + uint32_t(start - mark);
 1006|  11.2k|                  }
 1007|  2.30k|                  else {
 1008|  2.30k|                     p += next;
 1009|  2.30k|                     *p = char_unescape_table[uint8_t(*start)];
 1010|  2.30k|                     if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1010:26): [True: 35, False: 2.27k]
  ------------------
 1011|     35|                        ctx.error = error_code::invalid_escape;
 1012|     35|                        return;
 1013|     35|                     }
 1014|  2.27k|                     ++p;
 1015|  2.27k|                     ++start;
 1016|  2.27k|                     --n;
 1017|  2.27k|                  }
 1018|  13.7k|               }
 1019|       |
 1020|   869k|               value.resize(n);
 1021|   869k|               ++it;
 1022|       |            }
 1023|       |            else {
 1024|       |               // raw_string
 1025|       |               auto start = it;
 1026|       |               skip_string_view(ctx, it, end);
 1027|       |               if (bool(ctx.error)) [[unlikely]]
 1028|       |                  return;
 1029|       |
 1030|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1031|       |                  return;
 1032|       |               }
 1033|       |
 1034|       |               value.assign(start, size_t(it - start));
 1035|       |               ++it;
 1036|       |            }
 1037|   870k|         }
 1038|   870k|      }
_ZN3glz14parse_ws_colonITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT0_OT1_T2_:
  159|   869k|   {
  160|   869k|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (160:11): [True: 0, False: 869k]
  ------------------
  161|      0|         return true;
  162|      0|      }
  163|   869k|      if (match_invalid_end<':', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (163:11): [True: 764, False: 868k]
  ------------------
  164|    764|         return true;
  165|    764|      }
  166|   868k|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (166:11): [True: 0, False: 868k]
  ------------------
  167|      0|         return true;
  168|      0|      }
  169|   868k|      return false;
  170|   868k|   }
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj33EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlOT_E_clIRNSt3__112basic_stringIcNSS_11char_traitsIcEENSS_9allocatorIcEEEEEEDaSP_:
 3394|   868k|                  auto reading = [&](auto&& key) {
 3395|       |                     if constexpr (Opts.partial_read) {
 3396|       |                        if (auto element = value.find(key); element != value.end()) {
 3397|       |                           ++read_count;
 3398|       |                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3399|       |                        }
 3400|       |                        else {
 3401|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3402|       |                        }
 3403|       |                     }
 3404|   868k|                     else {
 3405|   868k|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3406|   868k|                     }
 3407|   868k|                  };
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  2.59M|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  2.59M|         else {
   60|  2.59M|            using V = std::remove_cvref_t<T>;
   61|  2.59M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  2.59M|                                             end);
   63|  2.59M|         }
   64|  2.59M|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  2.59M|      {
  151|  2.59M|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  2.59M|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  2.59M|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  2.59M|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 4065|  2.59M|      {
 4066|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 4067|       |            read_adjacent<Options>(value, ctx, it, end);
 4068|       |         }
 4069|  2.59M|         else {
 4070|  2.59M|            read_deduced<Options>(value, ctx, it, end);
 4071|  2.59M|         }
 4072|  2.59M|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE12read_deducedITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 4076|  2.59M|      {
 4077|  2.59M|         constexpr auto Opts = ws_handled_off<Options>();
 4078|  2.59M|         if constexpr (variant_is_auto_deducible<T>()) {
 4079|       |            if constexpr (not check_ws_handled(Options)) {
 4080|       |               if (skip_ws<Opts>(ctx, it, end)) {
 4081|       |                  return;
 4082|       |               }
 4083|       |            }
 4084|       |
 4085|  2.59M|            switch (*it) {
 4086|  1.57k|            case '\0':
  ------------------
  |  Branch (4086:13): [True: 1.57k, False: 2.59M]
  ------------------
 4087|  1.57k|               ctx.error = error_code::unexpected_end;
 4088|  1.57k|               return;
 4089|  20.2k|            case '{': {
  ------------------
  |  Branch (4089:13): [True: 20.2k, False: 2.57M]
  ------------------
 4090|       |               // This branch consumes the brace itself and hands the object to a reader with
 4091|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 4092|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 4093|       |               // the reader below.
 4094|  20.2k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (4094:20): [True: 9, False: 20.2k]
  ------------------
 4095|      9|                  return;
 4096|      9|               }
 4097|       |
 4098|  20.2k|               ++it;
 4099|       |               if constexpr (not Opts.null_terminated) {
 4100|       |                  if (it == end) [[unlikely]] {
 4101|       |                     ctx.error = error_code::unexpected_end;
 4102|       |                     return;
 4103|       |                  }
 4104|       |               }
 4105|  20.2k|               using type_counts = variant_type_count<T>;
 4106|  20.2k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 4107|       |               if constexpr (n_object_candidates < 1) {
 4108|       |                  ctx.error = error_code::no_matching_variant_type;
 4109|       |                  return;
 4110|       |               }
 4111|  20.2k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 4112|  20.2k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 4113|  20.2k|                  using V = std::variant_alternative_t<first_idx, T>;
 4114|  20.2k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4114:23): [True: 19.8k, False: 409]
  ------------------
 4115|  20.2k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 4116|  20.2k|                  return;
 4117|       |               }
 4118|       |               else {
 4119|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 4120|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 4121|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 4122|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 4123|       |
 4124|       |                  // Track if we've encountered a tag and what value it had
 4125|       |                  std::optional<size_t> tag_specified_index{};
 4126|       |
 4127|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 4128|       |                     return;
 4129|       |                  }
 4130|       |                  // Once the reader knows which alternative this object holds it may have to read
 4131|       |                  // it again from here. Anchor the position rather than keep the pointer: the scan
 4132|       |                  // below skips values, and a streaming skip refills, which moves the window out
 4133|       |                  // from under a raw pointer (see rewind_anchor).
 4134|       |                  auto start = make_rewind_anchor(ctx, it);
 4135|       |                  bool first_key = true;
 4136|       |                  // Parse bifurcation for tagged variants:
 4137|       |                  //
 4138|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 4139|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 4140|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 4141|       |                  //
 4142|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 4143|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 4144|       |                  // it advances past the trailing comma so the object parser picks up at the
 4145|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 4146|       |                  //
 4147|       |                  // One exception: if the tag name is also a field on the resolved struct
 4148|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 4149|       |                  // the struct field. This override is applied inside each std::visit lambda.
 4150|       |                  //
 4151|       |                  // Either way the rewind can fail under a streaming read: the window only holds so
 4152|       |                  // much, and an object wider than it has no start left to return to.
 4153|       |                  auto position_after_tag = [&] {
 4154|       |                     if (first_key) {
 4155|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 4156|       |                        return true;
 4157|       |                     }
 4158|       |                     return start.rewind(ctx, it, end); // tag came later, re-parse from the beginning
 4159|       |                  };
 4160|       |                  // `first_key` also answers "were we reset to the object start", which is what
 4161|       |                  // position_after_tag does for every key but the first.
 4162|       |                  for (; *it != '}'; first_key = false) {
 4163|       |                     if (!first_key) {
 4164|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 4165|       |                           return;
 4166|       |                        }
 4167|       |                     }
 4168|       |
 4169|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4170|       |                        return;
 4171|       |                     }
 4172|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4173|       |                        return;
 4174|       |                     }
 4175|       |
 4176|       |                     auto* key_start = it;
 4177|       |                     skip_string_view(ctx, it, end);
 4178|       |                     if (bool(ctx.error)) [[unlikely]]
 4179|       |                        return;
 4180|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 4181|       |                        return;
 4182|       |                     const sv key = {key_start, size_t(it - key_start)};
 4183|       |
 4184|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4185|       |                        return;
 4186|       |                     }
 4187|       |
 4188|       |                     if constexpr (deduction_key_count > 0) {
 4189|       |                        // We first check if a tag is defined and see if the key matches the tag
 4190|       |                        if constexpr (not tag_v<T>.empty()) {
 4191|       |                           if (key == tag_v<T>) {
 4192|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 4193|       |                                 return;
 4194|       |                              }
 4195|       |
 4196|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 4197|       |
 4198|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 4199|       |                              if constexpr (std::integral<id_type>) {
 4200|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4201|       |                              }
 4202|       |                              else {
 4203|       |                                 // The id is turned into an index below and never leaves this
 4204|       |                                 // reader, so the view of the window it borrows cannot outlive it.
 4205|       |                                 parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4206|       |                              }
 4207|       |                              if (bool(ctx.error)) [[unlikely]]
 4208|       |                                 return;
 4209|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4210|       |                                 return;
 4211|       |                              }
 4212|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4213|       |                                 ctx.error = error_code::syntax_error;
 4214|       |                                 return;
 4215|       |                              }
 4216|       |
 4217|       |                              size_t type_index;
 4218|       |                              if constexpr (std::integral<id_type>) {
 4219|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4220|       |                              }
 4221|       |                              else {
 4222|       |                                 type_index = variant_id_to_index<T>::op(
 4223|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4224|       |                              }
 4225|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4226|       |                                 // Check if the deduced types include the tag-specified type
 4227|       |                                 // If not, the tag doesn't match the fields
 4228|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4229|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4230|       |                                 // Check if the tag-specified type is still possible
 4231|       |                                 const bool type_is_possible = possible_types[type_index];
 4232|       |                                 if (!type_is_possible) {
 4233|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4234|       |                                    ctx.error = error_code::no_matching_variant_type;
 4235|       |                                    return;
 4236|       |                                 }
 4237|       |
 4238|       |                                 if (!position_after_tag()) return;
 4239|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4240|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4241|       |                                 std::visit(
 4242|       |                                    [&](auto&& v) {
 4243|       |                                       using V = std::decay_t<decltype(v)>;
 4244|       |                                       constexpr bool is_object =
 4245|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4246|       |                                       if constexpr (variant_unit_alternative<V>) {
 4247|       |                                          // A unit alternative carries no data; its object holds only the
 4248|       |                                          // discriminator. Consume that body through an empty reflected object so
 4249|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4250|       |                                          detail::variant_unit_body unit_body{};
 4251|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4252|       |                                                                                             tag_literal>(unit_body,
 4253|       |                                                                                                          ctx, it, end);
 4254|       |                                       }
 4255|       |                                       else if constexpr (is_object) {
 4256|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4257|       |                                             // tag is a struct field, must re-parse
 4258|       |                                             if (!start.rewind(ctx, it, end)) return;
 4259|       |                                          }
 4260|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4261|       |                                                                                                           end);
 4262|       |                                       }
 4263|       |                                       else if constexpr (is_memory_object<V>) {
 4264|       |                                          if (!v) {
 4265|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4266|       |                                                if constexpr (requires { v.emplace(); }) {
 4267|       |                                                   v.emplace();
 4268|       |                                                }
 4269|       |                                                else {
 4270|       |                                                   v = typename V::value_type{};
 4271|       |                                                }
 4272|       |                                             }
 4273|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4274|       |                                                v = std::make_unique<typename V::element_type>();
 4275|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4276|       |                                                v = std::make_shared<typename V::element_type>();
 4277|       |                                             else if constexpr (constructible<V>) {
 4278|       |                                                v = meta_construct_v<V>();
 4279|       |                                             }
 4280|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4281|       |                                                                can_allocate_raw_pointer<Opts,
 4282|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4283|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4284|       |                                                   return;
 4285|       |                                                }
 4286|       |                                             }
 4287|       |                                             else {
 4288|       |                                                ctx.error = error_code::invalid_nullable_read;
 4289|       |                                                return;
 4290|       |                                                // Cannot read into unset nullable that is not std::optional,
 4291|       |                                                // std::unique_ptr, or std::shared_ptr
 4292|       |                                             }
 4293|       |                                          }
 4294|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4295|       |                                             // tag is a struct field, must re-parse
 4296|       |                                             if (!start.rewind(ctx, it, end)) return;
 4297|       |                                          }
 4298|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4299|       |                                             *v, ctx, it, end);
 4300|       |                                       }
 4301|       |                                       else if constexpr (custom_read<V>) {
 4302|       |                                          // Custom handlers parse the remaining body themselves and do not
 4303|       |                                          // accept the tag template parameter; the tag was already consumed.
 4304|       |                                          // This only works when the tag was the first key. If it came later,
 4305|       |                                          // we were reset to the object start and the custom handler would
 4306|       |                                          // absorb the tag, so error rather than corrupt the value.
 4307|       |                                          if (!first_key) {
 4308|       |                                             ctx.error = error_code::feature_not_supported;
 4309|       |                                             ctx.custom_error_message =
 4310|       |                                                "the tag must be the first key for a custom variant alternative";
 4311|       |                                             return;
 4312|       |                                          }
 4313|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4314|       |                                       }
 4315|       |                                    },
 4316|       |                                    value);
 4317|       |
 4318|       |                                 return; // we've decoded our target type
 4319|       |                              }
 4320|       |                              else [[unlikely]] {
 4321|       |                                 // Check if we have a default type (ids array shorter than variant)
 4322|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4323|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4324|       |                                 if constexpr (ids_size < variant_size) {
 4325|       |                                    // Use the first unlabeled type as the default
 4326|       |                                    const auto default_type_index = ids_size;
 4327|       |
 4328|       |                                    if (!position_after_tag()) return;
 4329|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4330|       |                                    if (value.index() != default_type_index)
 4331|       |                                       emplace_runtime_variant(value, default_type_index);
 4332|       |                                    std::visit(
 4333|       |                                       [&](auto&& v) {
 4334|       |                                          using V = std::decay_t<decltype(v)>;
 4335|       |                                          constexpr bool is_object =
 4336|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4337|       |                                          if constexpr (variant_unit_alternative<V>) {
 4338|       |                                             // A unit alternative carries no data; its object holds only the
 4339|       |                                             // discriminator. Consume that body through an empty reflected object so
 4340|       |                                             // unknown-key policy and terminator handling match every other
 4341|       |                                             // alternative.
 4342|       |                                             detail::variant_unit_body unit_body{};
 4343|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4344|       |                                                                                                tag_literal>(
 4345|       |                                                unit_body, ctx, it, end);
 4346|       |                                          }
 4347|       |                                          else if constexpr (is_object) {
 4348|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4349|       |                                                // tag is a struct field, must re-parse
 4350|       |                                                if (!start.rewind(ctx, it, end)) return;
 4351|       |                                             }
 4352|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4353|       |                                          }
 4354|       |                                          else if constexpr (is_memory_object<V>) {
 4355|       |                                             if (!v) {
 4356|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4357|       |                                                   if constexpr (requires { v.emplace(); }) {
 4358|       |                                                      v.emplace();
 4359|       |                                                   }
 4360|       |                                                   else {
 4361|       |                                                      v = typename V::value_type{};
 4362|       |                                                   }
 4363|       |                                                }
 4364|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4365|       |                                                   v = std::make_unique<typename V::element_type>();
 4366|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4367|       |                                                   v = std::make_shared<typename V::element_type>();
 4368|       |                                                else if constexpr (constructible<V>) {
 4369|       |                                                   v = meta_construct_v<V>();
 4370|       |                                                }
 4371|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4372|       |                                                                   can_allocate_raw_pointer<
 4373|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4374|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4375|       |                                                      return;
 4376|       |                                                   }
 4377|       |                                                }
 4378|       |                                                else {
 4379|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4380|       |                                                   return;
 4381|       |                                                }
 4382|       |                                             }
 4383|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4384|       |                                                // tag is a struct field, must re-parse
 4385|       |                                                if (!start.rewind(ctx, it, end)) return;
 4386|       |                                             }
 4387|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4388|       |                                                                                                              it, end);
 4389|       |                                          }
 4390|       |                                          else if constexpr (custom_read<V>) {
 4391|       |                                             // Custom handlers parse the remaining body themselves; this only
 4392|       |                                             // works when the tag was the first key (see above). If it came
 4393|       |                                             // later we were reset to the object start, so error rather than
 4394|       |                                             // let the custom handler absorb the tag.
 4395|       |                                             if (!first_key) {
 4396|       |                                                ctx.error = error_code::feature_not_supported;
 4397|       |                                                ctx.custom_error_message =
 4398|       |                                                   "the tag must be the first key for a custom variant alternative";
 4399|       |                                                return;
 4400|       |                                             }
 4401|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4402|       |                                          }
 4403|       |                                       },
 4404|       |                                       value);
 4405|       |
 4406|       |                                    return;
 4407|       |                                 }
 4408|       |                                 else {
 4409|       |                                    ctx.error = error_code::no_matching_variant_type;
 4410|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4411|       |                                    return;
 4412|       |                                 }
 4413|       |                              }
 4414|       |                           }
 4415|       |                        }
 4416|       |
 4417|       |                        // Inline decode_hash lookup for variant deduction
 4418|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4419|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4420|       |                        const auto deduction_index =
 4421|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4422|       |                              key.data(), key.data() + key.size(), key.size());
 4423|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4424|       |                           [[likely]] {
 4425|       |                           possible_types &= deduction_bits[deduction_index];
 4426|       |                        }
 4427|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4428|       |                           ctx.error = error_code::unknown_key;
 4429|       |                           return;
 4430|       |                        }
 4431|       |                     }
 4432|       |                     else if constexpr (not tag_v<T>.empty()) {
 4433|       |                        // empty object case for variant, if there are no normal elements
 4434|       |                        if (key == tag_v<T>) {
 4435|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4436|       |                              return;
 4437|       |                           }
 4438|       |
 4439|       |                           // The id is turned into an index below and never leaves this reader,
 4440|       |                           // so the view of the window it borrows cannot outlive that window.
 4441|       |                           std::string_view type_id{};
 4442|       |                           parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4443|       |                           if (bool(ctx.error)) [[unlikely]]
 4444|       |                              return;
 4445|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4446|       |                              return;
 4447|       |                           }
 4448|       |
 4449|       |                           const auto type_index = variant_id_to_index<T>::op(
 4450|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4451|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4452|       |                              if (!position_after_tag()) return;
 4453|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4454|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4455|       |                           }
 4456|       |                           else {
 4457|       |                              // Check if we have a default type (ids array shorter than variant)
 4458|       |                              constexpr auto ids_size = ids_v<T>.size();
 4459|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4460|       |                              if constexpr (ids_size < variant_size) {
 4461|       |                                 // Use the first unlabeled type as the default
 4462|       |                                 if (!position_after_tag()) return;
 4463|       |                                 const auto default_index = ids_size;
 4464|       |                                 tag_specified_index = default_index; // Store the default type index
 4465|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4466|       |                              }
 4467|       |                              else {
 4468|       |                                 ctx.error = error_code::no_matching_variant_type;
 4469|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4470|       |                                 return;
 4471|       |                              }
 4472|       |                           }
 4473|       |                           // Parse the type (handles tag skipping and unknown keys)
 4474|       |                           std::visit(
 4475|       |                              [&](auto&& v) {
 4476|       |                                 using V = std::decay_t<decltype(v)>;
 4477|       |                                 if constexpr (custom_read<V>) {
 4478|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4479|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4480|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4481|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4482|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4483|       |                                    // into its value, so error here rather than corrupt the result.
 4484|       |                                    if (!first_key) {
 4485|       |                                       ctx.error = error_code::feature_not_supported;
 4486|       |                                       ctx.custom_error_message =
 4487|       |                                          "the tag must be the first key for a custom variant alternative";
 4488|       |                                       return;
 4489|       |                                    }
 4490|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4491|       |                                 }
 4492|       |                                 else {
 4493|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4494|       |                                       // tag is a struct field, must re-parse
 4495|       |                                       if (!start.rewind(ctx, it, end)) return;
 4496|       |                                    }
 4497|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4498|       |                                 }
 4499|       |                              },
 4500|       |                              value);
 4501|       |                           return;
 4502|       |                        }
 4503|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4504|       |                           ctx.error = error_code::unknown_key;
 4505|       |                           return;
 4506|       |                        }
 4507|       |                        else {
 4508|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4509|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4510|       |                              return;
 4511|       |                           }
 4512|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4513|       |                           if (bool(ctx.error)) [[unlikely]]
 4514|       |                              return;
 4515|       |                           resync_window_end(ctx, end); // a streaming skip refills
 4516|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4517|       |                              return;
 4518|       |                           }
 4519|       |                           continue; // Continue loop to find the tag
 4520|       |                        }
 4521|       |                     }
 4522|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4523|       |                        ctx.error = error_code::unknown_key;
 4524|       |                        return;
 4525|       |                     }
 4526|       |
 4527|       |                     auto matching_types = possible_types.popcount();
 4528|       |                     if (matching_types == 0) {
 4529|       |                        ctx.error = error_code::no_matching_variant_type;
 4530|       |                        return;
 4531|       |                     }
 4532|       |                     // Only short-circuit for variants without tags
 4533|       |                     else if constexpr (tag_v<T>.empty()) {
 4534|       |                        if (matching_types == 1) {
 4535|       |                           if (!start.rewind(ctx, it, end)) return;
 4536|       |                           const auto type_index = possible_types.countr_zero();
 4537|       |
 4538|       |                           if (value.index() != static_cast<size_t>(type_index))
 4539|       |                              emplace_runtime_variant(value, type_index);
 4540|       |                           std::visit(
 4541|       |                              [&](auto&& v) {
 4542|       |                                 using V = std::decay_t<decltype(v)>;
 4543|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4544|       |                                 if constexpr (variant_unit_alternative<V>) {
 4545|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4546|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4547|       |                                    // terminator handling match every other alternative.
 4548|       |                                    detail::variant_unit_body unit_body{};
 4549|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4550|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4551|       |                                                                                                    end);
 4552|       |                                 }
 4553|       |                                 else if constexpr (is_object) {
 4554|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4555|       |                                 }
 4556|       |                                 else if constexpr (is_memory_object<V>) {
 4557|       |                                    if (!v) {
 4558|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4559|       |                                          if constexpr (requires { v.emplace(); }) {
 4560|       |                                             v.emplace();
 4561|       |                                          }
 4562|       |                                          else {
 4563|       |                                             v = typename V::value_type{};
 4564|       |                                          }
 4565|       |                                       }
 4566|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4567|       |                                          v = std::make_unique<typename V::element_type>();
 4568|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4569|       |                                          v = std::make_shared<typename V::element_type>();
 4570|       |                                       else if constexpr (constructible<V>) {
 4571|       |                                          v = meta_construct_v<V>();
 4572|       |                                       }
 4573|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4574|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4575|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4576|       |                                             return;
 4577|       |                                          }
 4578|       |                                       }
 4579|       |                                       else {
 4580|       |                                          ctx.error = error_code::invalid_nullable_read;
 4581|       |                                          return;
 4582|       |                                          // Cannot read into unset nullable that is not std::optional,
 4583|       |                                          // std::unique_ptr, or std::shared_ptr
 4584|       |                                       }
 4585|       |                                    }
 4586|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4587|       |                                       *v, ctx, it, end);
 4588|       |                                 }
 4589|       |                                 else if constexpr (custom_read<V>) {
 4590|       |                                    // Custom handlers parse the remaining body themselves.
 4591|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4592|       |                                 }
 4593|       |                              },
 4594|       |                              value);
 4595|       |
 4596|       |                           return; // we've decoded our target type
 4597|       |                        }
 4598|       |                     }
 4599|       |                     // For tagged variants, continue processing to validate tags
 4600|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4601|       |                        return;
 4602|       |                     }
 4603|       |
 4604|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4605|       |                     if (bool(ctx.error)) [[unlikely]]
 4606|       |                        return;
 4607|       |                     resync_window_end(ctx, end); // a streaming skip refills
 4608|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4609|       |                        return;
 4610|       |                     }
 4611|       |                  }
 4612|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4613|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4614|       |                     // After parsing all keys, check if we have multiple matching types
 4615|       |                     // If so, choose the one with the fewest fields
 4616|       |                     auto final_matching = possible_types.popcount();
 4617|       |                     if (final_matching == 0) {
 4618|       |                        ctx.error = error_code::no_matching_variant_type;
 4619|       |                     }
 4620|       |                     else if (final_matching == 1) {
 4621|       |                        // Single type remains after field deduction
 4622|       |                        const auto type_index = possible_types.countr_zero();
 4623|       |
 4624|       |                        // Validate against tag if one was specified
 4625|       |                        if (tag_specified_index.has_value() &&
 4626|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4627|       |                           ctx.error = error_code::no_matching_variant_type;
 4628|       |                           return;
 4629|       |                        }
 4630|       |
 4631|       |                        if (!start.rewind(ctx, it, end)) return;
 4632|       |                        if (value.index() != static_cast<size_t>(type_index))
 4633|       |                           emplace_runtime_variant(value, type_index);
 4634|       |                        std::visit(
 4635|       |                           [&](auto&& v) {
 4636|       |                              using V = std::decay_t<decltype(v)>;
 4637|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4638|       |                              if constexpr (variant_unit_alternative<V>) {
 4639|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4640|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4641|       |                                 // terminator handling match every other alternative.
 4642|       |                                 detail::variant_unit_body unit_body{};
 4643|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4644|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4645|       |                                                                                                 end);
 4646|       |                              }
 4647|       |                              else if constexpr (is_object) {
 4648|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4649|       |                              }
 4650|       |                              else if constexpr (is_memory_object<V>) {
 4651|       |                                 if (!v) {
 4652|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4653|       |                                       if constexpr (requires { v.emplace(); }) {
 4654|       |                                          v.emplace();
 4655|       |                                       }
 4656|       |                                       else {
 4657|       |                                          v = typename V::value_type{};
 4658|       |                                       }
 4659|       |                                    }
 4660|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4661|       |                                       v = std::make_unique<typename V::element_type>();
 4662|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4663|       |                                       v = std::make_shared<typename V::element_type>();
 4664|       |                                    else if constexpr (constructible<V>) {
 4665|       |                                       v = meta_construct_v<V>();
 4666|       |                                    }
 4667|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4668|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4669|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4670|       |                                          return;
 4671|       |                                       }
 4672|       |                                    }
 4673|       |                                    else {
 4674|       |                                       ctx.error = error_code::invalid_nullable_read;
 4675|       |                                       return;
 4676|       |                                    }
 4677|       |                                 }
 4678|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4679|       |                                                                                                               it, end);
 4680|       |                              }
 4681|       |                              else if constexpr (custom_read<V>) {
 4682|       |                                 // Custom handlers parse the remaining body themselves.
 4683|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4684|       |                              }
 4685|       |                           },
 4686|       |                           value);
 4687|       |                     }
 4688|       |                     else if (final_matching > 1) {
 4689|       |                        constexpr auto N = std::variant_size_v<T>;
 4690|       |
 4691|       |                        // Compile-time array of field counts for each variant type
 4692|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4693|       |                           return std::array<size_t, N> {
 4694|       |                              ([]<size_t J = I>() -> size_t {
 4695|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4696|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4697|       |                                    return reflect<V>::size;
 4698|       |                                 }
 4699|       |                                 else if constexpr (is_memory_object<V>) {
 4700|       |                                    using X = memory_type<V>;
 4701|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4702|       |                                       return reflect<X>::size;
 4703|       |                                    }
 4704|       |                                    else {
 4705|       |                                       return (std::numeric_limits<size_t>::max)();
 4706|       |                                    }
 4707|       |                                 }
 4708|       |                                 else {
 4709|       |                                    return (std::numeric_limits<size_t>::max)();
 4710|       |                                 }
 4711|       |                              }.template operator()<I>())...
 4712|       |                           };
 4713|       |                        }(std::make_index_sequence<N>{});
 4714|       |
 4715|       |                        // Find the type with minimum field count among the possible types
 4716|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4717|       |                        size_t chosen_index = N; // Invalid index initially
 4718|       |
 4719|       |                        for (size_t i = 0; i < N; ++i) {
 4720|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4721|       |                              min_fields = field_counts[i];
 4722|       |                              chosen_index = i;
 4723|       |                           }
 4724|       |                        }
 4725|       |
 4726|       |                        if (chosen_index < N) {
 4727|       |                           // Validate against tag if one was specified
 4728|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4729|       |                              ctx.error = error_code::no_matching_variant_type;
 4730|       |                              return;
 4731|       |                           }
 4732|       |
 4733|       |                           if (!start.rewind(ctx, it, end)) return;
 4734|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4735|       |                           std::visit(
 4736|       |                              [&](auto&& v) {
 4737|       |                                 using V = std::decay_t<decltype(v)>;
 4738|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4739|       |                                 if constexpr (variant_unit_alternative<V>) {
 4740|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4741|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4742|       |                                    // terminator handling match every other alternative.
 4743|       |                                    detail::variant_unit_body unit_body{};
 4744|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4745|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4746|       |                                                                                                    end);
 4747|       |                                 }
 4748|       |                                 else if constexpr (is_object) {
 4749|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4750|       |                                 }
 4751|       |                                 else if constexpr (is_memory_object<V>) {
 4752|       |                                    if (!v) {
 4753|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4754|       |                                          if constexpr (requires { v.emplace(); }) {
 4755|       |                                             v.emplace();
 4756|       |                                          }
 4757|       |                                          else {
 4758|       |                                             v = typename V::value_type{};
 4759|       |                                          }
 4760|       |                                       }
 4761|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4762|       |                                          v = std::make_unique<typename V::element_type>();
 4763|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4764|       |                                          v = std::make_shared<typename V::element_type>();
 4765|       |                                       else if constexpr (constructible<V>) {
 4766|       |                                          v = meta_construct_v<V>();
 4767|       |                                       }
 4768|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4769|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4770|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4771|       |                                             return;
 4772|       |                                          }
 4773|       |                                       }
 4774|       |                                       else {
 4775|       |                                          ctx.error = error_code::invalid_nullable_read;
 4776|       |                                          return;
 4777|       |                                       }
 4778|       |                                    }
 4779|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4780|       |                                       *v, ctx, it, end);
 4781|       |                                 }
 4782|       |                                 else if constexpr (custom_read<V>) {
 4783|       |                                    // Custom handlers parse the remaining body themselves.
 4784|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4785|       |                                 }
 4786|       |                              },
 4787|       |                              value);
 4788|       |                        }
 4789|       |                        else {
 4790|       |                           ctx.error = error_code::no_matching_variant_type;
 4791|       |                        }
 4792|       |                     }
 4793|       |                  }
 4794|       |                  else {
 4795|       |                     // For variants with 0 or 1 object types, use the original error handling
 4796|       |                     ctx.error = error_code::no_matching_variant_type;
 4797|       |                  }
 4798|       |               }
 4799|      0|               break;
 4800|  20.2k|            }
 4801|   613k|            case '[':
  ------------------
  |  Branch (4801:13): [True: 613k, False: 1.98M]
  ------------------
 4802|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4803|   613k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4804|   613k|               break;
 4805|  5.26k|            case '"': {
  ------------------
  |  Branch (4805:13): [True: 5.26k, False: 2.58M]
  ------------------
 4806|  5.26k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4807|  5.26k|               break;
 4808|  20.2k|            }
 4809|    909|            case 't':
  ------------------
  |  Branch (4809:13): [True: 909, False: 2.59M]
  ------------------
 4810|  1.19k|            case 'f': {
  ------------------
  |  Branch (4810:13): [True: 290, False: 2.59M]
  ------------------
 4811|  1.19k|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4812|  1.19k|               break;
 4813|    909|            }
 4814|    590|            case 'n':
  ------------------
  |  Branch (4814:13): [True: 590, False: 2.59M]
  ------------------
 4815|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4816|       |                  ctx.error = error_code::no_matching_variant_type;
 4817|       |               }
 4818|    590|               else {
 4819|    590|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4820|    590|                  using V = std::variant_alternative_t<first_idx, T>;
 4821|    590|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4821:23): [True: 200, False: 390]
  ------------------
 4822|    590|                  match<"null", Opts>(ctx, it, end);
 4823|    590|               }
 4824|    590|               break;
 4825|  1.95M|            default: {
  ------------------
  |  Branch (4825:13): [True: 1.95M, False: 642k]
  ------------------
 4826|       |               // Not bool, string, object, or array so must be number or null
 4827|  1.95M|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4828|  1.95M|            }
 4829|  2.59M|            }
 4830|       |         }
 4831|       |         else {
 4832|       |            // For non-auto-deducible variants, try each type until one succeeds
 4833|       |            constexpr auto N = std::variant_size_v<T>;
 4834|       |            bool parsed = false;
 4835|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4836|       |
 4837|       |            for_each<N>([&]<size_t I>() {
 4838|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4839|       |
 4840|       |               auto copy_it = it;
 4841|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4842|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4843|       |               const auto copy_depth = ctx.depth;
 4844|       |
 4845|       |               // Try parsing as this type
 4846|       |               if (value.index() != I) {
 4847|       |                  emplace_runtime_variant(value, I);
 4848|       |               }
 4849|       |
 4850|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4851|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4852|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4853|       |               }
 4854|       |
 4855|       |               if (!bool(ctx.error)) {
 4856|       |                  parsed = true;
 4857|       |               }
 4858|       |               else if constexpr (not Options.null_terminated) {
 4859|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4860|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4861|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4862|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4863|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4864|       |                     parsed = true;
 4865|       |                     ctx.error = error_code::none;
 4866|       |                  }
 4867|       |                  else {
 4868|       |                     // Reset for next attempt (unless this is the last type)
 4869|       |                     it = copy_it;
 4870|       |                     rewind_depth<Options>(ctx, copy_depth);
 4871|       |                     if constexpr (I + 1 < N) {
 4872|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4873|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4874|       |                        }
 4875|       |                     }
 4876|       |                  }
 4877|       |               }
 4878|       |               else {
 4879|       |                  // Reset for next attempt (unless this is the last type)
 4880|       |                  it = copy_it;
 4881|       |                  rewind_depth<Options>(ctx, copy_depth);
 4882|       |                  if constexpr (I + 1 < N) {
 4883|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4884|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4885|       |                     }
 4886|       |                  }
 4887|       |               }
 4888|       |            });
 4889|       |         }
 4890|  2.59M|      }
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3725|   615k|      {
 3726|   615k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3727|       |
 3728|       |         if constexpr (category_count == 0) {
 3729|       |            ctx.error = error_code::no_matching_variant_type;
 3730|       |         }
 3731|   615k|         else {
 3732|   615k|            constexpr auto N = std::variant_size_v<Variant>;
 3733|   615k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3734|   615k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3735|       |
 3736|   615k|            bool found_match{};
 3737|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3738|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3739|       |            // so the budget stops it and the failure already in hand is reported.
 3740|   615k|            bool exhausted{};
 3741|       |
 3742|       |            // First pass: const glaze types in this category
 3743|       |            if constexpr (const_count > 0) {
 3744|       |               for_each<N>([&]<size_t I>() {
 3745|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3746|       |                     return;
 3747|       |                  }
 3748|       |                  using V = std::variant_alternative_t<I, Variant>;
 3749|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3750|       |                     // run time substitute to compare to const value
 3751|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3752|       |                     auto copy_it{it};
 3753|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3754|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3755|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3756|       |                     const auto copy_depth{ctx.depth};
 3757|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3758|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3759|       |                     if (substitute == const_value) {
 3760|       |                        found_match = true;
 3761|       |                        if (!std::holds_alternative<V>(value)) {
 3762|       |                           value = V{};
 3763|       |                        }
 3764|       |                     }
 3765|       |                     else {
 3766|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3767|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3768|       |                           exhausted = true;
 3769|       |                        }
 3770|       |                        if constexpr (not Options.null_terminated) {
 3771|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3772|       |                              ctx.error = error_code::none;
 3773|       |                           }
 3774|       |                        }
 3775|       |                        it = copy_it;
 3776|       |                        rewind_depth<Options>(ctx, copy_depth);
 3777|       |                     }
 3778|       |                  }
 3779|       |               });
 3780|       |               if (found_match) {
 3781|       |                  return;
 3782|       |               }
 3783|       |            }
 3784|       |
 3785|       |            // Second pass: non-const types in this category
 3786|   615k|            if constexpr (non_const_count > 0) {
 3787|       |               // Track position within matching types for "is last" check.
 3788|       |               // We iterate over all variant indices but only process matching types,
 3789|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3790|       |               // the loop index directly corresponded to position in filtered set).
 3791|       |               // This has negligible cost: one increment per matching type.
 3792|   615k|               size_t non_const_idx = 0;
 3793|       |
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3796|   615k|                     return;
 3797|   615k|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|   615k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|   615k|                     auto copy_it{it};
 3801|   615k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|   615k|                     if (!std::holds_alternative<V>(value)) {
 3803|   615k|                        value = V{};
 3804|   615k|                     }
 3805|   615k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|   615k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|   615k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|   615k|                     }
 3809|   615k|                     if (!bool(ctx.error)) {
 3810|   615k|                        found_match = true;
 3811|   615k|                     }
 3812|   615k|                     else if constexpr (not Options.null_terminated) {
 3813|   615k|                        constexpr bool is_complete_type =
 3814|   615k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|   615k|                        if constexpr (is_complete_type) {
 3817|   615k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|   615k|                              found_match = true;
 3819|   615k|                              ctx.error = error_code::none;
 3820|   615k|                           }
 3821|   615k|                           else {
 3822|   615k|                              it = copy_it;
 3823|   615k|                              rewind_depth<Options>(ctx, copy_depth);
 3824|   615k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|   615k|                                  not variant_alternative_exhausted(ctx)) {
 3826|   615k|                                 ctx.error = error_code::none;
 3827|   615k|                              }
 3828|   615k|                           }
 3829|   615k|                        }
 3830|   615k|                        else {
 3831|   615k|                           it = copy_it;
 3832|   615k|                           rewind_depth<Options>(ctx, copy_depth);
 3833|   615k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|   615k|                               not variant_alternative_exhausted(ctx)) {
 3835|   615k|                              ctx.error = error_code::none;
 3836|   615k|                           }
 3837|   615k|                        }
 3838|   615k|                     }
 3839|   615k|                     else {
 3840|   615k|                        it = copy_it;
 3841|   615k|                        rewind_depth<Options>(ctx, copy_depth);
 3842|   615k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|   615k|                            not variant_alternative_exhausted(ctx)) {
 3844|   615k|                           ctx.error = error_code::none;
 3845|   615k|                        }
 3846|   615k|                     }
 3847|   615k|                     ++non_const_idx;
 3848|   615k|                  }
 3849|   615k|               });
 3850|   615k|               if (!found_match) {
  ------------------
  |  Branch (3850:20): [True: 13.7k, False: 602k]
  ------------------
 3851|  13.7k|                  if constexpr (non_const_count == 1) {
 3852|       |                     // Keep the specific error from the single type we tried
 3853|       |                  }
 3854|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3855|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3856|       |                     ctx.error = error_code::no_matching_variant_type;
 3857|       |                  }
 3858|  13.7k|               }
 3859|       |            }
 3860|       |            else {
 3861|       |               ctx.error = error_code::no_matching_variant_type;
 3862|       |            }
 3863|   615k|         }
 3864|   615k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|   615k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|   615k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|   615k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|   615k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 615k]
  |  Branch (3795:38): [True: 0, False: 615k]
  |  Branch (3795:51): [True: 0, False: 615k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|   615k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|   615k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|   615k|                     auto copy_it{it};
 3801|   615k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|   615k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3802:26): [True: 482k, False: 132k]
  ------------------
 3803|   482k|                        value = V{};
 3804|   482k|                     }
 3805|   615k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|   615k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3806:26): [True: 13.7k, False: 602k]
  |  Branch (3806:45): [True: 0, False: 13.7k]
  ------------------
 3807|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|      0|                     }
 3809|   615k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3809:26): [True: 602k, False: 13.7k]
  ------------------
 3810|   602k|                        found_match = true;
 3811|   602k|                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|  13.7k|                     else {
 3840|  13.7k|                        it = copy_it;
 3841|  13.7k|                        rewind_depth<Options>(ctx, copy_depth);
 3842|  13.7k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3842:29): [True: 0, False: 13.7k]
  |  Branch (3842:68): [True: 0, False: 0]
  ------------------
 3843|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3843:29): [True: 0, False: 0]
  ------------------
 3844|      0|                           ctx.error = error_code::none;
 3845|      0|                        }
 3846|  13.7k|                     }
 3847|   615k|                     ++non_const_idx;
 3848|   615k|                  }
 3849|   615k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERNSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS4_9allocatorIS9_EEEETkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
   49|   615k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|   615k|         else {
   60|   615k|            using V = std::remove_cvref_t<T>;
   61|   615k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|   615k|                                             end);
   63|   615k|         }
   64|   615k|      }
_ZN3glz4fromILj10ENSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS1_9allocatorIS6_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERS9_TkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
 2308|   615k|      {
 2309|   615k|         constexpr auto Opts = ws_handled_off<Options>();
 2310|       |         if constexpr (!check_ws_handled(Options)) {
 2311|       |            if (skip_ws<Opts>(ctx, it, end)) {
 2312|       |               return;
 2313|       |            }
 2314|       |         }
 2315|       |
 2316|   615k|         if (match_invalid_end<'[', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2316:14): [True: 0, False: 615k]
  ------------------
 2317|      0|            return;
 2318|      0|         }
 2319|       |         // one nesting level (see enter_depth): counted in both modes so the limit binds,
 2320|       |         // released at each syntactic close below
 2321|   615k|         if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (2321:14): [True: 3, False: 615k]
  ------------------
 2322|      3|            return;
 2323|      3|         }
 2324|       |
 2325|   615k|         const auto ws_start = it;
 2326|   615k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2326:14): [True: 0, False: 615k]
  ------------------
 2327|      0|            return;
 2328|      0|         }
 2329|       |
 2330|   615k|         if (*it == ']') {
  ------------------
  |  Branch (2330:14): [True: 4.84k, False: 611k]
  ------------------
 2331|  4.84k|            --ctx.depth;
 2332|  4.84k|            ++it;
 2333|  4.84k|            if constexpr ((resizable<T> || is_inplace_vector<T>) && not check_append_arrays(Opts)) {
 2334|  4.84k|               value.clear();
 2335|       |
 2336|       |               if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2337|       |                  value.shrink_to_fit();
 2338|       |               }
 2339|  4.84k|            }
 2340|  4.84k|            return;
 2341|  4.84k|         }
 2342|       |
 2343|   611k|         const size_t ws_size = size_t(it - ws_start);
 2344|       |
 2345|   611k|         static constexpr bool should_append = (resizable<T> || is_inplace_vector<T>) && check_append_arrays(Opts);
  ------------------
  |  Branch (2345:49): [True: 611k, Folded]
  |  Branch (2345:65): [Folded, False: 0]
  |  Branch (2345:90): [Folded, False: 0]
  ------------------
 2346|   611k|         if constexpr (not should_append) {
 2347|   611k|            const auto n = value.size();
 2348|       |
 2349|   611k|            auto value_it = value.begin();
 2350|       |
 2351|   618k|            for (size_t i = 0; i < n; ++i) {
  ------------------
  |  Branch (2351:32): [True: 138k, False: 480k]
  ------------------
 2352|   138k|               parse<JSON>::op<ws_handled<Opts>()>(*value_it++, ctx, it, end);
 2353|   138k|               if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2353:20): [True: 758, False: 137k]
  ------------------
 2354|    758|                  return;
 2355|   137k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2355:20): [True: 0, False: 137k]
  ------------------
 2356|      0|                  return;
 2357|      0|               }
 2358|   137k|               if (*it == ',') {
  ------------------
  |  Branch (2358:20): [True: 7.74k, False: 129k]
  ------------------
 2359|  7.74k|                  ++it;
 2360|       |
 2361|  7.74k|                  if constexpr (!Opts.minified && !Opts.comments) {
 2362|  7.74k|                     if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2362:26): [True: 4.53k, False: 3.20k]
  |  Branch (2362:37): [True: 4.09k, False: 434]
  ------------------
 2363|  4.09k|                        skip_matching_ws(ws_start, it, ws_size);
 2364|  4.09k|                     }
 2365|  7.74k|                  }
 2366|       |
 2367|  7.74k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2367:23): [True: 0, False: 7.74k]
  ------------------
 2368|      0|                     return;
 2369|      0|                  }
 2370|  7.74k|               }
 2371|   129k|               else if (*it == ']') {
  ------------------
  |  Branch (2371:25): [True: 129k, False: 75]
  ------------------
 2372|   129k|                  --ctx.depth;
 2373|   129k|                  ++it;
 2374|   129k|                  if constexpr (erasable<T>) {
 2375|   129k|                     value.erase(value_it,
 2376|   129k|                                 value.end()); // use erase rather than resize for non-default constructible elements
 2377|       |
 2378|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2379|       |                        value.shrink_to_fit();
 2380|       |                     }
 2381|   129k|                  }
 2382|   129k|                  return;
 2383|   129k|               }
 2384|     75|               else [[unlikely]] {
 2385|     75|                  ctx.error = error_code::expected_bracket;
 2386|     75|                  return;
 2387|     75|               }
 2388|   137k|            }
 2389|   611k|         }
 2390|       |
 2391|       |         if constexpr (Opts.partial_read) {
 2392|       |            // partial_read stops early on a success path, so give the level back like the
 2393|       |            // syntactic-close paths do; otherwise it accumulates across reads sharing a context.
 2394|       |            --ctx.depth;
 2395|       |            return;
 2396|       |         }
 2397|   611k|         else {
 2398|       |            // growing
 2399|   611k|            if constexpr (emplace_backable<T> || has_try_emplace_back<T>) {
 2400|  1.71M|               while (it < end) {
  ------------------
  |  Branch (2400:23): [True: 1.58M, False: 130k]
  ------------------
 2401|       |                  // Streaming refill point: at start of each iteration, ensure buffer has data
 2402|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2403|       |                     if (ctx.stream.enabled()) {
 2404|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2405|       |                        const size_t remaining = ctx.stream.size() - consumed;
 2406|       |                        // Refill when less than half of buffer remains to ensure space for next element
 2407|       |                        if (remaining <= ctx.stream.size() / 2 || it >= end) {
 2408|       |                           const char* new_it;
 2409|       |                           const char* new_end;
 2410|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2411|       |                           it = new_it;
 2412|       |                           end = new_end;
 2413|       |                           if (it >= end && ctx.stream.at_eof()) {
 2414|       |                              break; // No more data, exit loop normally
 2415|       |                           }
 2416|       |                        }
 2417|       |                     }
 2418|       |                  }
 2419|       |
 2420|       |                  if constexpr (has_try_emplace_back<T>) {
 2421|       |                     if (value.try_emplace_back())
 2422|       |                        parse<JSON>::op<ws_handled<Opts>()>(value.back(), ctx, it, end);
 2423|       |                     else
 2424|       |                        ctx.error = error_code::exceeded_static_array_size;
 2425|       |                  }
 2426|  1.58M|                  else {
 2427|  1.58M|                     parse<JSON>::op<ws_handled<Opts>()>(value.emplace_back(), ctx, it, end);
 2428|  1.58M|                  }
 2429|       |
 2430|  1.58M|                  if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2430:23): [True: 11.8k, False: 1.57M]
  ------------------
 2431|  11.8k|                     return;
 2432|       |
 2433|       |                  // Streaming refill point: after parsing each element, refill if buffer is low
 2434|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2435|       |                     if (ctx.stream.enabled()) {
 2436|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2437|       |                        // Refill when less than 25% of buffer remains to ensure enough space for next element
 2438|       |                        if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 2439|       |                           const char* new_it;
 2440|       |                           const char* new_end;
 2441|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2442|       |                           it = new_it;
 2443|       |                           end = new_end;
 2444|       |                           if (it >= end && ctx.stream.at_eof()) {
 2445|       |                              ctx.error = error_code::unexpected_end;
 2446|       |                              return;
 2447|       |                           }
 2448|       |                        }
 2449|       |                     }
 2450|       |                  }
 2451|       |
 2452|  1.57M|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2452:23): [True: 0, False: 1.57M]
  ------------------
 2453|      0|                     return;
 2454|      0|                  }
 2455|  1.57M|                  if (*it == ',') [[likely]] {
  ------------------
  |  Branch (2455:23): [True: 1.10M, False: 468k]
  ------------------
 2456|  1.10M|                     ++it;
 2457|       |
 2458|  1.10M|                     if constexpr (!Opts.minified && !Opts.comments) {
 2459|  1.10M|                        if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2459:29): [True: 15.4k, False: 1.09M]
  |  Branch (2459:40): [True: 14.7k, False: 648]
  ------------------
 2460|  14.7k|                           skip_matching_ws(ws_start, it, ws_size);
 2461|  14.7k|                        }
 2462|  1.10M|                     }
 2463|       |
 2464|  1.10M|                     if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2464:26): [True: 0, False: 1.10M]
  ------------------
 2465|      0|                        return;
 2466|      0|                     }
 2467|  1.10M|                  }
 2468|   468k|                  else if (*it == ']') {
  ------------------
  |  Branch (2468:28): [True: 467k, False: 1.00k]
  ------------------
 2469|   467k|                     --ctx.depth;
 2470|   467k|                     ++it;
 2471|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2472|       |                        value.shrink_to_fit();
 2473|       |                     }
 2474|   467k|                     return;
 2475|   467k|                  }
 2476|  1.00k|                  else [[unlikely]] {
 2477|  1.00k|                     ctx.error = error_code::expected_bracket;
 2478|  1.00k|                     return;
 2479|  1.00k|                  }
 2480|  1.57M|               }
 2481|       |
 2482|       |               // A valid array always returns from inside the loop upon reaching ']'.
 2483|       |               // For a null-terminated buffer the loop can only exit here by falling
 2484|       |               // through when `it` reaches the terminator without a closing bracket,
 2485|       |               // which means the input was truncated (e.g. "[", "[1," or "[1,2,").
 2486|       |               // Non-null-terminated buffers surface this through skip_ws/depth
 2487|       |               // tracking (or the streaming refill break), so this guard is limited
 2488|       |               // to the null-terminated case.
 2489|   130k|               if constexpr (Opts.null_terminated) {
 2490|   130k|                  ctx.error = error_code::unexpected_end;
 2491|   130k|               }
 2492|       |            }
 2493|       |            else {
 2494|       |               ctx.error = error_code::exceeded_static_array_size;
 2495|       |            }
 2496|   611k|         }
 2497|   611k|      }
_ZN3glz12rewind_depthITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEETkNS_10is_contextENS_7contextEEEvRT0_j:
 3697|  16.3k|   {
 3698|  16.3k|      if (ctx.error == error_code::exceeded_max_recursive_depth) [[unlikely]] {
  ------------------
  |  Branch (3698:11): [True: 1.19k, False: 15.1k]
  ------------------
 3699|  1.19k|         return;
 3700|  1.19k|      }
 3701|  15.1k|      if constexpr (Opts.null_terminated) {
 3702|  15.1k|         ctx.depth = depth;
 3703|       |      }
 3704|       |      else {
 3705|       |         if (ctx.error != error_code::end_reached && ctx.error != error_code::unexpected_end) {
 3706|       |            ctx.depth = depth;
 3707|       |         }
 3708|       |      }
 3709|  15.1k|   }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3794|   615k|               for_each<N>([&]<size_t I>() {
 3795|   615k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 602k, False: 13.7k]
  |  Branch (3795:38): [True: 0, False: 13.7k]
  |  Branch (3795:51): [True: 1.19k, False: 12.5k]
  ------------------
 3796|   603k|                     return;
 3797|   603k|                  }
 3798|  12.5k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  12.5k|               });
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3725|  6.38k|      {
 3726|  6.38k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3727|       |
 3728|       |         if constexpr (category_count == 0) {
 3729|       |            ctx.error = error_code::no_matching_variant_type;
 3730|       |         }
 3731|  6.38k|         else {
 3732|  6.38k|            constexpr auto N = std::variant_size_v<Variant>;
 3733|  6.38k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3734|  6.38k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3735|       |
 3736|  6.38k|            bool found_match{};
 3737|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3738|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3739|       |            // so the budget stops it and the failure already in hand is reported.
 3740|  6.38k|            bool exhausted{};
 3741|       |
 3742|       |            // First pass: const glaze types in this category
 3743|       |            if constexpr (const_count > 0) {
 3744|       |               for_each<N>([&]<size_t I>() {
 3745|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3746|       |                     return;
 3747|       |                  }
 3748|       |                  using V = std::variant_alternative_t<I, Variant>;
 3749|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3750|       |                     // run time substitute to compare to const value
 3751|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3752|       |                     auto copy_it{it};
 3753|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3754|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3755|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3756|       |                     const auto copy_depth{ctx.depth};
 3757|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3758|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3759|       |                     if (substitute == const_value) {
 3760|       |                        found_match = true;
 3761|       |                        if (!std::holds_alternative<V>(value)) {
 3762|       |                           value = V{};
 3763|       |                        }
 3764|       |                     }
 3765|       |                     else {
 3766|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3767|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3768|       |                           exhausted = true;
 3769|       |                        }
 3770|       |                        if constexpr (not Options.null_terminated) {
 3771|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3772|       |                              ctx.error = error_code::none;
 3773|       |                           }
 3774|       |                        }
 3775|       |                        it = copy_it;
 3776|       |                        rewind_depth<Options>(ctx, copy_depth);
 3777|       |                     }
 3778|       |                  }
 3779|       |               });
 3780|       |               if (found_match) {
 3781|       |                  return;
 3782|       |               }
 3783|       |            }
 3784|       |
 3785|       |            // Second pass: non-const types in this category
 3786|  6.38k|            if constexpr (non_const_count > 0) {
 3787|       |               // Track position within matching types for "is last" check.
 3788|       |               // We iterate over all variant indices but only process matching types,
 3789|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3790|       |               // the loop index directly corresponded to position in filtered set).
 3791|       |               // This has negligible cost: one increment per matching type.
 3792|  6.38k|               size_t non_const_idx = 0;
 3793|       |
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3796|  6.38k|                     return;
 3797|  6.38k|                  }
 3798|  6.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  6.38k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  6.38k|                     auto copy_it{it};
 3801|  6.38k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  6.38k|                     if (!std::holds_alternative<V>(value)) {
 3803|  6.38k|                        value = V{};
 3804|  6.38k|                     }
 3805|  6.38k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  6.38k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|  6.38k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|  6.38k|                     }
 3809|  6.38k|                     if (!bool(ctx.error)) {
 3810|  6.38k|                        found_match = true;
 3811|  6.38k|                     }
 3812|  6.38k|                     else if constexpr (not Options.null_terminated) {
 3813|  6.38k|                        constexpr bool is_complete_type =
 3814|  6.38k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|  6.38k|                        if constexpr (is_complete_type) {
 3817|  6.38k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|  6.38k|                              found_match = true;
 3819|  6.38k|                              ctx.error = error_code::none;
 3820|  6.38k|                           }
 3821|  6.38k|                           else {
 3822|  6.38k|                              it = copy_it;
 3823|  6.38k|                              rewind_depth<Options>(ctx, copy_depth);
 3824|  6.38k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|  6.38k|                                  not variant_alternative_exhausted(ctx)) {
 3826|  6.38k|                                 ctx.error = error_code::none;
 3827|  6.38k|                              }
 3828|  6.38k|                           }
 3829|  6.38k|                        }
 3830|  6.38k|                        else {
 3831|  6.38k|                           it = copy_it;
 3832|  6.38k|                           rewind_depth<Options>(ctx, copy_depth);
 3833|  6.38k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|  6.38k|                               not variant_alternative_exhausted(ctx)) {
 3835|  6.38k|                              ctx.error = error_code::none;
 3836|  6.38k|                           }
 3837|  6.38k|                        }
 3838|  6.38k|                     }
 3839|  6.38k|                     else {
 3840|  6.38k|                        it = copy_it;
 3841|  6.38k|                        rewind_depth<Options>(ctx, copy_depth);
 3842|  6.38k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|  6.38k|                            not variant_alternative_exhausted(ctx)) {
 3844|  6.38k|                           ctx.error = error_code::none;
 3845|  6.38k|                        }
 3846|  6.38k|                     }
 3847|  6.38k|                     ++non_const_idx;
 3848|  6.38k|                  }
 3849|  6.38k|               });
 3850|  6.38k|               if (!found_match) {
  ------------------
  |  Branch (3850:20): [True: 843, False: 5.53k]
  ------------------
 3851|    843|                  if constexpr (non_const_count == 1) {
 3852|       |                     // Keep the specific error from the single type we tried
 3853|       |                  }
 3854|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3855|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3856|       |                     ctx.error = error_code::no_matching_variant_type;
 3857|       |                  }
 3858|    843|               }
 3859|       |            }
 3860|       |            else {
 3861|       |               ctx.error = error_code::no_matching_variant_type;
 3862|       |            }
 3863|  6.38k|         }
 3864|  6.38k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 6.38k]
  |  Branch (3795:38): [True: 0, False: 6.38k]
  |  Branch (3795:51): [True: 0, False: 6.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  6.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  6.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 6.38k]
  |  Branch (3795:38): [True: 0, False: 6.38k]
  |  Branch (3795:51): [True: 0, False: 6.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  6.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  6.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 6.38k]
  |  Branch (3795:38): [True: 0, False: 6.38k]
  |  Branch (3795:51): [True: 0, False: 6.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  6.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  6.38k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  6.38k|                     auto copy_it{it};
 3801|  6.38k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  6.38k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3802:26): [True: 4.65k, False: 1.72k]
  ------------------
 3803|  4.65k|                        value = V{};
 3804|  4.65k|                     }
 3805|  6.38k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  6.38k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3806:26): [True: 843, False: 5.53k]
  |  Branch (3806:45): [True: 0, False: 843]
  ------------------
 3807|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|      0|                     }
 3809|  6.38k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3809:26): [True: 5.53k, False: 843]
  ------------------
 3810|  5.53k|                        found_match = true;
 3811|  5.53k|                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|    843|                     else {
 3840|    843|                        it = copy_it;
 3841|    843|                        rewind_depth<Options>(ctx, copy_depth);
 3842|    843|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3842:29): [True: 0, False: 843]
  |  Branch (3842:68): [True: 0, False: 0]
  ------------------
 3843|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3843:29): [True: 0, False: 0]
  ------------------
 3844|      0|                           ctx.error = error_code::none;
 3845|      0|                        }
 3846|    843|                     }
 3847|  6.38k|                     ++non_const_idx;
 3848|  6.38k|                  }
 3849|  6.38k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|  6.38k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  6.38k|         else {
   60|  6.38k|            using V = std::remove_cvref_t<T>;
   61|  6.38k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  6.38k|                                             end);
   63|  6.38k|         }
   64|  6.38k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEQcl15check_is_paddedTL0__EEEvRT2_OT3_OT0_T1_:
  892|  6.38k|      {
  893|       |         if constexpr (check_string_as_number(Opts)) {
  894|       |            auto start = it;
  895|       |            skip_number<Opts>(ctx, it, end);
  896|       |            if (bool(ctx.error)) [[unlikely]] {
  897|       |               return;
  898|       |            }
  899|       |            value.append(start, size_t(it - start));
  900|       |         }
  901|  6.38k|         else {
  902|  6.38k|            if constexpr (!check_opening_handled(Opts)) {
  903|       |               if constexpr (!check_ws_handled(Opts)) {
  904|       |                  if (skip_ws<Opts>(ctx, it, end)) {
  905|       |                     return;
  906|       |                  }
  907|       |               }
  908|       |
  909|  6.38k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (909:20): [True: 0, False: 6.38k]
  ------------------
  910|      0|                  return;
  911|      0|               }
  912|  6.38k|            }
  913|       |
  914|  6.38k|            if constexpr (not check_raw_string(Opts)) {
  915|  6.38k|               static constexpr auto string_padding_bytes = 8;
  916|       |
  917|  6.38k|               auto start = it;
  918|  6.38k|               uint64_t ascii_acc{};
  919|  1.45M|               while (true) {
  ------------------
  |  Branch (919:23): [True: 1.45M, Folded]
  ------------------
  920|  1.45M|                  if (it >= end) [[unlikely]] {
  ------------------
  |  Branch (920:23): [True: 316, False: 1.45M]
  ------------------
  921|    316|                     ctx.error = error_code::unexpected_end;
  922|    316|                     return;
  923|    316|                  }
  924|       |
  925|  1.45M|                  uint64_t chunk;
  926|  1.45M|                  std::memcpy(&chunk, it, 8);
  927|       |                  if constexpr (std::endian::native == std::endian::big) {
  928|       |                     chunk = std::byteswap(chunk);
  929|       |                  }
  930|  1.45M|                  ascii_acc |= chunk;
  931|  1.45M|                  const uint64_t test_chars = has_quote(chunk);
  932|  1.45M|                  if (test_chars) {
  ------------------
  |  Branch (932:23): [True: 7.84k, False: 1.44M]
  ------------------
  933|  7.84k|                     it += (countr_zero(test_chars) >> 3);
  934|       |
  935|  7.84k|                     auto* prev = it - 1;
  936|  10.6k|                     while (*prev == '\\') {
  ------------------
  |  Branch (936:29): [True: 2.84k, False: 7.84k]
  ------------------
  937|  2.84k|                        --prev;
  938|  2.84k|                     }
  939|  7.84k|                     if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (939:26): [True: 6.06k, False: 1.78k]
  ------------------
  940|  6.06k|                        break;
  941|  6.06k|                     }
  942|  1.78k|                     ++it; // skip the escaped quote
  943|  1.78k|                  }
  944|  1.44M|                  else {
  945|  1.44M|                     it += 8;
  946|  1.44M|                  }
  947|  1.45M|               }
  948|       |
  949|  6.06k|               if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (949:20): [True: 249, False: 5.81k]
  ------------------
  950|    249|                  return;
  951|    249|               }
  952|       |
  953|  5.81k|               auto n = size_t(it - start);
  954|  5.81k|               value.resize(n + string_padding_bytes);
  955|       |
  956|  5.81k|               auto* p = value.data();
  957|       |
  958|   175k|               while (true) {
  ------------------
  |  Branch (958:23): [True: 175k, Folded]
  ------------------
  959|   175k|                  if (start >= it) {
  ------------------
  |  Branch (959:23): [True: 5.11k, False: 170k]
  ------------------
  960|  5.11k|                     break;
  961|  5.11k|                  }
  962|       |
  963|   170k|                  std::memcpy(p, start, 8);
  964|   170k|                  uint64_t swar;
  965|   170k|                  std::memcpy(&swar, p, 8);
  966|       |                  if constexpr (std::endian::native == std::endian::big) {
  967|       |                     swar = std::byteswap(swar);
  968|       |                  }
  969|       |
  970|   170k|                  constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
  971|   170k|                  const uint64_t lo7 = swar & lo7_mask;
  972|   170k|                  const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
  973|   170k|                  const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
  974|   170k|                  uint64_t next = ~((backslash & less_32) | swar);
  975|       |
  976|   170k|                  next &= repeat_byte8(0b10000000);
  977|   170k|                  if (next == 0) {
  ------------------
  |  Branch (977:23): [True: 166k, False: 4.36k]
  ------------------
  978|   166k|                     start += 8;
  979|   166k|                     p += 8;
  980|   166k|                     continue;
  981|   166k|                  }
  982|       |
  983|  4.36k|                  next = countr_zero(next) >> 3;
  984|  4.36k|                  start += next;
  985|  4.36k|                  if (start >= it) {
  ------------------
  |  Branch (985:23): [True: 421, False: 3.94k]
  ------------------
  986|    421|                     break;
  987|    421|                  }
  988|       |
  989|  3.94k|                  if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (989:23): [True: 83, False: 3.85k]
  ------------------
  990|     83|                     ctx.error = error_code::syntax_error;
  991|     83|                     return;
  992|     83|                  }
  993|  3.85k|                  ++start; // skip the escape
  994|  3.85k|                  if (*start == 'u') {
  ------------------
  |  Branch (994:23): [True: 2.39k, False: 1.45k]
  ------------------
  995|  2.39k|                     ++start;
  996|  2.39k|                     p += next;
  997|  2.39k|                     const auto mark = start;
  998|  2.39k|                     const auto offset = handle_unicode_code_point(start, p, end);
  999|  2.39k|                     if (offset == 0) [[unlikely]] {
  ------------------
  |  Branch (999:26): [True: 162, False: 2.23k]
  ------------------
 1000|    162|                        ctx.error = error_code::unicode_escape_conversion_failure;
 1001|    162|                        return;
 1002|    162|                     }
 1003|  2.23k|                     n += offset;
 1004|       |                     // escape + u + unicode code points
 1005|  2.23k|                     n -= 2 + uint32_t(start - mark);
 1006|  2.23k|                  }
 1007|  1.45k|                  else {
 1008|  1.45k|                     p += next;
 1009|  1.45k|                     *p = char_unescape_table[uint8_t(*start)];
 1010|  1.45k|                     if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1010:26): [True: 33, False: 1.42k]
  ------------------
 1011|     33|                        ctx.error = error_code::invalid_escape;
 1012|     33|                        return;
 1013|     33|                     }
 1014|  1.42k|                     ++p;
 1015|  1.42k|                     ++start;
 1016|  1.42k|                     --n;
 1017|  1.42k|                  }
 1018|  3.85k|               }
 1019|       |
 1020|  5.53k|               value.resize(n);
 1021|  5.53k|               ++it;
 1022|       |            }
 1023|       |            else {
 1024|       |               // raw_string
 1025|       |               auto start = it;
 1026|       |               skip_string_view(ctx, it, end);
 1027|       |               if (bool(ctx.error)) [[unlikely]]
 1028|       |                  return;
 1029|       |
 1030|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1031|       |                  return;
 1032|       |               }
 1033|       |
 1034|       |               value.assign(start, size_t(it - start));
 1035|       |               ++it;
 1036|       |            }
 1037|  6.38k|         }
 1038|  6.38k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 5.53k, False: 843]
  |  Branch (3795:38): [True: 0, False: 843]
  |  Branch (3795:51): [True: 0, False: 843]
  ------------------
 3796|  5.53k|                     return;
 3797|  5.53k|                  }
 3798|    843|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    843|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 5.53k, False: 843]
  |  Branch (3795:38): [True: 0, False: 843]
  |  Branch (3795:51): [True: 0, False: 843]
  ------------------
 3796|  5.53k|                     return;
 3797|  5.53k|                  }
 3798|    843|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    843|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3794|  6.38k|               for_each<N>([&]<size_t I>() {
 3795|  6.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 5.53k, False: 843]
  |  Branch (3795:38): [True: 0, False: 843]
  |  Branch (3795:51): [True: 0, False: 843]
  ------------------
 3796|  5.53k|                     return;
 3797|  5.53k|                  }
 3798|    843|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    843|               });
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3725|  1.38k|      {
 3726|  1.38k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3727|       |
 3728|       |         if constexpr (category_count == 0) {
 3729|       |            ctx.error = error_code::no_matching_variant_type;
 3730|       |         }
 3731|  1.38k|         else {
 3732|  1.38k|            constexpr auto N = std::variant_size_v<Variant>;
 3733|  1.38k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3734|  1.38k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3735|       |
 3736|  1.38k|            bool found_match{};
 3737|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3738|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3739|       |            // so the budget stops it and the failure already in hand is reported.
 3740|  1.38k|            bool exhausted{};
 3741|       |
 3742|       |            // First pass: const glaze types in this category
 3743|       |            if constexpr (const_count > 0) {
 3744|       |               for_each<N>([&]<size_t I>() {
 3745|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3746|       |                     return;
 3747|       |                  }
 3748|       |                  using V = std::variant_alternative_t<I, Variant>;
 3749|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3750|       |                     // run time substitute to compare to const value
 3751|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3752|       |                     auto copy_it{it};
 3753|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3754|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3755|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3756|       |                     const auto copy_depth{ctx.depth};
 3757|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3758|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3759|       |                     if (substitute == const_value) {
 3760|       |                        found_match = true;
 3761|       |                        if (!std::holds_alternative<V>(value)) {
 3762|       |                           value = V{};
 3763|       |                        }
 3764|       |                     }
 3765|       |                     else {
 3766|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3767|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3768|       |                           exhausted = true;
 3769|       |                        }
 3770|       |                        if constexpr (not Options.null_terminated) {
 3771|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3772|       |                              ctx.error = error_code::none;
 3773|       |                           }
 3774|       |                        }
 3775|       |                        it = copy_it;
 3776|       |                        rewind_depth<Options>(ctx, copy_depth);
 3777|       |                     }
 3778|       |                  }
 3779|       |               });
 3780|       |               if (found_match) {
 3781|       |                  return;
 3782|       |               }
 3783|       |            }
 3784|       |
 3785|       |            // Second pass: non-const types in this category
 3786|  1.38k|            if constexpr (non_const_count > 0) {
 3787|       |               // Track position within matching types for "is last" check.
 3788|       |               // We iterate over all variant indices but only process matching types,
 3789|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3790|       |               // the loop index directly corresponded to position in filtered set).
 3791|       |               // This has negligible cost: one increment per matching type.
 3792|  1.38k|               size_t non_const_idx = 0;
 3793|       |
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3796|  1.38k|                     return;
 3797|  1.38k|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  1.38k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  1.38k|                     auto copy_it{it};
 3801|  1.38k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  1.38k|                     if (!std::holds_alternative<V>(value)) {
 3803|  1.38k|                        value = V{};
 3804|  1.38k|                     }
 3805|  1.38k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  1.38k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|  1.38k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|  1.38k|                     }
 3809|  1.38k|                     if (!bool(ctx.error)) {
 3810|  1.38k|                        found_match = true;
 3811|  1.38k|                     }
 3812|  1.38k|                     else if constexpr (not Options.null_terminated) {
 3813|  1.38k|                        constexpr bool is_complete_type =
 3814|  1.38k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|  1.38k|                        if constexpr (is_complete_type) {
 3817|  1.38k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|  1.38k|                              found_match = true;
 3819|  1.38k|                              ctx.error = error_code::none;
 3820|  1.38k|                           }
 3821|  1.38k|                           else {
 3822|  1.38k|                              it = copy_it;
 3823|  1.38k|                              rewind_depth<Options>(ctx, copy_depth);
 3824|  1.38k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|  1.38k|                                  not variant_alternative_exhausted(ctx)) {
 3826|  1.38k|                                 ctx.error = error_code::none;
 3827|  1.38k|                              }
 3828|  1.38k|                           }
 3829|  1.38k|                        }
 3830|  1.38k|                        else {
 3831|  1.38k|                           it = copy_it;
 3832|  1.38k|                           rewind_depth<Options>(ctx, copy_depth);
 3833|  1.38k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|  1.38k|                               not variant_alternative_exhausted(ctx)) {
 3835|  1.38k|                              ctx.error = error_code::none;
 3836|  1.38k|                           }
 3837|  1.38k|                        }
 3838|  1.38k|                     }
 3839|  1.38k|                     else {
 3840|  1.38k|                        it = copy_it;
 3841|  1.38k|                        rewind_depth<Options>(ctx, copy_depth);
 3842|  1.38k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|  1.38k|                            not variant_alternative_exhausted(ctx)) {
 3844|  1.38k|                           ctx.error = error_code::none;
 3845|  1.38k|                        }
 3846|  1.38k|                     }
 3847|  1.38k|                     ++non_const_idx;
 3848|  1.38k|                  }
 3849|  1.38k|               });
 3850|  1.38k|               if (!found_match) {
  ------------------
  |  Branch (3850:20): [True: 257, False: 1.13k]
  ------------------
 3851|    257|                  if constexpr (non_const_count == 1) {
 3852|       |                     // Keep the specific error from the single type we tried
 3853|       |                  }
 3854|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3855|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3856|       |                     ctx.error = error_code::no_matching_variant_type;
 3857|       |                  }
 3858|    257|               }
 3859|       |            }
 3860|       |            else {
 3861|       |               ctx.error = error_code::no_matching_variant_type;
 3862|       |            }
 3863|  1.38k|         }
 3864|  1.38k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.38k]
  |  Branch (3795:38): [True: 0, False: 1.38k]
  |  Branch (3795:51): [True: 0, False: 1.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.38k]
  |  Branch (3795:38): [True: 0, False: 1.38k]
  |  Branch (3795:51): [True: 0, False: 1.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.38k]
  |  Branch (3795:38): [True: 0, False: 1.38k]
  |  Branch (3795:51): [True: 0, False: 1.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.38k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.38k]
  |  Branch (3795:38): [True: 0, False: 1.38k]
  |  Branch (3795:51): [True: 0, False: 1.38k]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.38k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  1.38k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  1.38k|                     auto copy_it{it};
 3801|  1.38k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  1.38k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3802:26): [True: 1.19k, False: 194]
  ------------------
 3803|  1.19k|                        value = V{};
 3804|  1.19k|                     }
 3805|  1.38k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  1.38k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3806:26): [True: 257, False: 1.13k]
  |  Branch (3806:45): [True: 0, False: 257]
  ------------------
 3807|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|      0|                     }
 3809|  1.38k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3809:26): [True: 1.13k, False: 257]
  ------------------
 3810|  1.13k|                        found_match = true;
 3811|  1.13k|                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|    257|                     else {
 3840|    257|                        it = copy_it;
 3841|    257|                        rewind_depth<Options>(ctx, copy_depth);
 3842|    257|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3842:29): [True: 0, False: 257]
  |  Branch (3842:68): [True: 0, False: 0]
  ------------------
 3843|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3843:29): [True: 0, False: 0]
  ------------------
 3844|      0|                           ctx.error = error_code::none;
 3845|      0|                        }
 3846|    257|                     }
 3847|  1.38k|                     ++non_const_idx;
 3848|  1.38k|                  }
 3849|  1.38k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  1.38k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  1.38k|         else {
   60|  1.38k|            using V = std::remove_cvref_t<T>;
   61|  1.38k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  1.38k|                                             end);
   63|  1.38k|         }
   64|  1.38k|      }
_ZN3glz4fromILj10EbE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEETkNS_6bool_tERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
  669|  1.38k|      {
  670|       |         if constexpr (check_quoted_num(Opts)) {
  671|       |            if (skip_ws<Opts>(ctx, it, end)) {
  672|       |               return;
  673|       |            }
  674|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  675|       |               return;
  676|       |            }
  677|       |         }
  678|       |
  679|       |         if constexpr (!check_ws_handled(Opts)) {
  680|       |            if (skip_ws<Opts>(ctx, it, end)) {
  681|       |               return;
  682|       |            }
  683|       |         }
  684|       |
  685|       |         if constexpr (check_bools_as_numbers(Opts)) {
  686|       |            if (*it == '1') {
  687|       |               value = true;
  688|       |               ++it;
  689|       |            }
  690|       |            else if (*it == '0') {
  691|       |               value = false;
  692|       |               ++it;
  693|       |            }
  694|       |            else {
  695|       |               ctx.error = error_code::syntax_error;
  696|       |               return;
  697|       |            }
  698|       |         }
  699|  1.38k|         else {
  700|       |            if constexpr (not check_is_padded(Opts)) {
  701|       |               if (size_t(end - it) < 4) [[unlikely]] {
  702|       |                  ctx.error = error_code::expected_true_or_false;
  703|       |                  return;
  704|       |               }
  705|       |            }
  706|       |
  707|  1.38k|            uint32_t c;
  708|  1.38k|            static constexpr uint32_t u_true = 0b01100101'01110101'01110010'01110100;
  709|  1.38k|            static constexpr uint32_t u_fals = 0b01110011'01101100'01100001'01100110;
  710|  1.38k|            std::memcpy(&c, it, 4);
  711|       |            if constexpr (std::endian::native == std::endian::big) {
  712|       |               c = std::byteswap(c);
  713|       |            }
  714|  1.38k|            it += 4;
  715|  1.38k|            if (c == u_true) {
  ------------------
  |  Branch (715:17): [True: 862, False: 525]
  ------------------
  716|    862|               value = true;
  717|    862|            }
  718|    525|            else if (it == end) [[unlikely]] {
  ------------------
  |  Branch (718:22): [True: 25, False: 500]
  ------------------
  719|     25|               ctx.error = error_code::unexpected_end;
  720|     25|               return;
  721|     25|            }
  722|    500|            else {
  723|    500|               if (c == u_fals && (*it == 'e')) [[likely]] {
  ------------------
  |  Branch (723:20): [True: 282, False: 218]
  |  Branch (723:35): [True: 268, False: 14]
  ------------------
  724|    268|                  value = false;
  725|    268|                  ++it;
  726|    268|               }
  727|    232|               else [[unlikely]] {
  728|    232|                  ctx.error = error_code::expected_true_or_false;
  729|    232|                  return;
  730|    232|               }
  731|    500|            }
  732|  1.38k|         }
  733|       |
  734|       |         if constexpr (check_quoted_num(Opts)) {
  735|       |            if constexpr (not Opts.null_terminated) {
  736|       |               if (it == end) [[unlikely]] {
  737|       |                  ctx.error = error_code::unexpected_end;
  738|       |                  return;
  739|       |               }
  740|       |            }
  741|       |            if (match<'"'>(ctx, it)) {
  742|       |               return;
  743|       |            }
  744|       |            if constexpr (not Opts.null_terminated) {
  745|       |               if (it == end) {
  746|       |                  ctx.error = error_code::end_reached;
  747|       |                  return;
  748|       |               }
  749|       |            }
  750|       |         }
  751|  1.38k|         else {
  752|       |            if constexpr (not Opts.null_terminated) {
  753|       |               if (it == end) {
  754|       |                  ctx.error = error_code::end_reached;
  755|       |                  return;
  756|       |               }
  757|       |            }
  758|  1.38k|         }
  759|  1.38k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.13k, False: 257]
  |  Branch (3795:38): [True: 0, False: 257]
  |  Branch (3795:51): [True: 0, False: 257]
  ------------------
 3796|  1.13k|                     return;
 3797|  1.13k|                  }
 3798|    257|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    257|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3794|  1.38k|               for_each<N>([&]<size_t I>() {
 3795|  1.38k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.13k, False: 257]
  |  Branch (3795:38): [True: 0, False: 257]
  |  Branch (3795:51): [True: 0, False: 257]
  ------------------
 3796|  1.13k|                     return;
 3797|  1.13k|                  }
 3798|    257|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|    257|               });
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3725|  1.95M|      {
 3726|  1.95M|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3727|       |
 3728|       |         if constexpr (category_count == 0) {
 3729|       |            ctx.error = error_code::no_matching_variant_type;
 3730|       |         }
 3731|  1.95M|         else {
 3732|  1.95M|            constexpr auto N = std::variant_size_v<Variant>;
 3733|  1.95M|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3734|  1.95M|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3735|       |
 3736|  1.95M|            bool found_match{};
 3737|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3738|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3739|       |            // so the budget stops it and the failure already in hand is reported.
 3740|  1.95M|            bool exhausted{};
 3741|       |
 3742|       |            // First pass: const glaze types in this category
 3743|       |            if constexpr (const_count > 0) {
 3744|       |               for_each<N>([&]<size_t I>() {
 3745|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3746|       |                     return;
 3747|       |                  }
 3748|       |                  using V = std::variant_alternative_t<I, Variant>;
 3749|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3750|       |                     // run time substitute to compare to const value
 3751|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3752|       |                     auto copy_it{it};
 3753|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3754|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3755|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3756|       |                     const auto copy_depth{ctx.depth};
 3757|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3758|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3759|       |                     if (substitute == const_value) {
 3760|       |                        found_match = true;
 3761|       |                        if (!std::holds_alternative<V>(value)) {
 3762|       |                           value = V{};
 3763|       |                        }
 3764|       |                     }
 3765|       |                     else {
 3766|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3767|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3768|       |                           exhausted = true;
 3769|       |                        }
 3770|       |                        if constexpr (not Options.null_terminated) {
 3771|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3772|       |                              ctx.error = error_code::none;
 3773|       |                           }
 3774|       |                        }
 3775|       |                        it = copy_it;
 3776|       |                        rewind_depth<Options>(ctx, copy_depth);
 3777|       |                     }
 3778|       |                  }
 3779|       |               });
 3780|       |               if (found_match) {
 3781|       |                  return;
 3782|       |               }
 3783|       |            }
 3784|       |
 3785|       |            // Second pass: non-const types in this category
 3786|  1.95M|            if constexpr (non_const_count > 0) {
 3787|       |               // Track position within matching types for "is last" check.
 3788|       |               // We iterate over all variant indices but only process matching types,
 3789|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3790|       |               // the loop index directly corresponded to position in filtered set).
 3791|       |               // This has negligible cost: one increment per matching type.
 3792|  1.95M|               size_t non_const_idx = 0;
 3793|       |
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.95M|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  1.95M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  1.95M|                     auto copy_it{it};
 3801|  1.95M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  1.95M|                     if (!std::holds_alternative<V>(value)) {
 3803|  1.95M|                        value = V{};
 3804|  1.95M|                     }
 3805|  1.95M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  1.95M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|  1.95M|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|  1.95M|                     }
 3809|  1.95M|                     if (!bool(ctx.error)) {
 3810|  1.95M|                        found_match = true;
 3811|  1.95M|                     }
 3812|  1.95M|                     else if constexpr (not Options.null_terminated) {
 3813|  1.95M|                        constexpr bool is_complete_type =
 3814|  1.95M|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|  1.95M|                        if constexpr (is_complete_type) {
 3817|  1.95M|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|  1.95M|                              found_match = true;
 3819|  1.95M|                              ctx.error = error_code::none;
 3820|  1.95M|                           }
 3821|  1.95M|                           else {
 3822|  1.95M|                              it = copy_it;
 3823|  1.95M|                              rewind_depth<Options>(ctx, copy_depth);
 3824|  1.95M|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|  1.95M|                                  not variant_alternative_exhausted(ctx)) {
 3826|  1.95M|                                 ctx.error = error_code::none;
 3827|  1.95M|                              }
 3828|  1.95M|                           }
 3829|  1.95M|                        }
 3830|  1.95M|                        else {
 3831|  1.95M|                           it = copy_it;
 3832|  1.95M|                           rewind_depth<Options>(ctx, copy_depth);
 3833|  1.95M|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|  1.95M|                               not variant_alternative_exhausted(ctx)) {
 3835|  1.95M|                              ctx.error = error_code::none;
 3836|  1.95M|                           }
 3837|  1.95M|                        }
 3838|  1.95M|                     }
 3839|  1.95M|                     else {
 3840|  1.95M|                        it = copy_it;
 3841|  1.95M|                        rewind_depth<Options>(ctx, copy_depth);
 3842|  1.95M|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|  1.95M|                            not variant_alternative_exhausted(ctx)) {
 3844|  1.95M|                           ctx.error = error_code::none;
 3845|  1.95M|                        }
 3846|  1.95M|                     }
 3847|  1.95M|                     ++non_const_idx;
 3848|  1.95M|                  }
 3849|  1.95M|               });
 3850|  1.95M|               if (!found_match) {
  ------------------
  |  Branch (3850:20): [True: 1.55k, False: 1.95M]
  ------------------
 3851|  1.55k|                  if constexpr (non_const_count == 1) {
 3852|       |                     // Keep the specific error from the single type we tried
 3853|       |                  }
 3854|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3855|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3856|       |                     ctx.error = error_code::no_matching_variant_type;
 3857|       |                  }
 3858|  1.55k|               }
 3859|       |            }
 3860|       |            else {
 3861|       |               ctx.error = error_code::no_matching_variant_type;
 3862|       |            }
 3863|  1.95M|         }
 3864|  1.95M|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.95M]
  |  Branch (3795:38): [True: 0, False: 1.95M]
  |  Branch (3795:51): [True: 0, False: 1.95M]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.95M|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.95M|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 0, False: 1.95M]
  |  Branch (3795:38): [True: 0, False: 1.95M]
  |  Branch (3795:51): [True: 0, False: 1.95M]
  ------------------
 3796|      0|                     return;
 3797|      0|                  }
 3798|  1.95M|                  using V = std::variant_alternative_t<I, Variant>;
 3799|  1.95M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|  1.95M|                     auto copy_it{it};
 3801|  1.95M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|  1.95M|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3802:26): [True: 1.75M, False: 202k]
  ------------------
 3803|  1.75M|                        value = V{};
 3804|  1.75M|                     }
 3805|  1.95M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|  1.95M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3806:26): [True: 1.55k, False: 1.95M]
  |  Branch (3806:45): [True: 0, False: 1.55k]
  ------------------
 3807|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|      0|                     }
 3809|  1.95M|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3809:26): [True: 1.95M, False: 1.55k]
  ------------------
 3810|  1.95M|                        found_match = true;
 3811|  1.95M|                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|  1.55k|                     else {
 3840|  1.55k|                        it = copy_it;
 3841|  1.55k|                        rewind_depth<Options>(ctx, copy_depth);
 3842|  1.55k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3842:29): [True: 0, False: 1.55k]
  |  Branch (3842:68): [True: 0, False: 0]
  ------------------
 3843|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3843:29): [True: 0, False: 0]
  ------------------
 3844|      0|                           ctx.error = error_code::none;
 3845|      0|                        }
 3846|  1.55k|                     }
 3847|  1.95M|                     ++non_const_idx;
 3848|  1.95M|                  }
 3849|  1.95M|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERdTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  1.95M|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  1.95M|         else {
   60|  1.95M|            using V = std::remove_cvref_t<T>;
   61|  1.95M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  1.95M|                                             end);
   63|  1.95M|         }
   64|  1.95M|      }
_ZN3glz4fromILj10EdE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERPKcRdTkNS_10is_contextERNS_7contextES5_EEvOT1_OT2_OT0_T3_:
  767|  1.95M|      {
  768|       |         if constexpr (check_quoted_num(Opts)) {
  769|       |            if (skip_ws<Opts>(ctx, it, end)) {
  770|       |               return;
  771|       |            }
  772|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  773|       |               return;
  774|       |            }
  775|       |         }
  776|       |
  777|       |         if constexpr (!check_ws_handled(Opts)) {
  778|       |            if (skip_ws<Opts>(ctx, it, end)) {
  779|       |               return;
  780|       |            }
  781|       |         }
  782|       |
  783|  1.95M|         using V = std::decay_t<decltype(value)>;
  784|       |         if constexpr (int_t<V>) {
  785|       |            static_assert(sizeof(*it) == sizeof(char));
  786|       |
  787|       |            if constexpr (Opts.null_terminated) {
  788|       |               if (not glz::atoi(value, it)) [[unlikely]] {
  789|       |                  ctx.error = error_code::parse_number_failure;
  790|       |                  return;
  791|       |               }
  792|       |            }
  793|       |            else {
  794|       |               if (not glz::atoi(value, it, end)) [[unlikely]] {
  795|       |                  ctx.error = error_code::parse_number_failure;
  796|       |                  return;
  797|       |               }
  798|       |            }
  799|       |         }
  800|  1.95M|         else {
  801|       |// float128_t requires std::from_chars for floating-point, unavailable on older Apple platforms (iOS < 16.3)
  802|  1.95M|#if !defined(_LIBCPP_VERSION) || defined(_LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT)
  803|       |            if constexpr (is_float128<V>) {
  804|       |               auto [ptr, ec] = std::from_chars(it, end, value);
  805|       |               if (ec != std::errc()) {
  806|       |                  ctx.error = error_code::parse_number_failure;
  807|       |                  return;
  808|       |               }
  809|       |               it = ptr;
  810|       |            }
  811|       |            else
  812|       |#endif
  813|  1.95M|            {
  814|       |               if constexpr (std::is_volatile_v<std::remove_reference_t<decltype(value)>>) {
  815|       |                  // Hardware may interact with value changes, so we parse into a temporary and assign in one
  816|       |                  // place
  817|       |                  V temp;
  818|       |                  if constexpr (is_size_optimized(Opts)) {
  819|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, temp);
  820|       |                     if (ec != std::errc{}) [[unlikely]] {
  821|       |                        ctx.error = error_code::parse_number_failure;
  822|       |                        return;
  823|       |                     }
  824|       |                     it = ptr;
  825|       |                  }
  826|       |                  else {
  827|       |                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, temp);
  828|       |                     if (ec != std::errc()) [[unlikely]] {
  829|       |                        ctx.error = error_code::parse_number_failure;
  830|       |                        return;
  831|       |                     }
  832|       |                     it = ptr;
  833|       |                  }
  834|       |                  value = temp;
  835|       |               }
  836|  1.95M|               else {
  837|       |                  if constexpr (is_size_optimized(Opts)) {
  838|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, value);
  839|       |                     if (ec != std::errc{}) [[unlikely]] {
  840|       |                        ctx.error = error_code::parse_number_failure;
  841|       |                        return;
  842|       |                     }
  843|       |                     it = ptr;
  844|       |                  }
  845|  1.95M|                  else {
  846|  1.95M|                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, value);
  847|  1.95M|                     if (ec != std::errc()) [[unlikely]] {
  ------------------
  |  Branch (847:26): [True: 1.55k, False: 1.95M]
  ------------------
  848|  1.55k|                        ctx.error = error_code::parse_number_failure;
  849|  1.55k|                        return;
  850|  1.55k|                     }
  851|  1.95M|                     it = ptr;
  852|  1.95M|                  }
  853|  1.95M|               }
  854|  1.95M|            }
  855|  1.95M|         }
  856|       |
  857|       |         if constexpr (check_quoted_num(Opts)) {
  858|       |            if constexpr (not Opts.null_terminated) {
  859|       |               if (it == end) [[unlikely]] {
  860|       |                  ctx.error = error_code::unexpected_end;
  861|       |                  return;
  862|       |               }
  863|       |            }
  864|       |            if (match<'"'>(ctx, it)) {
  865|       |               return;
  866|       |            }
  867|       |            if constexpr (not Opts.null_terminated) {
  868|       |               if (it == end) {
  869|       |                  ctx.error = error_code::end_reached;
  870|       |                  return;
  871|       |               }
  872|       |            }
  873|       |         }
  874|  1.95M|         else {
  875|       |            if constexpr (not Opts.null_terminated) {
  876|       |               if (it == end) {
  877|       |                  ctx.error = error_code::end_reached;
  878|       |                  return;
  879|       |               }
  880|       |            }
  881|  1.95M|         }
  882|  1.95M|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.95M, False: 1.55k]
  |  Branch (3795:38): [True: 0, False: 1.55k]
  |  Branch (3795:51): [True: 0, False: 1.55k]
  ------------------
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.55k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.55k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.95M, False: 1.55k]
  |  Branch (3795:38): [True: 0, False: 1.55k]
  |  Branch (3795:51): [True: 0, False: 1.55k]
  ------------------
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.55k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.55k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.95M, False: 1.55k]
  |  Branch (3795:38): [True: 0, False: 1.55k]
  |  Branch (3795:51): [True: 0, False: 1.55k]
  ------------------
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.55k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.55k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3794|  1.95M|               for_each<N>([&]<size_t I>() {
 3795|  1.95M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3795:23): [True: 1.95M, False: 1.55k]
  |  Branch (3795:38): [True: 0, False: 1.55k]
  |  Branch (3795:51): [True: 0, False: 1.55k]
  ------------------
 3796|  1.95M|                     return;
 3797|  1.95M|                  }
 3798|  1.55k|                  using V = std::variant_alternative_t<I, Variant>;
 3799|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3800|       |                     auto copy_it{it};
 3801|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3802|       |                     if (!std::holds_alternative<V>(value)) {
 3803|       |                        value = V{};
 3804|       |                     }
 3805|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3806|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3807|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3808|       |                     }
 3809|       |                     if (!bool(ctx.error)) {
 3810|       |                        found_match = true;
 3811|       |                     }
 3812|       |                     else if constexpr (not Options.null_terminated) {
 3813|       |                        constexpr bool is_complete_type =
 3814|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3815|       |
 3816|       |                        if constexpr (is_complete_type) {
 3817|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3818|       |                              found_match = true;
 3819|       |                              ctx.error = error_code::none;
 3820|       |                           }
 3821|       |                           else {
 3822|       |                              it = copy_it;
 3823|       |                              rewind_depth<Options>(ctx, copy_depth);
 3824|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3825|       |                                  not variant_alternative_exhausted(ctx)) {
 3826|       |                                 ctx.error = error_code::none;
 3827|       |                              }
 3828|       |                           }
 3829|       |                        }
 3830|       |                        else {
 3831|       |                           it = copy_it;
 3832|       |                           rewind_depth<Options>(ctx, copy_depth);
 3833|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3834|       |                               not variant_alternative_exhausted(ctx)) {
 3835|       |                              ctx.error = error_code::none;
 3836|       |                           }
 3837|       |                        }
 3838|       |                     }
 3839|       |                     else {
 3840|       |                        it = copy_it;
 3841|       |                        rewind_depth<Options>(ctx, copy_depth);
 3842|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3843|       |                            not variant_alternative_exhausted(ctx)) {
 3844|       |                           ctx.error = error_code::none;
 3845|       |                        }
 3846|       |                     }
 3847|       |                     ++non_const_idx;
 3848|       |                  }
 3849|  1.55k|               });

_ZN3glz11countr_zeroEm:
   29|  2.67M|   {
   30|       |#ifdef _MSC_VER
   31|       |      return std::countr_zero(x);
   32|       |#else
   33|  2.67M|#if __has_builtin(__builtin_ctzll)
   34|  2.67M|      return __builtin_ctzll(x);
   35|       |#else
   36|       |      return std::countr_zero(x);
   37|       |#endif
   38|  2.67M|#endif
   39|  2.67M|   }

_ZN3glz10comparitorIL_ZZNS_5matchITnNS_14string_literalEXtlNS2_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS9_Qntcl15check_is_paddedT0_EEEvOT1_OT2_T3_E1SELm4EcEEbPKSB_:
  245|    592|   {
  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|    592|      else if constexpr (N == 4) {
  286|    592|         static constexpr auto packed = pack<Str, 4>();
  287|    592|         uint32_t in;
  288|    592|         std::memcpy(&in, other, 4);
  289|       |         if constexpr (std::endian::native == std::endian::big) {
  290|       |            in = std::byteswap(in);
  291|       |         }
  292|    592|         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|    592|   }
_ZN3glz10comparitorIL_ZZNS_5matchITnNS_14string_literalEXtlNS2_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS9_Qntcl15check_is_paddedT0_EEEvOT1_OT2_T3_E1SELm4EcEEbPKSB_:
  245|    626|   {
  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|    626|      else if constexpr (N == 4) {
  286|    626|         static constexpr auto packed = pack<Str, 4>();
  287|    626|         uint32_t in;
  288|    626|         std::memcpy(&in, other, 4);
  289|       |         if constexpr (std::endian::native == std::endian::big) {
  290|       |            in = std::byteswap(in);
  291|       |         }
  292|    626|         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|    626|   }
_ZN3glz10comparitorIL_ZZNS_5matchITnNS_14string_literalEXtlNS2_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEETkNS_10is_contextERNS_7contextERPKcS9_Qaacl15check_is_paddedT0_ElecldtT_4sizeEL_ZNS_13padding_bytesEEEEvOT1_OT2_T3_E1SELm4EcEEbPKSB_:
  245|    662|   {
  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|    662|      else if constexpr (N == 4) {
  286|    662|         static constexpr auto packed = pack<Str, 4>();
  287|    662|         uint32_t in;
  288|    662|         std::memcpy(&in, other, 4);
  289|       |         if constexpr (std::endian::native == std::endian::big) {
  290|       |            in = std::byteswap(in);
  291|       |         }
  292|    662|         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|    662|   }

_ZN3glz10fast_float4spanIKcEC2Ev:
  438|  11.7M|  constexpr span() : ptr(nullptr), length(0) {}
_ZN3glz10fast_float10is_integerIcEEbT_:
 1481|  13.1k|fastfloat_really_inline constexpr bool is_integer(UC c) noexcept {
 1482|  13.1k|  return !(c > UC('9') || c < UC('0'));
  ------------------
  |  Branch (1482:12): [True: 6, False: 13.1k]
  |  Branch (1482:27): [True: 66, False: 13.0k]
  ------------------
 1483|  13.1k|}
_ZN3glz10fast_float11digit_valueIcEEmT_:
 1489|  35.6M|fastfloat_really_inline constexpr uint64_t digit_value(UC c) noexcept {
 1490|  35.6M|  return uint64_t(uint8_t(c) - uint8_t('0'));
 1491|  35.6M|}
_ZN3glz10fast_float4spanIKcEC2EPS2_m:
  436|  5.90M|  constexpr span(T const *_ptr, size_t _length) : ptr(_ptr), length(_length) {}
_ZN3glz10fast_float26loop_parse_if_eight_digitsERPKcS2_Rm:
 1679|  47.1k|                           uint64_t &i) {
 1680|       |  // optimizes better than parse_if_eight_digits_unrolled() for UC = char.
 1681|  3.13M|  while ((std::distance(p, pend) >= 8) &&
  ------------------
  |  Branch (1681:10): [True: 3.13M, False: 3.08k]
  ------------------
 1682|  3.13M|         is_made_of_eight_digits_fast(read8_to_u64(p))) {
  ------------------
  |  Branch (1682:10): [True: 3.09M, False: 44.0k]
  ------------------
 1683|  3.09M|    i = i * 100000000 +
 1684|  3.09M|        parse_eight_digits_unrolled(read8_to_u64(
 1685|  3.09M|            p)); // in rare cases, this will overflow, but that's ok
 1686|  3.09M|    p += 8;
 1687|  3.09M|  }
 1688|  47.1k|}
_ZN3glz10fast_float28is_made_of_eight_digits_fastEm:
 1597|  3.13M|is_made_of_eight_digits_fast(uint64_t val) noexcept {
 1598|  3.13M|  return !((((val + 0x4646464646464646) | (val - 0x3030303030303030)) &
 1599|  3.13M|            0x8080808080808080));
 1600|  3.13M|}
_ZN3glz10fast_float12read8_to_u64IcEEmPKT_:
 1503|  8.15M|read8_to_u64(UC const *chars) {
 1504|  8.15M|  if (cpp20_and_in_constexpr() || !std::is_same<UC, char>::value) {
  ------------------
  |  Branch (1504:7): [Folded, False: 0]
  |  Branch (1504:35): [Folded, False: 0]
  ------------------
 1505|      0|    uint64_t val = 0;
 1506|      0|    for (int i = 0; i < 8; ++i) {
  ------------------
  |  Branch (1506:21): [True: 0, False: 0]
  ------------------
 1507|      0|      val |= uint64_t(uint8_t(*chars)) << (i * 8);
 1508|      0|      ++chars;
 1509|      0|    }
 1510|      0|    return val;
 1511|      0|  }
 1512|  8.15M|  uint64_t val;
 1513|  8.15M|  ::memcpy(&val, chars, sizeof(uint64_t));
 1514|       |#if GLZ_FASTFLOAT_IS_BIG_ENDIAN == 1
 1515|       |  // Need to read as-if the number was in little-endian order.
 1516|       |  val = byteswap(val);
 1517|       |#endif
 1518|  8.15M|  return val;
 1519|  8.15M|}
_ZN3glz10fast_float27parse_eight_digits_unrolledEm:
 1575|  5.01M|parse_eight_digits_unrolled(uint64_t val) {
 1576|  5.01M|  uint64_t const mask = 0x000000FF000000FF;
 1577|  5.01M|  uint64_t const mul1 = 0x000F424000000064; // 100 + (1000000ULL << 32)
 1578|  5.01M|  uint64_t const mul2 = 0x0000271000000001; // 1 + (10000ULL << 32)
 1579|  5.01M|  val -= 0x3030303030303030;
 1580|  5.01M|  val = (val * 10) + (val >> 8); // val = (val * 2561) >> 8;
 1581|  5.01M|  val = (((val & mask) * mul1) + (((val >> 16) & mask) * mul2)) >> 32;
 1582|  5.01M|  return uint32_t(val);
 1583|  5.01M|}
_ZNK3glz10fast_float4spanIKcE3lenEv:
  440|   188k|  constexpr size_t len() const noexcept { return length; }
_ZN3glz10fast_float19from_chars_advancedIdcEENS0_19from_chars_result_tIT0_EERNS0_22parsed_number_string_tIS3_EERT_:
 4249|  5.85M|from_chars_advanced(parsed_number_string_t<UC> &pns, T &value) noexcept {
 4250|       |
 4251|  5.85M|  static_assert(is_supported_float_type<T>::value,
 4252|  5.85M|                "only some floating-point types are supported");
 4253|  5.85M|  static_assert(is_supported_char_type<UC>::value,
 4254|  5.85M|                "only char, wchar_t, char16_t and char32_t are supported");
 4255|       |
 4256|  5.85M|  from_chars_result_t<UC> answer;
 4257|       |
 4258|  5.85M|  answer.ec = std::errc(); // be optimistic
 4259|  5.85M|  answer.ptr = pns.lastmatch;
 4260|       |  // The implementation of the Clinger's fast path is convoluted because
 4261|       |  // we want round-to-nearest in all cases, irrespective of the rounding mode
 4262|       |  // selected on the thread.
 4263|       |  // We proceed optimistically, assuming that detail::rounds_to_nearest()
 4264|       |  // returns true.
 4265|  5.85M|  if (binary_format<T>::min_exponent_fast_path() <= pns.exponent &&
  ------------------
  |  Branch (4265:7): [True: 5.84M, False: 12.3k]
  ------------------
 4266|  5.84M|      pns.exponent <= binary_format<T>::max_exponent_fast_path() &&
  ------------------
  |  Branch (4266:7): [True: 5.81M, False: 34.0k]
  ------------------
 4267|  5.81M|      !pns.too_many_digits) {
  ------------------
  |  Branch (4267:7): [True: 5.77M, False: 37.7k]
  ------------------
 4268|       |    // Unfortunately, the conventional Clinger's fast path is only possible
 4269|       |    // when the system rounds to the nearest float.
 4270|       |    //
 4271|       |    // We expect the next branch to almost always be selected.
 4272|       |    // We could check it first (before the previous branch), but
 4273|       |    // there might be performance advantages at having the check
 4274|       |    // be last.
 4275|  5.77M|    if (!cpp20_and_in_constexpr() && detail::rounds_to_nearest()) {
  ------------------
  |  Branch (4275:9): [True: 5.77M, Folded]
  |  Branch (4275:38): [True: 5.77M, False: 0]
  ------------------
 4276|       |      // We have that fegetround() == FE_TONEAREST.
 4277|       |      // Next is Clinger's fast path.
 4278|  5.77M|      if (pns.mantissa <= binary_format<T>::max_mantissa_fast_path()) {
  ------------------
  |  Branch (4278:11): [True: 5.77M, False: 3.24k]
  ------------------
 4279|  5.77M|        value = T(pns.mantissa);
 4280|  5.77M|        if (pns.exponent < 0) {
  ------------------
  |  Branch (4280:13): [True: 5.97k, False: 5.76M]
  ------------------
 4281|  5.97k|          value = value / binary_format<T>::exact_power_of_ten(-pns.exponent);
 4282|  5.76M|        } else {
 4283|  5.76M|          value = value * binary_format<T>::exact_power_of_ten(pns.exponent);
 4284|  5.76M|        }
 4285|  5.77M|        if (pns.negative) {
  ------------------
  |  Branch (4285:13): [True: 9.19k, False: 5.76M]
  ------------------
 4286|  9.19k|          value = -value;
 4287|  9.19k|        }
 4288|  5.77M|        return answer;
 4289|  5.77M|      }
 4290|  5.77M|    } else {
 4291|       |      // We do not have that fegetround() == FE_TONEAREST.
 4292|       |      // Next is a modified Clinger's fast path, inspired by Jakub Jelínek's
 4293|       |      // proposal
 4294|      0|      if (pns.exponent >= 0 &&
  ------------------
  |  Branch (4294:11): [True: 0, False: 0]
  ------------------
 4295|      0|          pns.mantissa <=
  ------------------
  |  Branch (4295:11): [True: 0, False: 0]
  ------------------
 4296|      0|              binary_format<T>::max_mantissa_fast_path(pns.exponent)) {
 4297|      0|#if defined(__clang__) || defined(GLZ_FASTFLOAT_32BIT)
 4298|       |        // Clang may map 0 to -0.0 when fegetround() == FE_DOWNWARD
 4299|      0|        if (pns.mantissa == 0) {
  ------------------
  |  Branch (4299:13): [True: 0, False: 0]
  ------------------
 4300|      0|          value = pns.negative ? T(-0.) : T(0.);
  ------------------
  |  Branch (4300:19): [True: 0, False: 0]
  ------------------
 4301|      0|          return answer;
 4302|      0|        }
 4303|      0|#endif
 4304|      0|        value = T(pns.mantissa) *
 4305|      0|                binary_format<T>::exact_power_of_ten(pns.exponent);
 4306|      0|        if (pns.negative) {
  ------------------
  |  Branch (4306:13): [True: 0, False: 0]
  ------------------
 4307|      0|          value = -value;
 4308|      0|        }
 4309|      0|        return answer;
 4310|      0|      }
 4311|      0|    }
 4312|  5.77M|  }
 4313|  87.4k|  adjusted_mantissa am =
 4314|  87.4k|      compute_float<binary_format<T>>(pns.exponent, pns.mantissa);
 4315|  87.4k|  if (pns.too_many_digits && am.power2 >= 0) {
  ------------------
  |  Branch (4315:7): [True: 70.0k, False: 17.3k]
  |  Branch (4315:30): [True: 70.0k, False: 0]
  ------------------
 4316|  70.0k|    if (am != compute_float<binary_format<T>>(pns.exponent, pns.mantissa + 1)) {
  ------------------
  |  Branch (4316:9): [True: 59.3k, False: 10.7k]
  ------------------
 4317|  59.3k|      am = compute_error<binary_format<T>>(pns.exponent, pns.mantissa);
 4318|  59.3k|    }
 4319|  70.0k|  }
 4320|       |  // If we called compute_float<binary_format<T>>(pns.exponent, pns.mantissa)
 4321|       |  // and we have an invalid power (am.power2 < 0), then we need to go the long
 4322|       |  // way around again. This is very uncommon.
 4323|  87.4k|  if (am.power2 < 0) {
  ------------------
  |  Branch (4323:7): [True: 59.3k, False: 28.0k]
  ------------------
 4324|  59.3k|    am = digit_comp<T>(pns, am);
 4325|  59.3k|  }
 4326|  87.4k|  to_float(pns.negative, am, value);
 4327|       |  // Test for over/underflow.
 4328|  87.4k|  if ((pns.mantissa != 0 && am.mantissa == 0 && am.power2 == 0) ||
  ------------------
  |  Branch (4328:8): [True: 85.5k, False: 1.87k]
  |  Branch (4328:29): [True: 7.44k, False: 78.0k]
  |  Branch (4328:49): [True: 270, False: 7.17k]
  ------------------
 4329|  87.1k|      am.power2 == binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (4329:7): [True: 381, False: 86.7k]
  ------------------
 4330|    651|    answer.ec = std::errc::result_out_of_range;
 4331|    651|  }
 4332|  87.4k|  return answer;
 4333|  5.85M|}
_ZN3glz10fast_float13binary_formatIdE22min_exponent_fast_pathEv:
  695|  5.85M|inline constexpr int binary_format<double>::min_exponent_fast_path() {
  696|       |#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
  697|       |  return 0;
  698|       |#else
  699|  5.85M|  return -22;
  700|  5.85M|#endif
  701|  5.85M|}
_ZN3glz10fast_float13binary_formatIdE22max_exponent_fast_pathEv:
  767|  5.84M|inline constexpr int binary_format<double>::max_exponent_fast_path() {
  768|  5.84M|  return 22;
  769|  5.84M|}
_ZN3glz10fast_float6detail17rounds_to_nearestEv:
 4129|  5.77M|fastfloat_really_inline bool rounds_to_nearest() noexcept {
 4130|       |  // https://lemire.me/blog/2020/06/26/gcc-not-nearest/
 4131|       |#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
 4132|       |  return false;
 4133|       |#endif
 4134|       |  // See
 4135|       |  // A fast function to check your floating-point rounding mode
 4136|       |  // https://lemire.me/blog/2022/11/16/a-fast-function-to-check-your-floating-point-rounding-mode/
 4137|       |  //
 4138|       |  // This function is meant to be equivalent to :
 4139|       |  // prior: #include <cfenv>
 4140|       |  //  return fegetround() == FE_TONEAREST;
 4141|       |  // However, it is expected to be much faster than the fegetround()
 4142|       |  // function call.
 4143|       |  //
 4144|       |  // The volatile keyword prevents the compiler from computing the function
 4145|       |  // at compile-time.
 4146|       |  // There might be other ways to prevent compile-time optimizations (e.g.,
 4147|       |  // asm). The value does not need to be std::numeric_limits<float>::min(), any
 4148|       |  // small value so that 1 + x should round to 1 would do (after accounting for
 4149|       |  // excess precision, as in 387 instructions).
 4150|  5.77M|  static float volatile fmin = (std::numeric_limits<float>::min)();
 4151|  5.77M|  float fmini = fmin; // we copy it so that it gets loaded at most once.
 4152|       |//
 4153|       |// Explanation:
 4154|       |// Only when fegetround() == FE_TONEAREST do we have that
 4155|       |// fmin + 1.0f == 1.0f - fmin.
 4156|       |//
 4157|       |// FE_UPWARD:
 4158|       |//  fmin + 1.0f > 1
 4159|       |//  1.0f - fmin == 1
 4160|       |//
 4161|       |// FE_DOWNWARD or  FE_TOWARDZERO:
 4162|       |//  fmin + 1.0f == 1
 4163|       |//  1.0f - fmin < 1
 4164|       |//
 4165|       |// Note: This may fail to be accurate if fast-math has been
 4166|       |// enabled, as rounding conventions may not apply.
 4167|       |#ifdef GLZ_FASTFLOAT_VISUAL_STUDIO
 4168|       |#pragma warning(push)
 4169|       |//  todo: is there a VS warning?
 4170|       |//  see
 4171|       |//  https://stackoverflow.com/questions/46079446/is-there-a-warning-for-floating-point-equality-checking-in-visual-studio-2013
 4172|       |#elif defined(__clang__)
 4173|       |#pragma clang diagnostic push
 4174|  5.77M|#pragma clang diagnostic ignored "-Wfloat-equal"
 4175|       |#elif defined(__GNUC__)
 4176|       |#pragma GCC diagnostic push
 4177|       |#pragma GCC diagnostic ignored "-Wfloat-equal"
 4178|       |#endif
 4179|  5.77M|  return (fmini + 1.0f == 1.0f - fmini);
 4180|       |#ifdef GLZ_FASTFLOAT_VISUAL_STUDIO
 4181|       |#pragma warning(pop)
 4182|       |#elif defined(__clang__)
 4183|       |#pragma clang diagnostic pop
 4184|       |#elif defined(__GNUC__)
 4185|       |#pragma GCC diagnostic pop
 4186|       |#endif
 4187|  5.77M|}
_ZN3glz10fast_float13binary_formatIdE22max_mantissa_fast_pathEv:
  777|  5.77M|inline constexpr uint64_t binary_format<double>::max_mantissa_fast_path() {
  778|  5.77M|  return uint64_t(2) << mantissa_explicit_bits();
  779|  5.77M|}
_ZN3glz10fast_float13binary_formatIdE22mantissa_explicit_bitsEv:
  713|  6.81M|inline constexpr int binary_format<double>::mantissa_explicit_bits() {
  714|  6.81M|  return 52;
  715|  6.81M|}
_ZN3glz10fast_float13binary_formatIdE18exact_power_of_tenEl:
 1057|  5.77M|binary_format<double>::exact_power_of_ten(int64_t power) {
 1058|       |  // Work around clang bug https://godbolt.org/z/zedh7rrhc
 1059|  5.77M|  return (void)powers_of_ten[0], powers_of_ten[power];
 1060|  5.77M|}
_ZN3glz10fast_float13compute_floatINS0_13binary_formatIdEEEENS0_17adjusted_mantissaElm:
 2852|   157k|compute_float(int64_t q, uint64_t w) noexcept {
 2853|   157k|  adjusted_mantissa answer;
 2854|   157k|  if ((w == 0) || (q < binary::smallest_power_of_ten())) {
  ------------------
  |  Branch (2854:7): [True: 1.87k, False: 155k]
  |  Branch (2854:19): [True: 312, False: 155k]
  ------------------
 2855|  2.19k|    answer.power2 = 0;
 2856|  2.19k|    answer.mantissa = 0;
 2857|       |    // result should be zero
 2858|  2.19k|    return answer;
 2859|  2.19k|  }
 2860|   155k|  if (q > binary::largest_power_of_ten()) {
  ------------------
  |  Branch (2860:7): [True: 450, False: 154k]
  ------------------
 2861|       |    // we want to get infinity:
 2862|    450|    answer.power2 = binary::infinite_power();
 2863|    450|    answer.mantissa = 0;
 2864|    450|    return answer;
 2865|    450|  }
 2866|       |  // At this point in time q is in [powers::smallest_power_of_five,
 2867|       |  // powers::largest_power_of_five].
 2868|       |
 2869|       |  // We want the most significant bit of i to be 1. Shift if needed.
 2870|   154k|  int lz = leading_zeroes(w);
 2871|   154k|  w <<= lz;
 2872|       |
 2873|       |  // The required precision is binary::mantissa_explicit_bits() + 3 because
 2874|       |  // 1. We need the implicit bit
 2875|       |  // 2. We need an extra bit for rounding purposes
 2876|       |  // 3. We might lose a bit due to the "upperbit" routine (result too small,
 2877|       |  // requiring a shift)
 2878|       |
 2879|   154k|  value128 product =
 2880|   154k|      compute_product_approximation<binary::mantissa_explicit_bits() + 3>(q, w);
 2881|       |  // The computed 'product' is always sufficient.
 2882|       |  // Mathematical proof:
 2883|       |  // Noble Mushtak and Daniel Lemire, Fast Number Parsing Without Fallback (to
 2884|       |  // appear) See script/mushtak_lemire.py
 2885|       |
 2886|       |  // The "compute_product_approximation" function can be slightly slower than a
 2887|       |  // branchless approach: value128 product = compute_product(q, w); but in
 2888|       |  // practice, we can win big with the compute_product_approximation if its
 2889|       |  // additional branch is easily predicted. Which is best is data specific.
 2890|   154k|  int upperbit = int(product.high >> 63);
 2891|   154k|  int shift = upperbit + 64 - binary::mantissa_explicit_bits() - 3;
 2892|       |
 2893|   154k|  answer.mantissa = product.high >> shift;
 2894|       |
 2895|   154k|  answer.power2 = int32_t(detail::power(int32_t(q)) + upperbit - lz -
 2896|   154k|                          binary::minimum_exponent());
 2897|   154k|  if (answer.power2 <= 0) { // we have a subnormal?
  ------------------
  |  Branch (2897:7): [True: 11.1k, False: 143k]
  ------------------
 2898|       |    // Here have that answer.power2 <= 0 so -answer.power2 >= 0
 2899|  11.1k|    if (-answer.power2 + 1 >=
  ------------------
  |  Branch (2899:9): [True: 9, False: 11.1k]
  ------------------
 2900|  11.1k|        64) { // if we have more than 64 bits below the minimum exponent, you
 2901|       |              // have a zero for sure.
 2902|      9|      answer.power2 = 0;
 2903|      9|      answer.mantissa = 0;
 2904|       |      // result should be zero
 2905|      9|      return answer;
 2906|      9|    }
 2907|       |    // next line is safe because -answer.power2 + 1 < 64
 2908|  11.1k|    answer.mantissa >>= -answer.power2 + 1;
 2909|       |    // Thankfully, we can't have both "round-to-even" and subnormals because
 2910|       |    // "round-to-even" only occurs for powers close to 0 in the 32-bit and
 2911|       |    // and 64-bit case (with no more than 19 digits).
 2912|  11.1k|    answer.mantissa += (answer.mantissa & 1); // round up
 2913|  11.1k|    answer.mantissa >>= 1;
 2914|       |    // There is a weird scenario where we don't have a subnormal but just.
 2915|       |    // Suppose we start with 2.2250738585072013e-308, we end up
 2916|       |    // with 0x3fffffffffffff x 2^-1023-53 which is technically subnormal
 2917|       |    // whereas 0x40000000000000 x 2^-1023-53  is normal. Now, we need to round
 2918|       |    // up 0x3fffffffffffff x 2^-1023-53  and once we do, we are no longer
 2919|       |    // subnormal, but we can only know this after rounding.
 2920|       |    // So we only declare a subnormal if we are smaller than the threshold.
 2921|  11.1k|    answer.power2 =
 2922|  11.1k|        (answer.mantissa < (uint64_t(1) << binary::mantissa_explicit_bits()))
  ------------------
  |  Branch (2922:9): [True: 11.1k, False: 9]
  ------------------
 2923|  11.1k|            ? 0
 2924|  11.1k|            : 1;
 2925|  11.1k|    return answer;
 2926|  11.1k|  }
 2927|       |
 2928|       |  // usually, we round *up*, but if we fall right in between and and we have an
 2929|       |  // even basis, we need to round down
 2930|       |  // We are only concerned with the cases where 5**q fits in single 64-bit word.
 2931|   143k|  if ((product.low <= 1) && (q >= binary::min_exponent_round_to_even()) &&
  ------------------
  |  Branch (2931:7): [True: 34.2k, False: 109k]
  |  Branch (2931:29): [True: 31.4k, False: 2.79k]
  ------------------
 2932|  31.4k|      (q <= binary::max_exponent_round_to_even()) &&
  ------------------
  |  Branch (2932:7): [True: 29.0k, False: 2.42k]
  ------------------
 2933|  29.0k|      ((answer.mantissa & 3) == 1)) { // we may fall between two floats!
  ------------------
  |  Branch (2933:7): [True: 15.2k, False: 13.8k]
  ------------------
 2934|       |    // To be in-between two floats we need that in doing
 2935|       |    //   answer.mantissa = product.high >> (upperbit + 64 -
 2936|       |    //   binary::mantissa_explicit_bits() - 3);
 2937|       |    // ... we dropped out only zeroes. But if this happened, then we can go
 2938|       |    // back!!!
 2939|  15.2k|    if ((answer.mantissa << shift) == product.high) {
  ------------------
  |  Branch (2939:9): [True: 11.1k, False: 4.08k]
  ------------------
 2940|  11.1k|      answer.mantissa &= ~uint64_t(1); // flip it so that we do not round up
 2941|  11.1k|    }
 2942|  15.2k|  }
 2943|       |
 2944|   143k|  answer.mantissa += (answer.mantissa & 1); // round up
 2945|   143k|  answer.mantissa >>= 1;
 2946|   143k|  if (answer.mantissa >= (uint64_t(2) << binary::mantissa_explicit_bits())) {
  ------------------
  |  Branch (2946:7): [True: 6.72k, False: 136k]
  ------------------
 2947|  6.72k|    answer.mantissa = (uint64_t(1) << binary::mantissa_explicit_bits());
 2948|  6.72k|    answer.power2++; // undo previous addition
 2949|  6.72k|  }
 2950|       |
 2951|   143k|  answer.mantissa &= ~(uint64_t(1) << binary::mantissa_explicit_bits());
 2952|   143k|  if (answer.power2 >= binary::infinite_power()) { // infinity
  ------------------
  |  Branch (2952:7): [True: 45, False: 143k]
  ------------------
 2953|     45|    answer.power2 = binary::infinite_power();
 2954|     45|    answer.mantissa = 0;
 2955|     45|  }
 2956|   143k|  return answer;
 2957|   154k|}
_ZN3glz10fast_float17adjusted_mantissaC2Ev:
  568|   276k|  adjusted_mantissa() = default;
_ZN3glz10fast_float13binary_formatIdE21smallest_power_of_tenEv:
 1077|   155k|inline constexpr int binary_format<double>::smallest_power_of_ten() {
 1078|   155k|  return -342;
 1079|   155k|}
_ZN3glz10fast_float13binary_formatIdE20largest_power_of_tenEv:
 1068|   155k|template <> inline constexpr int binary_format<double>::largest_power_of_ten() {
 1069|   155k|  return 308;
 1070|   155k|}
_ZN3glz10fast_float14leading_zeroesEm:
  488|   249k|leading_zeroes(uint64_t input_num) {
  489|   249k|  assert(input_num > 0);
  ------------------
  |  Branch (489:3): [True: 249k, False: 0]
  ------------------
  490|   249k|  if (cpp20_and_in_constexpr()) {
  ------------------
  |  Branch (490:7): [Folded, False: 249k]
  ------------------
  491|      0|    return leading_zeroes_generic(input_num);
  492|      0|  }
  493|       |#ifdef GLZ_FASTFLOAT_VISUAL_STUDIO
  494|       |#if defined(_M_X64) || defined(_M_ARM64)
  495|       |  unsigned long leading_zero = 0;
  496|       |  // Search the mask data from most significant bit (MSB)
  497|       |  // to least significant bit (LSB) for a set bit (1).
  498|       |  _BitScanReverse64(&leading_zero, input_num);
  499|       |  return (int)(63 - leading_zero);
  500|       |#else
  501|       |  return leading_zeroes_generic(input_num);
  502|       |#endif
  503|       |#else
  504|   249k|  return __builtin_clzll(input_num);
  505|   249k|#endif
  506|   249k|}
_ZN3glz10fast_float29compute_product_approximationILi55EEENS0_8value128Elm:
 2771|   214k|compute_product_approximation(int64_t q, uint64_t w) {
 2772|   214k|  int const index = 2 * int(q - powers::smallest_power_of_five);
 2773|       |  // For small values of q, e.g., q in [0,27], the answer is always exact
 2774|       |  // because The line value128 firstproduct = full_multiplication(w,
 2775|       |  // power_of_five_128[index]); gives the exact answer.
 2776|   214k|  value128 firstproduct =
 2777|   214k|      full_multiplication(w, powers::power_of_five_128[index]);
 2778|   214k|  static_assert((bit_precision >= 0) && (bit_precision <= 64),
 2779|   214k|                " precision should  be in (0,64]");
 2780|   214k|  constexpr uint64_t precision_mask =
 2781|   214k|      (bit_precision < 64) ? (uint64_t(0xFFFFFFFFFFFFFFFF) >> bit_precision)
  ------------------
  |  Branch (2781:7): [True: 0, Folded]
  ------------------
 2782|   214k|                           : uint64_t(0xFFFFFFFFFFFFFFFF);
 2783|   214k|  if ((firstproduct.high & precision_mask) ==
  ------------------
  |  Branch (2783:7): [True: 48.3k, False: 165k]
  ------------------
 2784|   214k|      precision_mask) { // could further guard with  (lower + w < lower)
 2785|       |    // regarding the second product, we only need secondproduct.high, but our
 2786|       |    // expectation is that the compiler will optimize this extra work away if
 2787|       |    // needed.
 2788|  48.3k|    value128 secondproduct =
 2789|  48.3k|        full_multiplication(w, powers::power_of_five_128[index + 1]);
 2790|  48.3k|    firstproduct.low += secondproduct.high;
 2791|  48.3k|    if (secondproduct.high > firstproduct.low) {
  ------------------
  |  Branch (2791:9): [True: 12.2k, False: 36.1k]
  ------------------
 2792|  12.2k|      firstproduct.high++;
 2793|  12.2k|    }
 2794|  48.3k|  }
 2795|   214k|  return firstproduct;
 2796|   214k|}
_ZN3glz10fast_float19full_multiplicationEmm:
  540|   262k|full_multiplication(uint64_t a, uint64_t b) {
  541|   262k|  if (cpp20_and_in_constexpr()) {
  ------------------
  |  Branch (541:7): [Folded, False: 262k]
  ------------------
  542|      0|    value128 answer;
  543|      0|    answer.low = umul128_generic(a, b, &answer.high);
  544|      0|    return answer;
  545|      0|  }
  546|   262k|  value128 answer;
  547|       |#if defined(_M_ARM64) && !defined(__MINGW32__)
  548|       |  // ARM64 has native support for 64-bit multiplications, no need to emulate
  549|       |  // But MinGW on ARM64 doesn't have native support for 64-bit multiplications
  550|       |  answer.high = __umulh(a, b);
  551|       |  answer.low = a * b;
  552|       |#elif defined(GLZ_FASTFLOAT_32BIT) ||                                              \
  553|       |    (defined(_WIN64) && !defined(__clang__) && !defined(_M_ARM64))
  554|       |  answer.low = _umul128(a, b, &answer.high); // _umul128 not available on ARM64
  555|       |#elif defined(GLZ_FASTFLOAT_64BIT) && defined(__SIZEOF_INT128__)
  556|       |  __uint128_t r = ((__uint128_t)a) * b;
  557|   262k|  answer.low = uint64_t(r);
  558|   262k|  answer.high = uint64_t(r >> 64);
  559|       |#else
  560|       |  answer.low = umul128_generic(a, b, &answer.high);
  561|       |#endif
  562|   262k|  return answer;
  563|   262k|}
_ZN3glz10fast_float8value128C2Ev:
  454|   262k|  constexpr value128() : low(0), high(0) {}
_ZN3glz10fast_float6detail5powerEi:
 2814|   214k|constexpr fastfloat_really_inline int32_t power(int32_t q) noexcept {
 2815|   214k|  return (((152170 + 65536) * q) >> 16) + 63;
 2816|   214k|}
_ZN3glz10fast_float13binary_formatIdE16minimum_exponentEv:
  742|   273k|template <> inline constexpr int binary_format<double>::minimum_exponent() {
  743|   273k|  return -1023;
  744|   273k|}
_ZN3glz10fast_float13binary_formatIdE26min_exponent_round_to_evenEv:
  733|  34.2k|inline constexpr int binary_format<double>::min_exponent_round_to_even() {
  734|  34.2k|  return -4;
  735|  34.2k|}
_ZN3glz10fast_float13binary_formatIdE26max_exponent_round_to_evenEv:
  723|  31.4k|inline constexpr int binary_format<double>::max_exponent_round_to_even() {
  724|  31.4k|  return 23;
  725|  31.4k|}
_ZNK3glz10fast_float17adjusted_mantissaneERKS1_:
  574|  70.0k|  constexpr bool operator!=(adjusted_mantissa const &o) const {
  575|  70.0k|    return mantissa != o.mantissa || power2 != o.power2;
  ------------------
  |  Branch (575:12): [True: 59.3k, False: 10.7k]
  |  Branch (575:38): [True: 0, False: 10.7k]
  ------------------
  576|  70.0k|  }
_ZN3glz10fast_float13compute_errorINS0_13binary_formatIdEEEENS0_17adjusted_mantissaElm:
 2837|  59.3k|compute_error(int64_t q, uint64_t w) noexcept {
 2838|  59.3k|  int lz = leading_zeroes(w);
 2839|  59.3k|  w <<= lz;
 2840|  59.3k|  value128 product =
 2841|  59.3k|      compute_product_approximation<binary::mantissa_explicit_bits() + 3>(q, w);
 2842|  59.3k|  return compute_error_scaled<binary>(q, product.high, lz);
 2843|  59.3k|}
_ZN3glz10fast_float20compute_error_scaledINS0_13binary_formatIdEEEENS0_17adjusted_mantissaElmi:
 2823|  59.3k|compute_error_scaled(int64_t q, uint64_t w, int lz) noexcept {
 2824|  59.3k|  int hilz = int(w >> 63) ^ 1;
 2825|  59.3k|  adjusted_mantissa answer;
 2826|  59.3k|  answer.mantissa = w << hilz;
 2827|  59.3k|  int bias = binary::mantissa_explicit_bits() - binary::minimum_exponent();
 2828|  59.3k|  answer.power2 = int32_t(detail::power(int32_t(q)) + bias - hilz - lz - 62 +
 2829|  59.3k|                          invalid_am_bias);
 2830|  59.3k|  return answer;
 2831|  59.3k|}
_ZN3glz10fast_float10digit_compIdcEENS0_17adjusted_mantissaERNS0_22parsed_number_string_tIT0_EES2_:
 4034|  59.3k|digit_comp(parsed_number_string_t<UC> &num, adjusted_mantissa am) noexcept {
 4035|       |  // remove the invalid exponent bias
 4036|  59.3k|  am.power2 -= invalid_am_bias;
 4037|       |
 4038|  59.3k|  int32_t sci_exp = scientific_exponent(num);
 4039|  59.3k|  size_t max_digits = binary_format<T>::max_digits();
 4040|  59.3k|  size_t digits = 0;
 4041|  59.3k|  bigint bigmant;
 4042|  59.3k|  parse_mantissa(bigmant, num, max_digits, digits);
 4043|       |  // can't underflow, since digits is at most max_digits.
 4044|  59.3k|  int32_t exponent = sci_exp + 1 - int32_t(digits);
 4045|  59.3k|  if (exponent >= 0) {
  ------------------
  |  Branch (4045:7): [True: 17.7k, False: 41.5k]
  ------------------
 4046|  17.7k|    return positive_digit_comp<T>(bigmant, exponent);
 4047|  41.5k|  } else {
 4048|  41.5k|    return negative_digit_comp<T>(bigmant, am, exponent);
 4049|  41.5k|  }
 4050|  59.3k|}
_ZN3glz10fast_float19scientific_exponentIcEEiRNS0_22parsed_number_string_tIT_EE:
 3640|  59.3k|scientific_exponent(parsed_number_string_t<UC> &num) noexcept {
 3641|  59.3k|  uint64_t mantissa = num.mantissa;
 3642|  59.3k|  int32_t exponent = int32_t(num.exponent);
 3643|   296k|  while (mantissa >= 10000) {
  ------------------
  |  Branch (3643:10): [True: 237k, False: 59.3k]
  ------------------
 3644|   237k|    mantissa /= 10000;
 3645|   237k|    exponent += 4;
 3646|   237k|  }
 3647|   118k|  while (mantissa >= 100) {
  ------------------
  |  Branch (3647:10): [True: 59.3k, False: 59.3k]
  ------------------
 3648|  59.3k|    mantissa /= 100;
 3649|  59.3k|    exponent += 2;
 3650|  59.3k|  }
 3651|  59.3k|  while (mantissa >= 10) {
  ------------------
  |  Branch (3651:10): [True: 0, False: 59.3k]
  ------------------
 3652|      0|    mantissa /= 10;
 3653|      0|    exponent += 1;
 3654|      0|  }
 3655|  59.3k|  return exponent;
 3656|  59.3k|}
_ZN3glz10fast_float13binary_formatIdE10max_digitsEv:
 1085|  59.3k|template <> inline constexpr size_t binary_format<double>::max_digits() {
 1086|  59.3k|  return 769;
 1087|  59.3k|}
_ZN3glz10fast_float6bigintC2Ev:
 3399|  59.3k|  GLZ_FASTFLOAT_CONSTEXPR20 bigint() : vec() {}
_ZN3glz10fast_float8stackvecILt62EEC2Ev:
 3006|   592k|  stackvec() = default;
_ZN3glz10fast_float14parse_mantissaIcEEvRNS0_6bigintERNS0_22parsed_number_string_tIT_EEmRm:
 3859|  59.3k|               size_t max_digits, size_t &digits) noexcept {
 3860|       |  // try to minimize the number of big integer and scalar multiplication.
 3861|       |  // therefore, try to parse 8 digits at a time, and multiply by the largest
 3862|       |  // scalar value (9 or 19 digits) for each step.
 3863|  59.3k|  size_t counter = 0;
 3864|  59.3k|  digits = 0;
 3865|  59.3k|  limb value = 0;
 3866|  59.3k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3867|  59.3k|  size_t step = 19;
 3868|       |#else
 3869|       |  size_t step = 9;
 3870|       |#endif
 3871|       |
 3872|       |  // process all integer digits.
 3873|  59.3k|  UC const *p = num.integer.ptr;
 3874|  59.3k|  UC const *pend = p + num.integer.len();
 3875|  59.3k|  skip_zeros(p, pend);
 3876|       |  // process all digits, in increments of step per loop
 3877|   631k|  while (p != pend) {
  ------------------
  |  Branch (3877:10): [True: 585k, False: 46.8k]
  ------------------
 3878|  1.67M|    while ((std::distance(p, pend) >= 8) && (step - counter >= 8) &&
  ------------------
  |  Branch (3878:12): [True: 1.61M, False: 65.7k]
  |  Branch (3878:45): [True: 1.10M, False: 510k]
  ------------------
 3879|  1.10M|           (max_digits - digits >= 8)) {
  ------------------
  |  Branch (3879:12): [True: 1.09M, False: 8.70k]
  ------------------
 3880|  1.09M|      parse_eight_digits(p, value, counter, digits);
 3881|  1.09M|    }
 3882|  2.25M|    while (counter < step && p != pend && digits < max_digits) {
  ------------------
  |  Branch (3882:12): [True: 1.72M, False: 530k]
  |  Branch (3882:30): [True: 1.67M, False: 45.7k]
  |  Branch (3882:43): [True: 1.66M, False: 9.18k]
  ------------------
 3883|  1.66M|      parse_one_digit(p, value, counter, digits);
 3884|  1.66M|    }
 3885|   585k|    if (digits == max_digits) {
  ------------------
  |  Branch (3885:9): [True: 12.5k, False: 572k]
  ------------------
 3886|       |      // add the temporary value, then check if we've truncated any digits
 3887|  12.5k|      add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3888|  12.5k|      bool truncated = is_truncated(p, pend);
 3889|  12.5k|      if (num.fraction.ptr != nullptr) {
  ------------------
  |  Branch (3889:11): [True: 9.27k, False: 3.23k]
  ------------------
 3890|  9.27k|        truncated |= is_truncated(num.fraction);
 3891|  9.27k|      }
 3892|  12.5k|      if (truncated) {
  ------------------
  |  Branch (3892:11): [True: 7.14k, False: 5.36k]
  ------------------
 3893|  7.14k|        round_up_bigint(result, digits);
 3894|  7.14k|      }
 3895|  12.5k|      return;
 3896|   572k|    } else {
 3897|   572k|      add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3898|   572k|      counter = 0;
 3899|   572k|      value = 0;
 3900|   572k|    }
 3901|   585k|  }
 3902|       |
 3903|       |  // add our fraction digits, if they're available.
 3904|  46.8k|  if (num.fraction.ptr != nullptr) {
  ------------------
  |  Branch (3904:7): [True: 26.7k, False: 20.0k]
  ------------------
 3905|  26.7k|    p = num.fraction.ptr;
 3906|  26.7k|    pend = p + num.fraction.len();
 3907|  26.7k|    if (digits == 0) {
  ------------------
  |  Branch (3907:9): [True: 4.32k, False: 22.4k]
  ------------------
 3908|  4.32k|      skip_zeros(p, pend);
 3909|  4.32k|    }
 3910|       |    // process all digits, in increments of step per loop
 3911|   454k|    while (p != pend) {
  ------------------
  |  Branch (3911:12): [True: 437k, False: 16.8k]
  ------------------
 3912|  1.27M|      while ((std::distance(p, pend) >= 8) && (step - counter >= 8) &&
  ------------------
  |  Branch (3912:14): [True: 1.24M, False: 25.9k]
  |  Branch (3912:47): [True: 840k, False: 407k]
  ------------------
 3913|   840k|             (max_digits - digits >= 8)) {
  ------------------
  |  Branch (3913:14): [True: 835k, False: 4.14k]
  ------------------
 3914|   835k|        parse_eight_digits(p, value, counter, digits);
 3915|   835k|      }
 3916|  1.73M|      while (counter < step && p != pend && digits < max_digits) {
  ------------------
  |  Branch (3916:14): [True: 1.32M, False: 414k]
  |  Branch (3916:32): [True: 1.30M, False: 16.0k]
  |  Branch (3916:45): [True: 1.30M, False: 6.70k]
  ------------------
 3917|  1.30M|        parse_one_digit(p, value, counter, digits);
 3918|  1.30M|      }
 3919|   437k|      if (digits == max_digits) {
  ------------------
  |  Branch (3919:11): [True: 9.93k, False: 427k]
  ------------------
 3920|       |        // add the temporary value, then check if we've truncated any digits
 3921|  9.93k|        add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3922|  9.93k|        bool truncated = is_truncated(p, pend);
 3923|  9.93k|        if (truncated) {
  ------------------
  |  Branch (3923:13): [True: 6.29k, False: 3.64k]
  ------------------
 3924|  6.29k|          round_up_bigint(result, digits);
 3925|  6.29k|        }
 3926|  9.93k|        return;
 3927|   427k|      } else {
 3928|   427k|        add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3929|   427k|        counter = 0;
 3930|   427k|        value = 0;
 3931|   427k|      }
 3932|   437k|    }
 3933|  26.7k|  }
 3934|       |
 3935|  36.8k|  if (counter != 0) {
  ------------------
  |  Branch (3935:7): [True: 0, False: 36.8k]
  ------------------
 3936|      0|    add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3937|      0|  }
 3938|  36.8k|}
_ZN3glz10fast_float10skip_zerosIcEEvRPKT_S4_:
 3773|  63.6k|skip_zeros(UC const *&first, UC const *last) noexcept {
 3774|  63.6k|  uint64_t val;
 3775|  64.8k|  while (!cpp20_and_in_constexpr() &&
  ------------------
  |  Branch (3775:10): [True: 64.8k, Folded]
  ------------------
 3776|  64.8k|         std::distance(first, last) >= int_cmp_len<UC>()) {
  ------------------
  |  Branch (3776:10): [True: 53.5k, False: 11.2k]
  ------------------
 3777|  53.5k|    ::memcpy(&val, first, sizeof(uint64_t));
 3778|  53.5k|    if (val != int_cmp_zeros<UC>()) {
  ------------------
  |  Branch (3778:9): [True: 52.4k, False: 1.18k]
  ------------------
 3779|  52.4k|      break;
 3780|  52.4k|    }
 3781|  1.18k|    first += int_cmp_len<UC>();
 3782|  1.18k|  }
 3783|  74.0k|  while (first != last) {
  ------------------
  |  Branch (3783:10): [True: 69.7k, False: 4.32k]
  ------------------
 3784|  69.7k|    if (*first != UC('0')) {
  ------------------
  |  Branch (3784:9): [True: 59.3k, False: 10.4k]
  ------------------
 3785|  59.3k|      break;
 3786|  59.3k|    }
 3787|  10.4k|    first++;
 3788|  10.4k|  }
 3789|  63.6k|}
_ZN3glz10fast_float11int_cmp_lenIcEEiv:
 1180|   272k|template <typename UC> constexpr int int_cmp_len() {
 1181|   272k|  return sizeof(uint64_t) / sizeof(UC);
 1182|   272k|}
_ZN3glz10fast_float13int_cmp_zerosIcEEmv:
 1170|   147k|template <typename UC> constexpr uint64_t int_cmp_zeros() {
 1171|   147k|  static_assert((sizeof(UC) == 1) || (sizeof(UC) == 2) || (sizeof(UC) == 4),
 1172|   147k|                "Unsupported character size");
 1173|   147k|  return (sizeof(UC) == 1) ? 0x3030303030303030
  ------------------
  |  Branch (1173:10): [True: 147k, Folded]
  ------------------
 1174|   147k|         : (sizeof(UC) == 2)
  ------------------
  |  Branch (1174:12): [Folded, False: 0]
  ------------------
 1175|      0|             ? (uint64_t(UC('0')) << 48 | uint64_t(UC('0')) << 32 |
 1176|      0|                uint64_t(UC('0')) << 16 | UC('0'))
 1177|      0|             : (uint64_t(UC('0')) << 32 | UC('0'));
 1178|   147k|}
_ZN3glz10fast_float18parse_eight_digitsIcEEvRPKT_RmS6_S6_:
 3824|  1.92M|                   size_t &count) noexcept {
 3825|  1.92M|  value = value * 100000000 + parse_eight_digits_unrolled(p);
 3826|  1.92M|  p += 8;
 3827|  1.92M|  counter += 8;
 3828|  1.92M|  count += 8;
 3829|  1.92M|}
_ZN3glz10fast_float27parse_eight_digits_unrolledIcEEjPKT_:
 1588|  1.92M|parse_eight_digits_unrolled(UC const *chars) noexcept {
 1589|  1.92M|  if (cpp20_and_in_constexpr() || !has_simd_opt<UC>()) {
  ------------------
  |  Branch (1589:7): [Folded, False: 0]
  |  Branch (1589:35): [True: 0, Folded]
  ------------------
 1590|  1.92M|    return parse_eight_digits_unrolled(read8_to_u64(chars)); // truncation okay
 1591|  1.92M|  }
 1592|      0|  return parse_eight_digits_unrolled(simd_read8_to_u64(chars));
 1593|  1.92M|}
_ZN3glz10fast_float15parse_one_digitIcEEvRPKT_RmS6_S6_:
 3834|  2.97M|                size_t &count) noexcept {
 3835|  2.97M|  value = value * 10 + limb(*p - UC('0'));
 3836|  2.97M|  p++;
 3837|  2.97M|  counter++;
 3838|  2.97M|  count++;
 3839|  2.97M|}
_ZN3glz10fast_float10add_nativeERNS0_6bigintEmm:
 3842|  1.03M|add_native(bigint &big, limb power, limb value) noexcept {
 3843|  1.03M|  big.mul(power);
 3844|  1.03M|  big.add(value);
 3845|  1.03M|}
_ZN3glz10fast_float6bigint3mulEm:
 3552|  1.03M|  GLZ_FASTFLOAT_CONSTEXPR20 bool mul(limb y) noexcept { return small_mul(vec, y); }
_ZN3glz10fast_float9small_mulILt62EEEbRNS0_8stackvecIXT_EEEm:
 3249|  1.76M|                                            limb y) noexcept {
 3250|  1.76M|  limb carry = 0;
 3251|  28.9M|  for (size_t index = 0; index < vec.len(); index++) {
  ------------------
  |  Branch (3251:26): [True: 27.2M, False: 1.76M]
  ------------------
 3252|  27.2M|    vec[index] = scalar_mul(vec[index], y, carry);
 3253|  27.2M|  }
 3254|  1.76M|  if (carry != 0) {
  ------------------
  |  Branch (3254:7): [True: 1.59M, False: 175k]
  ------------------
 3255|  1.59M|    GLZ_FASTFLOAT_TRY(vec.try_push(carry));
  ------------------
  |  |  354|  1.59M|  {                                                                            \
  |  |  355|  1.59M|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 1.59M]
  |  |  ------------------
  |  |  356|  1.59M|      return false;                                                            \
  |  |  357|  1.59M|  }
  ------------------
 3256|  1.59M|  }
 3257|  1.76M|  return true;
 3258|  1.76M|}
_ZNK3glz10fast_float8stackvecILt62EE3lenEv:
 3039|  36.8M|  constexpr size_t len() const noexcept { return length; }
_ZN3glz10fast_float10scalar_mulEmmRm:
 3196|  27.2M|scalar_mul(limb x, limb y, limb &carry) noexcept {
 3197|  27.2M|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3198|  27.2M|#if defined(__SIZEOF_INT128__)
 3199|       |  // GCC and clang both define it as an extension.
 3200|  27.2M|  __uint128_t z = __uint128_t(x) * __uint128_t(y) + __uint128_t(carry);
 3201|  27.2M|  carry = limb(z >> limb_bits);
 3202|  27.2M|  return limb(z);
 3203|       |#else
 3204|       |  // fallback, no native 128-bit integer multiplication with carry.
 3205|       |  // on msvc, this optimizes identically, somehow.
 3206|       |  value128 z = full_multiplication(x, y);
 3207|       |  bool overflow;
 3208|       |  z.low = scalar_add(z.low, carry, overflow);
 3209|       |  z.high += uint64_t(overflow); // cannot overflow
 3210|       |  carry = z.high;
 3211|       |  return z.low;
 3212|       |#endif
 3213|       |#else
 3214|       |  uint64_t z = uint64_t(x) * uint64_t(y) + uint64_t(carry);
 3215|       |  carry = limb(z >> limb_bits);
 3216|       |  return limb(z);
 3217|       |#endif
 3218|  27.2M|}
_ZN3glz10fast_float8stackvecILt62EEixEm:
 3017|  67.1M|  GLZ_FASTFLOAT_CONSTEXPR14 limb &operator[](size_t index) noexcept {
 3018|  67.1M|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|  67.1M|  { ((void)(x)); }
  ------------------
 3019|  67.1M|    return data[index];
 3020|  67.1M|  }
_ZN3glz10fast_float8stackvecILt62EE8try_pushEm:
 3052|  1.66M|  GLZ_FASTFLOAT_CONSTEXPR14 bool try_push(limb value) noexcept {
 3053|  1.66M|    if (len() < capacity()) {
  ------------------
  |  Branch (3053:9): [True: 1.66M, False: 0]
  ------------------
 3054|  1.66M|      push_unchecked(value);
 3055|  1.66M|      return true;
 3056|  1.66M|    } else {
 3057|      0|      return false;
 3058|      0|    }
 3059|  1.66M|  }
_ZNK3glz10fast_float8stackvecILt62EE8capacityEv:
 3043|  2.80M|  constexpr size_t capacity() const noexcept { return size; }
_ZN3glz10fast_float8stackvecILt62EE14push_uncheckedEm:
 3046|  1.70M|  GLZ_FASTFLOAT_CONSTEXPR14 void push_unchecked(limb value) noexcept {
 3047|  1.70M|    data[length] = value;
 3048|  1.70M|    length++;
 3049|  1.70M|  }
_ZN3glz10fast_float6bigint3addEm:
 3554|  1.03M|  GLZ_FASTFLOAT_CONSTEXPR20 bool add(limb y) noexcept { return small_add(vec, y); }
_ZN3glz10fast_float9small_addILt62EEEbRNS0_8stackvecIXT_EEEm:
 3242|  1.03M|small_add(stackvec<size> &vec, limb y) noexcept {
 3243|  1.03M|  return small_add_from(vec, y, 0);
 3244|  1.03M|}
_ZN3glz10fast_float14small_add_fromILt62EEEbRNS0_8stackvecIXT_EEEmm:
 3224|  1.03M|                                                 size_t start) noexcept {
 3225|  1.03M|  size_t index = start;
 3226|  1.03M|  limb carry = y;
 3227|  1.03M|  bool overflow;
 3228|  1.37M|  while (carry != 0 && index < vec.len()) {
  ------------------
  |  Branch (3228:10): [True: 408k, False: 970k]
  |  Branch (3228:24): [True: 343k, False: 64.7k]
  ------------------
 3229|   343k|    vec[index] = scalar_add(vec[index], carry, overflow);
 3230|   343k|    carry = limb(overflow);
 3231|   343k|    index += 1;
 3232|   343k|  }
 3233|  1.03M|  if (carry != 0) {
  ------------------
  |  Branch (3233:7): [True: 64.7k, False: 970k]
  ------------------
 3234|  64.7k|    GLZ_FASTFLOAT_TRY(vec.try_push(carry));
  ------------------
  |  |  354|  64.7k|  {                                                                            \
  |  |  355|  64.7k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 64.7k]
  |  |  ------------------
  |  |  356|  64.7k|      return false;                                                            \
  |  |  357|  64.7k|  }
  ------------------
 3235|  64.7k|  }
 3236|  1.03M|  return true;
 3237|  1.03M|}
_ZN3glz10fast_float10scalar_addEmmRb:
 3176|  7.80M|scalar_add(limb x, limb y, bool &overflow) noexcept {
 3177|  7.80M|  limb z;
 3178|       |// gcc and clang
 3179|  7.80M|#if defined(__has_builtin)
 3180|  7.80M|#if __has_builtin(__builtin_add_overflow)
 3181|  7.80M|  if (!cpp20_and_in_constexpr()) {
  ------------------
  |  Branch (3181:7): [True: 7.80M, Folded]
  ------------------
 3182|  7.80M|    overflow = __builtin_add_overflow(x, y, &z);
 3183|  7.80M|    return z;
 3184|  7.80M|  }
 3185|      0|#endif
 3186|      0|#endif
 3187|       |
 3188|       |  // generic, this still optimizes correctly on MSVC.
 3189|      0|  z = x + y;
 3190|      0|  overflow = z < x;
 3191|      0|  return z;
 3192|  7.80M|}
_ZN3glz10fast_float12is_truncatedIcEEbPKT_S4_:
 3795|  31.7k|is_truncated(UC const *first, UC const *last) noexcept {
 3796|       |  // do 8-bit optimizations, can just compare to 8 literal 0s.
 3797|  31.7k|  uint64_t val;
 3798|   119k|  while (!cpp20_and_in_constexpr() &&
  ------------------
  |  Branch (3798:10): [True: 119k, Folded]
  ------------------
 3799|   119k|         std::distance(first, last) >= int_cmp_len<UC>()) {
  ------------------
  |  Branch (3799:10): [True: 93.4k, False: 25.7k]
  ------------------
 3800|  93.4k|    ::memcpy(&val, first, sizeof(uint64_t));
 3801|  93.4k|    if (val != int_cmp_zeros<UC>()) {
  ------------------
  |  Branch (3801:9): [True: 6.01k, False: 87.4k]
  ------------------
 3802|  6.01k|      return true;
 3803|  6.01k|    }
 3804|  87.4k|    first += int_cmp_len<UC>();
 3805|  87.4k|  }
 3806|  65.4k|  while (first != last) {
  ------------------
  |  Branch (3806:10): [True: 50.8k, False: 14.5k]
  ------------------
 3807|  50.8k|    if (*first != UC('0')) {
  ------------------
  |  Branch (3807:9): [True: 11.1k, False: 39.7k]
  ------------------
 3808|  11.1k|      return true;
 3809|  11.1k|    }
 3810|  39.7k|    ++first;
 3811|  39.7k|  }
 3812|  14.5k|  return false;
 3813|  25.7k|}
_ZN3glz10fast_float12is_truncatedIcEEbNS0_4spanIKT_EE:
 3817|  9.27k|is_truncated(span<UC const> s) noexcept {
 3818|  9.27k|  return is_truncated(s.ptr, s.ptr + s.len());
 3819|  9.27k|}
_ZN3glz10fast_float15round_up_bigintERNS0_6bigintERm:
 3848|  13.4k|round_up_bigint(bigint &big, size_t &count) noexcept {
 3849|       |  // need to round-up the digits, but need to avoid rounding
 3850|       |  // ....9999 to ...10000, which could cause a false halfway point.
 3851|  13.4k|  add_native(big, 10, 1);
 3852|  13.4k|  count++;
 3853|  13.4k|}
_ZN3glz10fast_float19positive_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintEi:
 3942|  17.7k|positive_digit_comp(bigint &bigmant, int32_t exponent) noexcept {
 3943|  17.7k|  GLZ_FASTFLOAT_ASSERT(bigmant.pow10(uint32_t(exponent)));
  ------------------
  |  |  344|  17.7k|  { ((void)(x)); }
  ------------------
 3944|  17.7k|  adjusted_mantissa answer;
 3945|  17.7k|  bool truncated;
 3946|  17.7k|  answer.mantissa = bigmant.hi64(truncated);
 3947|  17.7k|  int bias = binary_format<T>::mantissa_explicit_bits() -
 3948|  17.7k|             binary_format<T>::minimum_exponent();
 3949|  17.7k|  answer.power2 = bigmant.bit_length() - 64 + bias;
 3950|       |
 3951|  17.7k|  round<T>(answer, [truncated](adjusted_mantissa &a, int32_t shift) {
 3952|  17.7k|    round_nearest_tie_even(
 3953|  17.7k|        a, shift,
 3954|  17.7k|        [truncated](bool is_odd, bool is_halfway, bool is_above) -> bool {
 3955|  17.7k|          return is_above || (is_halfway && truncated) ||
 3956|  17.7k|                 (is_odd && is_halfway);
 3957|  17.7k|        });
 3958|  17.7k|  });
 3959|       |
 3960|  17.7k|  return answer;
 3961|  17.7k|}
_ZN3glz10fast_float6bigint5pow10Ej:
 3591|  17.7k|  GLZ_FASTFLOAT_CONSTEXPR20 bool pow10(uint32_t exp) noexcept {
 3592|  17.7k|    GLZ_FASTFLOAT_TRY(pow5(exp));
  ------------------
  |  |  354|  17.7k|  {                                                                            \
  |  |  355|  17.7k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 17.7k]
  |  |  ------------------
  |  |  356|  17.7k|      return false;                                                            \
  |  |  357|  17.7k|  }
  ------------------
 3593|  17.7k|    return pow2(exp);
 3594|  17.7k|  }
_ZN3glz10fast_float6bigint4pow5Ej:
 3560|  59.3k|  GLZ_FASTFLOAT_CONSTEXPR20 bool pow5(uint32_t exp) noexcept {
 3561|       |    // multiply by a power of 5
 3562|  59.3k|    size_t large_length = sizeof(large_power_of_5) / sizeof(limb);
 3563|  59.3k|    limb_span large = limb_span(large_power_of_5, large_length);
 3564|   182k|    while (exp >= large_step) {
  ------------------
  |  Branch (3564:12): [True: 122k, False: 59.3k]
  ------------------
 3565|   122k|      GLZ_FASTFLOAT_TRY(large_mul(vec, large));
  ------------------
  |  |  354|   122k|  {                                                                            \
  |  |  355|   122k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 122k]
  |  |  ------------------
  |  |  356|   122k|      return false;                                                            \
  |  |  357|   122k|  }
  ------------------
 3566|   122k|      exp -= large_step;
 3567|   122k|    }
 3568|  59.3k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3569|  59.3k|    uint32_t small_step = 27;
 3570|  59.3k|    limb max_native = 7450580596923828125UL;
 3571|       |#else
 3572|       |    uint32_t small_step = 13;
 3573|       |    limb max_native = 1220703125U;
 3574|       |#endif
 3575|   124k|    while (exp >= small_step) {
  ------------------
  |  Branch (3575:12): [True: 65.5k, False: 59.3k]
  ------------------
 3576|  65.5k|      GLZ_FASTFLOAT_TRY(small_mul(vec, max_native));
  ------------------
  |  |  354|  65.5k|  {                                                                            \
  |  |  355|  65.5k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 65.5k]
  |  |  ------------------
  |  |  356|  65.5k|      return false;                                                            \
  |  |  357|  65.5k|  }
  ------------------
 3577|  65.5k|      exp -= small_step;
 3578|  65.5k|    }
 3579|  59.3k|    if (exp != 0) {
  ------------------
  |  Branch (3579:9): [True: 51.1k, False: 8.19k]
  ------------------
 3580|       |      // Work around clang bug https://godbolt.org/z/zedh7rrhc
 3581|       |      // This is similar to https://github.com/llvm/llvm-project/issues/47746,
 3582|       |      // except the workaround described there don't work here
 3583|  51.1k|      GLZ_FASTFLOAT_TRY(small_mul(
  ------------------
  |  |  354|  51.1k|  {                                                                            \
  |  |  355|  51.1k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 51.1k]
  |  |  ------------------
  |  |  356|  51.1k|      return false;                                                            \
  |  |  357|  51.1k|  }
  ------------------
 3584|  51.1k|          vec, limb(((void)small_power_of_5[0], small_power_of_5[exp]))));
 3585|  51.1k|    }
 3586|       |
 3587|  59.3k|    return true;
 3588|  59.3k|  }
_ZN3glz10fast_float4spanImEC2EPKmm:
  436|   796k|  constexpr span(T const *_ptr, size_t _length) : ptr(_ptr), length(_length) {}
_ZN3glz10fast_float9large_mulILt62EEEbRNS0_8stackvecIXT_EEENS0_4spanImEE:
 3329|   122k|GLZ_FASTFLOAT_CONSTEXPR20 bool large_mul(stackvec<size> &x, limb_span y) noexcept {
 3330|   122k|  if (y.len() == 1) {
  ------------------
  |  Branch (3330:7): [True: 0, False: 122k]
  ------------------
 3331|      0|    GLZ_FASTFLOAT_TRY(small_mul(x, y[0]));
  ------------------
  |  |  354|      0|  {                                                                            \
  |  |  355|      0|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  356|      0|      return false;                                                            \
  |  |  357|      0|  }
  ------------------
 3332|   122k|  } else {
 3333|   122k|    GLZ_FASTFLOAT_TRY(long_mul(x, y));
  ------------------
  |  |  354|   122k|  {                                                                            \
  |  |  355|   122k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 122k]
  |  |  ------------------
  |  |  356|   122k|      return false;                                                            \
  |  |  357|   122k|  }
  ------------------
 3334|   122k|  }
 3335|   122k|  return true;
 3336|   122k|}
_ZNK3glz10fast_float4spanImE3lenEv:
  440|  9.47M|  constexpr size_t len() const noexcept { return length; }
_ZNK3glz10fast_float4spanImEixEm:
  442|  5.91M|  GLZ_FASTFLOAT_CONSTEXPR14 const T &operator[](size_t index) const noexcept {
  443|  5.91M|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|  5.91M|  { ((void)(x)); }
  ------------------
  444|  5.91M|    return ptr[index];
  445|  5.91M|  }
_ZN3glz10fast_float8long_mulILt62EEEbRNS0_8stackvecIXT_EEENS0_4spanImEE:
 3301|   122k|GLZ_FASTFLOAT_CONSTEXPR20 bool long_mul(stackvec<size> &x, limb_span y) noexcept {
 3302|   122k|  limb_span xs = limb_span(x.data, x.len());
 3303|   122k|  stackvec<size> z(xs);
 3304|   122k|  limb_span zs = limb_span(z.data, z.len());
 3305|       |
 3306|   122k|  if (y.len() != 0) {
  ------------------
  |  Branch (3306:7): [True: 122k, False: 0]
  ------------------
 3307|   122k|    limb y0 = y[0];
 3308|   122k|    GLZ_FASTFLOAT_TRY(small_mul(x, y0));
  ------------------
  |  |  354|   122k|  {                                                                            \
  |  |  355|   122k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 122k]
  |  |  ------------------
  |  |  356|   122k|      return false;                                                            \
  |  |  357|   122k|  }
  ------------------
 3309|   614k|    for (size_t index = 1; index < y.len(); index++) {
  ------------------
  |  Branch (3309:28): [True: 491k, False: 122k]
  ------------------
 3310|   491k|      limb yi = y[index];
 3311|   491k|      stackvec<size> zi;
 3312|   491k|      if (yi != 0) {
  ------------------
  |  Branch (3312:11): [True: 491k, False: 0]
  ------------------
 3313|       |        // re-use the same buffer throughout
 3314|   491k|        zi.set_len(0);
 3315|   491k|        GLZ_FASTFLOAT_TRY(zi.try_extend(zs));
  ------------------
  |  |  354|   491k|  {                                                                            \
  |  |  355|   491k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 491k]
  |  |  ------------------
  |  |  356|   491k|      return false;                                                            \
  |  |  357|   491k|  }
  ------------------
 3316|   491k|        GLZ_FASTFLOAT_TRY(small_mul(zi, yi));
  ------------------
  |  |  354|   491k|  {                                                                            \
  |  |  355|   491k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 491k]
  |  |  ------------------
  |  |  356|   491k|      return false;                                                            \
  |  |  357|   491k|  }
  ------------------
 3317|   491k|        limb_span zis = limb_span(zi.data, zi.len());
 3318|   491k|        GLZ_FASTFLOAT_TRY(large_add_from(x, zis, index));
  ------------------
  |  |  354|   491k|  {                                                                            \
  |  |  355|   491k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 491k]
  |  |  ------------------
  |  |  356|   491k|      return false;                                                            \
  |  |  357|   491k|  }
  ------------------
 3319|   491k|      }
 3320|   491k|    }
 3321|   122k|  }
 3322|       |
 3323|   122k|  x.normalize();
 3324|   122k|  return true;
 3325|   122k|}
_ZN3glz10fast_float8stackvecILt62EEC2ENS0_4spanImEE:
 3013|   122k|  GLZ_FASTFLOAT_CONSTEXPR20 stackvec(limb_span s) {
 3014|   122k|    GLZ_FASTFLOAT_ASSERT(try_extend(s));
  ------------------
  |  |  344|   122k|  { ((void)(x)); }
  ------------------
 3015|   122k|  }
_ZN3glz10fast_float8stackvecILt62EE7set_lenEm:
 3035|  1.62M|  GLZ_FASTFLOAT_CONSTEXPR14 void set_len(size_t len) noexcept {
 3036|  1.62M|    length = uint16_t(len);
 3037|  1.62M|  }
_ZN3glz10fast_float8stackvecILt62EE10try_extendENS0_4spanImEE:
 3069|   614k|  GLZ_FASTFLOAT_CONSTEXPR20 bool try_extend(limb_span s) noexcept {
 3070|   614k|    if (len() + s.len() <= capacity()) {
  ------------------
  |  Branch (3070:9): [True: 614k, False: 0]
  ------------------
 3071|   614k|      extend_unchecked(s);
 3072|   614k|      return true;
 3073|   614k|    } else {
 3074|      0|      return false;
 3075|      0|    }
 3076|   614k|  }
_ZN3glz10fast_float8stackvecILt62EE16extend_uncheckedENS0_4spanImEE:
 3062|   614k|  GLZ_FASTFLOAT_CONSTEXPR20 void extend_unchecked(limb_span s) noexcept {
 3063|   614k|    limb *ptr = data + length;
 3064|   614k|    std::copy_n(s.ptr, s.len(), ptr);
 3065|   614k|    set_len(len() + s.len());
 3066|   614k|  }
_ZN3glz10fast_float14large_add_fromILt62EEEbRNS0_8stackvecIXT_EEENS0_4spanImEEm:
 3264|   491k|                                          size_t start) noexcept {
 3265|       |  // the effective x buffer is from `xstart..x.len()`, so exit early
 3266|       |  // if we can't get that current range.
 3267|   491k|  if (x.len() < start || y.len() > x.len() - start) {
  ------------------
  |  Branch (3267:7): [True: 0, False: 491k]
  |  Branch (3267:26): [True: 487k, False: 4.40k]
  ------------------
 3268|   487k|    GLZ_FASTFLOAT_TRY(x.try_resize(y.len() + start, 0));
  ------------------
  |  |  354|   487k|  {                                                                            \
  |  |  355|   487k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 487k]
  |  |  ------------------
  |  |  356|   487k|      return false;                                                            \
  |  |  357|   487k|  }
  ------------------
 3269|   487k|  }
 3270|       |
 3271|   491k|  bool carry = false;
 3272|  5.79M|  for (size_t index = 0; index < y.len(); index++) {
  ------------------
  |  Branch (3272:26): [True: 5.30M, False: 491k]
  ------------------
 3273|  5.30M|    limb xi = x[index + start];
 3274|  5.30M|    limb yi = y[index];
 3275|  5.30M|    bool c1 = false;
 3276|  5.30M|    bool c2 = false;
 3277|  5.30M|    xi = scalar_add(xi, yi, c1);
 3278|  5.30M|    if (carry) {
  ------------------
  |  Branch (3278:9): [True: 2.16M, False: 3.13M]
  ------------------
 3279|  2.16M|      xi = scalar_add(xi, 1, c2);
 3280|  2.16M|    }
 3281|  5.30M|    x[index + start] = xi;
 3282|  5.30M|    carry = c1 | c2;
 3283|  5.30M|  }
 3284|       |
 3285|       |  // handle overflow
 3286|   491k|  if (carry) {
  ------------------
  |  Branch (3286:7): [True: 0, False: 491k]
  ------------------
 3287|      0|    GLZ_FASTFLOAT_TRY(small_add_from(x, 1, y.len() + start));
  ------------------
  |  |  354|      0|  {                                                                            \
  |  |  355|      0|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  356|      0|      return false;                                                            \
  |  |  357|      0|  }
  ------------------
 3288|      0|  }
 3289|   491k|  return true;
 3290|   491k|}
_ZN3glz10fast_float8stackvecILt62EE10try_resizeEmm:
 3095|   487k|  GLZ_FASTFLOAT_CONSTEXPR20 bool try_resize(size_t new_len, limb value) noexcept {
 3096|   487k|    if (new_len > capacity()) {
  ------------------
  |  Branch (3096:9): [True: 0, False: 487k]
  ------------------
 3097|      0|      return false;
 3098|   487k|    } else {
 3099|   487k|      resize_unchecked(new_len, value);
 3100|   487k|      return true;
 3101|   487k|    }
 3102|   487k|  }
_ZN3glz10fast_float8stackvecILt62EE16resize_uncheckedEmm:
 3082|   487k|  void resize_unchecked(size_t new_len, limb value) noexcept {
 3083|   487k|    if (new_len > len()) {
  ------------------
  |  Branch (3083:9): [True: 487k, False: 0]
  ------------------
 3084|   487k|      size_t count = new_len - len();
 3085|   487k|      limb *first = data + len();
 3086|   487k|      limb *last = first + count;
 3087|   487k|      ::std::fill(first, last, value);
 3088|   487k|      set_len(new_len);
 3089|   487k|    } else {
 3090|      0|      set_len(new_len);
 3091|      0|    }
 3092|   487k|  }
_ZN3glz10fast_float8stackvecILt62EE9normalizeEv:
 3118|   164k|  GLZ_FASTFLOAT_CONSTEXPR14 void normalize() noexcept {
 3119|   164k|    while (len() > 0 && rindex(0) == 0) {
  ------------------
  |  Branch (3119:12): [True: 164k, False: 0]
  |  Branch (3119:25): [True: 0, False: 164k]
  ------------------
 3120|      0|      length--;
 3121|      0|    }
 3122|   164k|  }
_ZNK3glz10fast_float8stackvecILt62EE6rindexEm:
 3028|   223k|  GLZ_FASTFLOAT_CONSTEXPR14 const limb &rindex(size_t index) const noexcept {
 3029|   223k|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|   223k|  { ((void)(x)); }
  ------------------
 3030|   223k|    size_t rindex = length - index - 1;
 3031|   223k|    return data[rindex];
 3032|   223k|  }
_ZN3glz10fast_float6bigint4pow2Ej:
 3557|  58.3k|  GLZ_FASTFLOAT_CONSTEXPR20 bool pow2(uint32_t exp) noexcept { return shl(exp); }
_ZN3glz10fast_float6bigint3shlEm:
 3519|  58.3k|  GLZ_FASTFLOAT_CONSTEXPR20 bool shl(size_t n) noexcept {
 3520|  58.3k|    size_t rem = n % limb_bits;
 3521|  58.3k|    size_t div = n / limb_bits;
 3522|  58.3k|    if (rem != 0) {
  ------------------
  |  Branch (3522:9): [True: 47.4k, False: 10.8k]
  ------------------
 3523|  47.4k|      GLZ_FASTFLOAT_TRY(shl_bits(rem));
  ------------------
  |  |  354|  47.4k|  {                                                                            \
  |  |  355|  47.4k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 47.4k]
  |  |  ------------------
  |  |  356|  47.4k|      return false;                                                            \
  |  |  357|  47.4k|  }
  ------------------
 3524|  47.4k|    }
 3525|  58.3k|    if (div != 0) {
  ------------------
  |  Branch (3525:9): [True: 35.4k, False: 22.8k]
  ------------------
 3526|  35.4k|      GLZ_FASTFLOAT_TRY(shl_limbs(div));
  ------------------
  |  |  354|  35.4k|  {                                                                            \
  |  |  355|  35.4k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 35.4k]
  |  |  ------------------
  |  |  356|  35.4k|      return false;                                                            \
  |  |  357|  35.4k|  }
  ------------------
 3527|  35.4k|    }
 3528|  58.3k|    return true;
 3529|  58.3k|  }
_ZN3glz10fast_float6bigint8shl_bitsEm:
 3472|  47.4k|  GLZ_FASTFLOAT_CONSTEXPR20 bool shl_bits(size_t n) noexcept {
 3473|       |    // Internally, for each item, we shift left by n, and add the previous
 3474|       |    // right shifted limb-bits.
 3475|       |    // For example, we transform (for u8) shifted left 2, to:
 3476|       |    //      b10100100 b01000010
 3477|       |    //      b10 b10010001 b00001000
 3478|  47.4k|    GLZ_FASTFLOAT_DEBUG_ASSERT(n != 0);
  ------------------
  |  |  349|  47.4k|  { ((void)(x)); }
  ------------------
 3479|  47.4k|    GLZ_FASTFLOAT_DEBUG_ASSERT(n < sizeof(limb) * 8);
  ------------------
  |  |  349|  47.4k|  { ((void)(x)); }
  ------------------
 3480|       |
 3481|  47.4k|    size_t shl = n;
 3482|  47.4k|    size_t shr = limb_bits - shl;
 3483|  47.4k|    limb prev = 0;
 3484|   735k|    for (size_t index = 0; index < vec.len(); index++) {
  ------------------
  |  Branch (3484:28): [True: 688k, False: 47.4k]
  ------------------
 3485|   688k|      limb xi = vec[index];
 3486|   688k|      vec[index] = (xi << shl) | (prev >> shr);
 3487|   688k|      prev = xi;
 3488|   688k|    }
 3489|       |
 3490|  47.4k|    limb carry = prev >> shr;
 3491|  47.4k|    if (carry != 0) {
  ------------------
  |  Branch (3491:9): [True: 12.3k, False: 35.0k]
  ------------------
 3492|  12.3k|      return vec.try_push(carry);
 3493|  12.3k|    }
 3494|  35.0k|    return true;
 3495|  47.4k|  }
_ZN3glz10fast_float6bigint9shl_limbsEm:
 3498|  35.4k|  GLZ_FASTFLOAT_CONSTEXPR20 bool shl_limbs(size_t n) noexcept {
 3499|  35.4k|    GLZ_FASTFLOAT_DEBUG_ASSERT(n != 0);
  ------------------
  |  |  349|  35.4k|  { ((void)(x)); }
  ------------------
 3500|  35.4k|    if (n + vec.len() > vec.capacity()) {
  ------------------
  |  Branch (3500:9): [True: 0, False: 35.4k]
  ------------------
 3501|      0|      return false;
 3502|  35.4k|    } else if (!vec.is_empty()) {
  ------------------
  |  Branch (3502:16): [True: 35.4k, False: 0]
  ------------------
 3503|       |      // move limbs
 3504|  35.4k|      limb *dst = vec.data + n;
 3505|  35.4k|      limb const *src = vec.data;
 3506|  35.4k|      std::copy_backward(src, src + vec.len(), dst + vec.len());
 3507|       |      // fill in empty limbs
 3508|  35.4k|      limb *first = vec.data;
 3509|  35.4k|      limb *last = first + n;
 3510|  35.4k|      ::std::fill(first, last, 0);
 3511|  35.4k|      vec.set_len(n + vec.len());
 3512|  35.4k|      return true;
 3513|  35.4k|    } else {
 3514|      0|      return true;
 3515|      0|    }
 3516|  35.4k|  }
_ZNK3glz10fast_float8stackvecILt62EE8is_emptyEv:
 3041|  53.1k|  constexpr bool is_empty() const noexcept { return length == 0; }
_ZNK3glz10fast_float6bigint4hi64ERb:
 3418|  17.7k|  GLZ_FASTFLOAT_CONSTEXPR20 uint64_t hi64(bool &truncated) const noexcept {
 3419|  17.7k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3420|  17.7k|    if (vec.len() == 0) {
  ------------------
  |  Branch (3420:9): [True: 0, False: 17.7k]
  ------------------
 3421|      0|      return empty_hi64(truncated);
 3422|  17.7k|    } else if (vec.len() == 1) {
  ------------------
  |  Branch (3422:16): [True: 4.55k, False: 13.1k]
  ------------------
 3423|  4.55k|      return uint64_hi64(vec.rindex(0), truncated);
 3424|  13.1k|    } else {
 3425|  13.1k|      uint64_t result = uint64_hi64(vec.rindex(0), vec.rindex(1), truncated);
 3426|  13.1k|      truncated |= vec.nonzero(2);
 3427|  13.1k|      return result;
 3428|  13.1k|    }
 3429|       |#else
 3430|       |    if (vec.len() == 0) {
 3431|       |      return empty_hi64(truncated);
 3432|       |    } else if (vec.len() == 1) {
 3433|       |      return uint32_hi64(vec.rindex(0), truncated);
 3434|       |    } else if (vec.len() == 2) {
 3435|       |      return uint32_hi64(vec.rindex(0), vec.rindex(1), truncated);
 3436|       |    } else {
 3437|       |      uint64_t result =
 3438|       |          uint32_hi64(vec.rindex(0), vec.rindex(1), vec.rindex(2), truncated);
 3439|       |      truncated |= vec.nonzero(3);
 3440|       |      return result;
 3441|       |    }
 3442|       |#endif
 3443|  17.7k|  }
_ZN3glz10fast_float11uint64_hi64EmRb:
 3132|  4.55k|uint64_hi64(uint64_t r0, bool &truncated) noexcept {
 3133|  4.55k|  truncated = false;
 3134|  4.55k|  int shl = leading_zeroes(r0);
 3135|  4.55k|  return r0 << shl;
 3136|  4.55k|}
_ZN3glz10fast_float11uint64_hi64EmmRb:
 3139|  13.1k|uint64_hi64(uint64_t r0, uint64_t r1, bool &truncated) noexcept {
 3140|  13.1k|  int shl = leading_zeroes(r0);
 3141|  13.1k|  if (shl == 0) {
  ------------------
  |  Branch (3141:7): [True: 1.49k, False: 11.6k]
  ------------------
 3142|  1.49k|    truncated = r1 != 0;
 3143|  1.49k|    return r0;
 3144|  11.6k|  } else {
 3145|  11.6k|    int shr = 64 - shl;
 3146|  11.6k|    truncated = (r1 << shl) != 0;
 3147|  11.6k|    return (r0 << shl) | (r1 >> shr);
 3148|  11.6k|  }
 3149|  13.1k|}
_ZNK3glz10fast_float8stackvecILt62EE7nonzeroEm:
 3107|  13.1k|  GLZ_FASTFLOAT_CONSTEXPR14 bool nonzero(size_t index) const noexcept {
 3108|  17.9k|    while (index < len()) {
  ------------------
  |  Branch (3108:12): [True: 10.8k, False: 7.12k]
  ------------------
 3109|  10.8k|      if (rindex(index) != 0) {
  ------------------
  |  Branch (3109:11): [True: 6.05k, False: 4.80k]
  ------------------
 3110|  6.05k|        return true;
 3111|  6.05k|      }
 3112|  4.80k|      index++;
 3113|  4.80k|    }
 3114|  7.12k|    return false;
 3115|  13.1k|  }
_ZNK3glz10fast_float6bigint10bit_lengthEv:
 3547|  17.7k|  GLZ_FASTFLOAT_CONSTEXPR20 int bit_length() const noexcept {
 3548|  17.7k|    int lz = ctlz();
 3549|  17.7k|    return int(limb_bits * vec.len()) - lz;
 3550|  17.7k|  }
_ZNK3glz10fast_float6bigint4ctlzEv:
 3532|  17.7k|  GLZ_FASTFLOAT_CONSTEXPR20 int ctlz() const noexcept {
 3533|  17.7k|    if (vec.is_empty()) {
  ------------------
  |  Branch (3533:9): [True: 0, False: 17.7k]
  ------------------
 3534|      0|      return 0;
 3535|  17.7k|    } else {
 3536|  17.7k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3537|  17.7k|      return leading_zeroes(vec.rindex(0));
 3538|       |#else
 3539|       |      // no use defining a specialized leading_zeroes for a 32-bit type.
 3540|       |      uint64_t r0 = vec.rindex(0);
 3541|       |      return leading_zeroes(r0 << 32);
 3542|       |#endif
 3543|  17.7k|    }
 3544|  17.7k|  }
_ZN3glz10fast_float5roundIdZNS0_19positive_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintEiEUlRS3_iE_EEvS6_T0_:
 3707|  17.7k|                                                         callback cb) noexcept {
 3708|  17.7k|  int32_t mantissa_shift = 64 - binary_format<T>::mantissa_explicit_bits() - 1;
 3709|  17.7k|  if (-am.power2 >= mantissa_shift) {
  ------------------
  |  Branch (3709:7): [True: 0, False: 17.7k]
  ------------------
 3710|       |    // have a denormal float
 3711|      0|    int32_t shift = -am.power2 + 1;
 3712|      0|    cb(am, (std::min<int32_t>)(shift, 64));
 3713|       |    // check for round-up: if rounding-nearest carried us to the hidden bit.
 3714|      0|    am.power2 = (am.mantissa <
  ------------------
  |  Branch (3714:17): [True: 0, False: 0]
  ------------------
 3715|      0|                 (uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))
 3716|      0|                    ? 0
 3717|      0|                    : 1;
 3718|      0|    return;
 3719|      0|  }
 3720|       |
 3721|       |  // have a normal float, use the default shift.
 3722|  17.7k|  cb(am, mantissa_shift);
 3723|       |
 3724|       |  // check for carry
 3725|  17.7k|  if (am.mantissa >=
  ------------------
  |  Branch (3725:7): [True: 2.55k, False: 15.1k]
  ------------------
 3726|  17.7k|      (uint64_t(2) << binary_format<T>::mantissa_explicit_bits())) {
 3727|  2.55k|    am.mantissa = (uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3728|  2.55k|    am.power2++;
 3729|  2.55k|  }
 3730|       |
 3731|       |  // check for infinite: we could have carried to an infinite power
 3732|  17.7k|  am.mantissa &= ~(uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3733|  17.7k|  if (am.power2 >= binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (3733:7): [True: 0, False: 17.7k]
  ------------------
 3734|      0|    am.power2 = binary_format<T>::infinite_power();
 3735|      0|    am.mantissa = 0;
 3736|      0|  }
 3737|  17.7k|}
_ZZN3glz10fast_float19positive_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintEiENKUlRS2_iE_clES5_i:
 3951|  17.7k|  round<T>(answer, [truncated](adjusted_mantissa &a, int32_t shift) {
 3952|  17.7k|    round_nearest_tie_even(
 3953|  17.7k|        a, shift,
 3954|  17.7k|        [truncated](bool is_odd, bool is_halfway, bool is_above) -> bool {
 3955|  17.7k|          return is_above || (is_halfway && truncated) ||
 3956|  17.7k|                 (is_odd && is_halfway);
 3957|  17.7k|        });
 3958|  17.7k|  });
_ZN3glz10fast_float22round_nearest_tie_evenIZZNS0_19positive_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintEiENKUlRS3_iE_clES6_iEUlbbbE_EEvS6_iT_:
 3742|  17.7k|                       callback cb) noexcept {
 3743|  17.7k|  uint64_t const mask = (shift == 64) ? UINT64_MAX : (uint64_t(1) << shift) - 1;
  ------------------
  |  Branch (3743:25): [True: 0, False: 17.7k]
  ------------------
 3744|  17.7k|  uint64_t const halfway = (shift == 0) ? 0 : uint64_t(1) << (shift - 1);
  ------------------
  |  Branch (3744:28): [True: 0, False: 17.7k]
  ------------------
 3745|  17.7k|  uint64_t truncated_bits = am.mantissa & mask;
 3746|  17.7k|  bool is_above = truncated_bits > halfway;
 3747|  17.7k|  bool is_halfway = truncated_bits == halfway;
 3748|       |
 3749|       |  // shift digits into position
 3750|  17.7k|  if (shift == 64) {
  ------------------
  |  Branch (3750:7): [True: 0, False: 17.7k]
  ------------------
 3751|      0|    am.mantissa = 0;
 3752|  17.7k|  } else {
 3753|  17.7k|    am.mantissa >>= shift;
 3754|  17.7k|  }
 3755|  17.7k|  am.power2 += shift;
 3756|       |
 3757|  17.7k|  bool is_odd = (am.mantissa & 1) == 1;
 3758|  17.7k|  am.mantissa += uint64_t(cb(is_odd, is_halfway, is_above));
 3759|  17.7k|}
_ZZZN3glz10fast_float19positive_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintEiENKUlRS2_iE_clES5_iENKUlbbbE_clEbbb:
 3954|  17.7k|        [truncated](bool is_odd, bool is_halfway, bool is_above) -> bool {
 3955|  17.7k|          return is_above || (is_halfway && truncated) ||
  ------------------
  |  Branch (3955:18): [True: 3.99k, False: 13.7k]
  |  Branch (3955:31): [True: 9.96k, False: 3.77k]
  |  Branch (3955:45): [True: 4.65k, False: 5.31k]
  ------------------
 3956|  9.08k|                 (is_odd && is_halfway);
  ------------------
  |  Branch (3956:19): [True: 2.74k, False: 6.33k]
  |  Branch (3956:29): [True: 42, False: 2.70k]
  ------------------
 3957|  17.7k|        });
_ZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_i:
 3970|  41.5k|    bigint &bigmant, adjusted_mantissa am, int32_t exponent) noexcept {
 3971|  41.5k|  bigint &real_digits = bigmant;
 3972|  41.5k|  int32_t real_exp = exponent;
 3973|       |
 3974|       |  // get the value of `b`, rounded down, and get a bigint representation of b+h
 3975|  41.5k|  adjusted_mantissa am_b = am;
 3976|       |  // gcc7 buf: use a lambda to remove the noexcept qualifier bug with
 3977|       |  // -Wnoexcept-type.
 3978|  41.5k|  round<T>(am_b,
 3979|  41.5k|           [](adjusted_mantissa &a, int32_t shift) { round_down(a, shift); });
 3980|  41.5k|  T b;
 3981|  41.5k|  to_float(false, am_b, b);
 3982|  41.5k|  adjusted_mantissa theor = to_extended_halfway(b);
 3983|  41.5k|  bigint theor_digits(theor.mantissa);
 3984|  41.5k|  int32_t theor_exp = theor.power2;
 3985|       |
 3986|       |  // scale real digits and theor digits to be same power.
 3987|  41.5k|  int32_t pow2_exp = theor_exp - real_exp;
 3988|  41.5k|  uint32_t pow5_exp = uint32_t(-real_exp);
 3989|  41.5k|  if (pow5_exp != 0) {
  ------------------
  |  Branch (3989:7): [True: 41.5k, False: 0]
  ------------------
 3990|  41.5k|    GLZ_FASTFLOAT_ASSERT(theor_digits.pow5(pow5_exp));
  ------------------
  |  |  344|  41.5k|  { ((void)(x)); }
  ------------------
 3991|  41.5k|  }
 3992|  41.5k|  if (pow2_exp > 0) {
  ------------------
  |  Branch (3992:7): [True: 28.9k, False: 12.6k]
  ------------------
 3993|  28.9k|    GLZ_FASTFLOAT_ASSERT(theor_digits.pow2(uint32_t(pow2_exp)));
  ------------------
  |  |  344|  28.9k|  { ((void)(x)); }
  ------------------
 3994|  28.9k|  } else if (pow2_exp < 0) {
  ------------------
  |  Branch (3994:14): [True: 11.6k, False: 981]
  ------------------
 3995|  11.6k|    GLZ_FASTFLOAT_ASSERT(real_digits.pow2(uint32_t(-pow2_exp)));
  ------------------
  |  |  344|  11.6k|  { ((void)(x)); }
  ------------------
 3996|  11.6k|  }
 3997|       |
 3998|       |  // compare digits, and use it to director rounding
 3999|  41.5k|  int ord = real_digits.compare(theor_digits);
 4000|  41.5k|  adjusted_mantissa answer = am;
 4001|  41.5k|  round<T>(answer, [ord](adjusted_mantissa &a, int32_t shift) {
 4002|  41.5k|    round_nearest_tie_even(
 4003|  41.5k|        a, shift, [ord](bool is_odd, bool _, bool __) -> bool {
 4004|  41.5k|          (void)_;  // not needed, since we've done our comparison
 4005|  41.5k|          (void)__; // not needed, since we've done our comparison
 4006|  41.5k|          if (ord > 0) {
 4007|  41.5k|            return true;
 4008|  41.5k|          } else if (ord < 0) {
 4009|  41.5k|            return false;
 4010|  41.5k|          } else {
 4011|  41.5k|            return is_odd;
 4012|  41.5k|          }
 4013|  41.5k|        });
 4014|  41.5k|  });
 4015|       |
 4016|  41.5k|  return answer;
 4017|  41.5k|}
_ZN3glz10fast_float5roundIdZNS0_19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES3_iEUlRS3_iE_EEvS6_T0_:
 3707|  41.5k|                                                         callback cb) noexcept {
 3708|  41.5k|  int32_t mantissa_shift = 64 - binary_format<T>::mantissa_explicit_bits() - 1;
 3709|  41.5k|  if (-am.power2 >= mantissa_shift) {
  ------------------
  |  Branch (3709:7): [True: 4.65k, False: 36.9k]
  ------------------
 3710|       |    // have a denormal float
 3711|  4.65k|    int32_t shift = -am.power2 + 1;
 3712|  4.65k|    cb(am, (std::min<int32_t>)(shift, 64));
 3713|       |    // check for round-up: if rounding-nearest carried us to the hidden bit.
 3714|  4.65k|    am.power2 = (am.mantissa <
  ------------------
  |  Branch (3714:17): [True: 4.65k, False: 0]
  ------------------
 3715|  4.65k|                 (uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))
 3716|  4.65k|                    ? 0
 3717|  4.65k|                    : 1;
 3718|  4.65k|    return;
 3719|  4.65k|  }
 3720|       |
 3721|       |  // have a normal float, use the default shift.
 3722|  36.9k|  cb(am, mantissa_shift);
 3723|       |
 3724|       |  // check for carry
 3725|  36.9k|  if (am.mantissa >=
  ------------------
  |  Branch (3725:7): [True: 0, False: 36.9k]
  ------------------
 3726|  36.9k|      (uint64_t(2) << binary_format<T>::mantissa_explicit_bits())) {
 3727|      0|    am.mantissa = (uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3728|      0|    am.power2++;
 3729|      0|  }
 3730|       |
 3731|       |  // check for infinite: we could have carried to an infinite power
 3732|  36.9k|  am.mantissa &= ~(uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3733|  36.9k|  if (am.power2 >= binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (3733:7): [True: 0, False: 36.9k]
  ------------------
 3734|      0|    am.power2 = binary_format<T>::infinite_power();
 3735|      0|    am.mantissa = 0;
 3736|      0|  }
 3737|  36.9k|}
_ZZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_iENKUlRS2_iE_clES5_i:
 3979|  41.5k|           [](adjusted_mantissa &a, int32_t shift) { round_down(a, shift); });
_ZN3glz10fast_float10round_downERNS0_17adjusted_mantissaEi:
 3762|  41.5k|round_down(adjusted_mantissa &am, int32_t shift) noexcept {
 3763|  41.5k|  if (shift == 64) {
  ------------------
  |  Branch (3763:7): [True: 1.07k, False: 40.5k]
  ------------------
 3764|  1.07k|    am.mantissa = 0;
 3765|  40.5k|  } else {
 3766|  40.5k|    am.mantissa >>= shift;
 3767|  40.5k|  }
 3768|  41.5k|  am.power2 += shift;
 3769|  41.5k|}
_ZN3glz10fast_float19to_extended_halfwayIdEENS0_17adjusted_mantissaET_:
 3696|  41.5k|to_extended_halfway(T value) noexcept {
 3697|  41.5k|  adjusted_mantissa am = to_extended(value);
 3698|  41.5k|  am.mantissa <<= 1;
 3699|  41.5k|  am.mantissa += 1;
 3700|  41.5k|  am.power2 -= 1;
 3701|  41.5k|  return am;
 3702|  41.5k|}
_ZN3glz10fast_float11to_extendedIdEENS0_17adjusted_mantissaET_:
 3661|  41.5k|to_extended(T value) noexcept {
 3662|  41.5k|  using equiv_uint = equiv_uint_t<T>;
 3663|  41.5k|  constexpr equiv_uint exponent_mask = binary_format<T>::exponent_mask();
 3664|  41.5k|  constexpr equiv_uint mantissa_mask = binary_format<T>::mantissa_mask();
 3665|  41.5k|  constexpr equiv_uint hidden_bit_mask = binary_format<T>::hidden_bit_mask();
 3666|       |
 3667|  41.5k|  adjusted_mantissa am;
 3668|  41.5k|  int32_t bias = binary_format<T>::mantissa_explicit_bits() -
 3669|  41.5k|                 binary_format<T>::minimum_exponent();
 3670|  41.5k|  equiv_uint bits;
 3671|  41.5k|#if GLZ_FASTFLOAT_HAS_BIT_CAST
 3672|  41.5k|  bits = std::bit_cast<equiv_uint>(value);
 3673|       |#else
 3674|       |  ::memcpy(&bits, &value, sizeof(T));
 3675|       |#endif
 3676|  41.5k|  if ((bits & exponent_mask) == 0) {
  ------------------
  |  Branch (3676:7): [True: 4.65k, False: 36.9k]
  ------------------
 3677|       |    // denormal
 3678|  4.65k|    am.power2 = 1 - bias;
 3679|  4.65k|    am.mantissa = bits & mantissa_mask;
 3680|  36.9k|  } else {
 3681|       |    // normal
 3682|  36.9k|    am.power2 = int32_t((bits & exponent_mask) >>
 3683|  36.9k|                        binary_format<T>::mantissa_explicit_bits());
 3684|  36.9k|    am.power2 -= bias;
 3685|  36.9k|    am.mantissa = (bits & mantissa_mask) | hidden_bit_mask;
 3686|  36.9k|  }
 3687|       |
 3688|  41.5k|  return am;
 3689|  41.5k|}
_ZN3glz10fast_float6bigintC2Em:
 3406|  41.5k|  GLZ_FASTFLOAT_CONSTEXPR20 bigint(uint64_t value) : vec() {
 3407|  41.5k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3408|  41.5k|    vec.push_unchecked(value);
 3409|       |#else
 3410|       |    vec.push_unchecked(uint32_t(value));
 3411|       |    vec.push_unchecked(uint32_t(value >> 32));
 3412|       |#endif
 3413|  41.5k|    vec.normalize();
 3414|  41.5k|  }
_ZNK3glz10fast_float6bigint7compareERKS1_:
 3451|  41.5k|  GLZ_FASTFLOAT_CONSTEXPR20 int compare(bigint const &other) const noexcept {
 3452|  41.5k|    if (vec.len() > other.vec.len()) {
  ------------------
  |  Branch (3452:9): [True: 0, False: 41.5k]
  ------------------
 3453|      0|      return 1;
 3454|  41.5k|    } else if (vec.len() < other.vec.len()) {
  ------------------
  |  Branch (3454:16): [True: 0, False: 41.5k]
  ------------------
 3455|      0|      return -1;
 3456|  41.5k|    } else {
 3457|  86.1k|      for (size_t index = vec.len(); index > 0; index--) {
  ------------------
  |  Branch (3457:38): [True: 83.0k, False: 3.11k]
  ------------------
 3458|  83.0k|        limb xi = vec[index - 1];
 3459|  83.0k|        limb yi = other.vec[index - 1];
 3460|  83.0k|        if (xi > yi) {
  ------------------
  |  Branch (3460:13): [True: 14.4k, False: 68.5k]
  ------------------
 3461|  14.4k|          return 1;
 3462|  68.5k|        } else if (xi < yi) {
  ------------------
  |  Branch (3462:20): [True: 24.0k, False: 44.5k]
  ------------------
 3463|  24.0k|          return -1;
 3464|  24.0k|        }
 3465|  83.0k|      }
 3466|  3.11k|      return 0;
 3467|  41.5k|    }
 3468|  41.5k|  }
_ZNK3glz10fast_float8stackvecILt62EEixEm:
 3022|   166k|  GLZ_FASTFLOAT_CONSTEXPR14 const limb &operator[](size_t index) const noexcept {
 3023|   166k|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|   166k|  { ((void)(x)); }
  ------------------
 3024|   166k|    return data[index];
 3025|   166k|  }
_ZN3glz10fast_float5roundIdZNS0_19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES3_iEUlRS3_iE0_EEvS6_T0_:
 3707|  41.5k|                                                         callback cb) noexcept {
 3708|  41.5k|  int32_t mantissa_shift = 64 - binary_format<T>::mantissa_explicit_bits() - 1;
 3709|  41.5k|  if (-am.power2 >= mantissa_shift) {
  ------------------
  |  Branch (3709:7): [True: 4.65k, False: 36.9k]
  ------------------
 3710|       |    // have a denormal float
 3711|  4.65k|    int32_t shift = -am.power2 + 1;
 3712|  4.65k|    cb(am, (std::min<int32_t>)(shift, 64));
 3713|       |    // check for round-up: if rounding-nearest carried us to the hidden bit.
 3714|  4.65k|    am.power2 = (am.mantissa <
  ------------------
  |  Branch (3714:17): [True: 4.65k, False: 6]
  ------------------
 3715|  4.65k|                 (uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))
 3716|  4.65k|                    ? 0
 3717|  4.65k|                    : 1;
 3718|  4.65k|    return;
 3719|  4.65k|  }
 3720|       |
 3721|       |  // have a normal float, use the default shift.
 3722|  36.9k|  cb(am, mantissa_shift);
 3723|       |
 3724|       |  // check for carry
 3725|  36.9k|  if (am.mantissa >=
  ------------------
  |  Branch (3725:7): [True: 1.83k, False: 35.0k]
  ------------------
 3726|  36.9k|      (uint64_t(2) << binary_format<T>::mantissa_explicit_bits())) {
 3727|  1.83k|    am.mantissa = (uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3728|  1.83k|    am.power2++;
 3729|  1.83k|  }
 3730|       |
 3731|       |  // check for infinite: we could have carried to an infinite power
 3732|  36.9k|  am.mantissa &= ~(uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3733|  36.9k|  if (am.power2 >= binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (3733:7): [True: 0, False: 36.9k]
  ------------------
 3734|      0|    am.power2 = binary_format<T>::infinite_power();
 3735|      0|    am.mantissa = 0;
 3736|      0|  }
 3737|  36.9k|}
_ZZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_iENKUlRS2_iE0_clES5_i:
 4001|  41.5k|  round<T>(answer, [ord](adjusted_mantissa &a, int32_t shift) {
 4002|  41.5k|    round_nearest_tie_even(
 4003|  41.5k|        a, shift, [ord](bool is_odd, bool _, bool __) -> bool {
 4004|  41.5k|          (void)_;  // not needed, since we've done our comparison
 4005|  41.5k|          (void)__; // not needed, since we've done our comparison
 4006|  41.5k|          if (ord > 0) {
 4007|  41.5k|            return true;
 4008|  41.5k|          } else if (ord < 0) {
 4009|  41.5k|            return false;
 4010|  41.5k|          } else {
 4011|  41.5k|            return is_odd;
 4012|  41.5k|          }
 4013|  41.5k|        });
 4014|  41.5k|  });
_ZN3glz10fast_float22round_nearest_tie_evenIZZNS0_19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES3_iENKUlRS3_iE0_clES6_iEUlbbbE_EEvS6_iT_:
 3742|  41.5k|                       callback cb) noexcept {
 3743|  41.5k|  uint64_t const mask = (shift == 64) ? UINT64_MAX : (uint64_t(1) << shift) - 1;
  ------------------
  |  Branch (3743:25): [True: 1.07k, False: 40.5k]
  ------------------
 3744|  41.5k|  uint64_t const halfway = (shift == 0) ? 0 : uint64_t(1) << (shift - 1);
  ------------------
  |  Branch (3744:28): [True: 0, False: 41.5k]
  ------------------
 3745|  41.5k|  uint64_t truncated_bits = am.mantissa & mask;
 3746|  41.5k|  bool is_above = truncated_bits > halfway;
 3747|  41.5k|  bool is_halfway = truncated_bits == halfway;
 3748|       |
 3749|       |  // shift digits into position
 3750|  41.5k|  if (shift == 64) {
  ------------------
  |  Branch (3750:7): [True: 1.07k, False: 40.5k]
  ------------------
 3751|  1.07k|    am.mantissa = 0;
 3752|  40.5k|  } else {
 3753|  40.5k|    am.mantissa >>= shift;
 3754|  40.5k|  }
 3755|  41.5k|  am.power2 += shift;
 3756|       |
 3757|  41.5k|  bool is_odd = (am.mantissa & 1) == 1;
 3758|  41.5k|  am.mantissa += uint64_t(cb(is_odd, is_halfway, is_above));
 3759|  41.5k|}
_ZZZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_iENKUlRS2_iE0_clES5_iENKUlbbbE_clEbbb:
 4003|  41.5k|        a, shift, [ord](bool is_odd, bool _, bool __) -> bool {
 4004|  41.5k|          (void)_;  // not needed, since we've done our comparison
 4005|  41.5k|          (void)__; // not needed, since we've done our comparison
 4006|  41.5k|          if (ord > 0) {
  ------------------
  |  Branch (4006:15): [True: 14.4k, False: 27.1k]
  ------------------
 4007|  14.4k|            return true;
 4008|  27.1k|          } else if (ord < 0) {
  ------------------
  |  Branch (4008:22): [True: 24.0k, False: 3.11k]
  ------------------
 4009|  24.0k|            return false;
 4010|  24.0k|          } else {
 4011|  3.11k|            return is_odd;
 4012|  3.11k|          }
 4013|  41.5k|        });
_ZN3glz10fast_float8to_floatIdEEvbNS0_17adjusted_mantissaERT_:
 1131|   128k|to_float(bool negative, adjusted_mantissa am, T &value) {
 1132|   128k|  using equiv_uint = equiv_uint_t<T>;
 1133|   128k|  equiv_uint word = equiv_uint(am.mantissa);
 1134|   128k|  word = equiv_uint(word | equiv_uint(am.power2)
 1135|   128k|                               << binary_format<T>::mantissa_explicit_bits());
 1136|   128k|  word =
 1137|   128k|      equiv_uint(word | equiv_uint(negative) << binary_format<T>::sign_index());
 1138|   128k|#if GLZ_FASTFLOAT_HAS_BIT_CAST
 1139|   128k|  value = std::bit_cast<T>(word);
 1140|       |#else
 1141|       |  ::memcpy(&value, &word, sizeof(T));
 1142|       |#endif
 1143|   128k|}
_ZN3glz10fast_float13binary_formatIdE10sign_indexEv:
  758|   128k|template <> inline constexpr int binary_format<double>::sign_index() {
  759|   128k|  return 63;
  760|   128k|}
_ZN3glz10fast_float13binary_formatIdE14infinite_powerEv:
  750|   322k|template <> inline constexpr int binary_format<double>::infinite_power() {
  751|   322k|  return 0x7FF;
  752|   322k|}

_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   24|   615k|   {
   25|   615k|      if constexpr (N > 0) {
   26|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   27|       |         // These generate less assembly with O0, but make no difference for higher optimization
   28|       |         if constexpr (N == 1) {
   29|       |            lambda.template operator()<0>();
   30|       |         }
   31|       |         else if constexpr (N == 2) {
   32|       |            lambda.template operator()<0>();
   33|       |            lambda.template operator()<1>();
   34|       |         }
   35|       |         else if constexpr (N == 3) {
   36|       |            lambda.template operator()<0>();
   37|       |            lambda.template operator()<1>();
   38|       |            lambda.template operator()<2>();
   39|       |         }
   40|       |         else if constexpr (N == 4) {
   41|       |            lambda.template operator()<0>();
   42|       |            lambda.template operator()<1>();
   43|       |            lambda.template operator()<2>();
   44|       |            lambda.template operator()<3>();
   45|       |         }
   46|   615k|         else {
   47|   615k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|   615k|               (void)(lambda.template operator()<I>(), ...);
   49|   615k|            }(std::make_index_sequence<N>{});
   50|   615k|         }
   51|   615k|      }
   52|   615k|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   47|   615k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|   615k|               (void)(lambda.template operator()<I>(), ...);
   49|   615k|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   24|  6.38k|   {
   25|  6.38k|      if constexpr (N > 0) {
   26|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   27|       |         // These generate less assembly with O0, but make no difference for higher optimization
   28|       |         if constexpr (N == 1) {
   29|       |            lambda.template operator()<0>();
   30|       |         }
   31|       |         else if constexpr (N == 2) {
   32|       |            lambda.template operator()<0>();
   33|       |            lambda.template operator()<1>();
   34|       |         }
   35|       |         else if constexpr (N == 3) {
   36|       |            lambda.template operator()<0>();
   37|       |            lambda.template operator()<1>();
   38|       |            lambda.template operator()<2>();
   39|       |         }
   40|       |         else if constexpr (N == 4) {
   41|       |            lambda.template operator()<0>();
   42|       |            lambda.template operator()<1>();
   43|       |            lambda.template operator()<2>();
   44|       |            lambda.template operator()<3>();
   45|       |         }
   46|  6.38k|         else {
   47|  6.38k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  6.38k|               (void)(lambda.template operator()<I>(), ...);
   49|  6.38k|            }(std::make_index_sequence<N>{});
   50|  6.38k|         }
   51|  6.38k|      }
   52|  6.38k|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   47|  6.38k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  6.38k|               (void)(lambda.template operator()<I>(), ...);
   49|  6.38k|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   24|  1.38k|   {
   25|  1.38k|      if constexpr (N > 0) {
   26|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   27|       |         // These generate less assembly with O0, but make no difference for higher optimization
   28|       |         if constexpr (N == 1) {
   29|       |            lambda.template operator()<0>();
   30|       |         }
   31|       |         else if constexpr (N == 2) {
   32|       |            lambda.template operator()<0>();
   33|       |            lambda.template operator()<1>();
   34|       |         }
   35|       |         else if constexpr (N == 3) {
   36|       |            lambda.template operator()<0>();
   37|       |            lambda.template operator()<1>();
   38|       |            lambda.template operator()<2>();
   39|       |         }
   40|       |         else if constexpr (N == 4) {
   41|       |            lambda.template operator()<0>();
   42|       |            lambda.template operator()<1>();
   43|       |            lambda.template operator()<2>();
   44|       |            lambda.template operator()<3>();
   45|       |         }
   46|  1.38k|         else {
   47|  1.38k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.38k|               (void)(lambda.template operator()<I>(), ...);
   49|  1.38k|            }(std::make_index_sequence<N>{});
   50|  1.38k|         }
   51|  1.38k|      }
   52|  1.38k|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   47|  1.38k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.38k|               (void)(lambda.template operator()<I>(), ...);
   49|  1.38k|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   24|  1.95M|   {
   25|  1.95M|      if constexpr (N > 0) {
   26|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   27|       |         // These generate less assembly with O0, but make no difference for higher optimization
   28|       |         if constexpr (N == 1) {
   29|       |            lambda.template operator()<0>();
   30|       |         }
   31|       |         else if constexpr (N == 2) {
   32|       |            lambda.template operator()<0>();
   33|       |            lambda.template operator()<1>();
   34|       |         }
   35|       |         else if constexpr (N == 3) {
   36|       |            lambda.template operator()<0>();
   37|       |            lambda.template operator()<1>();
   38|       |            lambda.template operator()<2>();
   39|       |         }
   40|       |         else if constexpr (N == 4) {
   41|       |            lambda.template operator()<0>();
   42|       |            lambda.template operator()<1>();
   43|       |            lambda.template operator()<2>();
   44|       |            lambda.template operator()<3>();
   45|       |         }
   46|  1.95M|         else {
   47|  1.95M|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.95M|               (void)(lambda.template operator()<I>(), ...);
   49|  1.95M|            }(std::make_index_sequence<N>{});
   50|  1.95M|         }
   51|  1.95M|      }
   52|  1.95M|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   47|  1.95M|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.95M|               (void)(lambda.template operator()<I>(), ...);
   49|  1.95M|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   24|   615k|   {
   25|   615k|      if constexpr (N > 0) {
   26|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   27|       |         // These generate less assembly with O0, but make no difference for higher optimization
   28|       |         if constexpr (N == 1) {
   29|       |            lambda.template operator()<0>();
   30|       |         }
   31|       |         else if constexpr (N == 2) {
   32|       |            lambda.template operator()<0>();
   33|       |            lambda.template operator()<1>();
   34|       |         }
   35|       |         else if constexpr (N == 3) {
   36|       |            lambda.template operator()<0>();
   37|       |            lambda.template operator()<1>();
   38|       |            lambda.template operator()<2>();
   39|       |         }
   40|       |         else if constexpr (N == 4) {
   41|       |            lambda.template operator()<0>();
   42|       |            lambda.template operator()<1>();
   43|       |            lambda.template operator()<2>();
   44|       |            lambda.template operator()<3>();
   45|       |         }
   46|   615k|         else {
   47|   615k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|   615k|               (void)(lambda.template operator()<I>(), ...);
   49|   615k|            }(std::make_index_sequence<N>{});
   50|   615k|         }
   51|   615k|      }
   52|   615k|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   47|   615k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|   615k|               (void)(lambda.template operator()<I>(), ...);
   49|   615k|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   24|  6.38k|   {
   25|  6.38k|      if constexpr (N > 0) {
   26|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   27|       |         // These generate less assembly with O0, but make no difference for higher optimization
   28|       |         if constexpr (N == 1) {
   29|       |            lambda.template operator()<0>();
   30|       |         }
   31|       |         else if constexpr (N == 2) {
   32|       |            lambda.template operator()<0>();
   33|       |            lambda.template operator()<1>();
   34|       |         }
   35|       |         else if constexpr (N == 3) {
   36|       |            lambda.template operator()<0>();
   37|       |            lambda.template operator()<1>();
   38|       |            lambda.template operator()<2>();
   39|       |         }
   40|       |         else if constexpr (N == 4) {
   41|       |            lambda.template operator()<0>();
   42|       |            lambda.template operator()<1>();
   43|       |            lambda.template operator()<2>();
   44|       |            lambda.template operator()<3>();
   45|       |         }
   46|  6.38k|         else {
   47|  6.38k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  6.38k|               (void)(lambda.template operator()<I>(), ...);
   49|  6.38k|            }(std::make_index_sequence<N>{});
   50|  6.38k|         }
   51|  6.38k|      }
   52|  6.38k|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   47|  6.38k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  6.38k|               (void)(lambda.template operator()<I>(), ...);
   49|  6.38k|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   24|  1.38k|   {
   25|  1.38k|      if constexpr (N > 0) {
   26|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   27|       |         // These generate less assembly with O0, but make no difference for higher optimization
   28|       |         if constexpr (N == 1) {
   29|       |            lambda.template operator()<0>();
   30|       |         }
   31|       |         else if constexpr (N == 2) {
   32|       |            lambda.template operator()<0>();
   33|       |            lambda.template operator()<1>();
   34|       |         }
   35|       |         else if constexpr (N == 3) {
   36|       |            lambda.template operator()<0>();
   37|       |            lambda.template operator()<1>();
   38|       |            lambda.template operator()<2>();
   39|       |         }
   40|       |         else if constexpr (N == 4) {
   41|       |            lambda.template operator()<0>();
   42|       |            lambda.template operator()<1>();
   43|       |            lambda.template operator()<2>();
   44|       |            lambda.template operator()<3>();
   45|       |         }
   46|  1.38k|         else {
   47|  1.38k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.38k|               (void)(lambda.template operator()<I>(), ...);
   49|  1.38k|            }(std::make_index_sequence<N>{});
   50|  1.38k|         }
   51|  1.38k|      }
   52|  1.38k|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   47|  1.38k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.38k|               (void)(lambda.template operator()<I>(), ...);
   49|  1.38k|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   24|  1.95M|   {
   25|  1.95M|      if constexpr (N > 0) {
   26|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   27|       |         // These generate less assembly with O0, but make no difference for higher optimization
   28|       |         if constexpr (N == 1) {
   29|       |            lambda.template operator()<0>();
   30|       |         }
   31|       |         else if constexpr (N == 2) {
   32|       |            lambda.template operator()<0>();
   33|       |            lambda.template operator()<1>();
   34|       |         }
   35|       |         else if constexpr (N == 3) {
   36|       |            lambda.template operator()<0>();
   37|       |            lambda.template operator()<1>();
   38|       |            lambda.template operator()<2>();
   39|       |         }
   40|       |         else if constexpr (N == 4) {
   41|       |            lambda.template operator()<0>();
   42|       |            lambda.template operator()<1>();
   43|       |            lambda.template operator()<2>();
   44|       |            lambda.template operator()<3>();
   45|       |         }
   46|  1.95M|         else {
   47|  1.95M|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.95M|               (void)(lambda.template operator()<I>(), ...);
   49|  1.95M|            }(std::make_index_sequence<N>{});
   50|  1.95M|         }
   51|  1.95M|      }
   52|  1.95M|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   47|  1.95M|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.95M|               (void)(lambda.template operator()<I>(), ...);
   49|  1.95M|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   24|   615k|   {
   25|   615k|      if constexpr (N > 0) {
   26|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   27|       |         // These generate less assembly with O0, but make no difference for higher optimization
   28|       |         if constexpr (N == 1) {
   29|       |            lambda.template operator()<0>();
   30|       |         }
   31|       |         else if constexpr (N == 2) {
   32|       |            lambda.template operator()<0>();
   33|       |            lambda.template operator()<1>();
   34|       |         }
   35|       |         else if constexpr (N == 3) {
   36|       |            lambda.template operator()<0>();
   37|       |            lambda.template operator()<1>();
   38|       |            lambda.template operator()<2>();
   39|       |         }
   40|       |         else if constexpr (N == 4) {
   41|       |            lambda.template operator()<0>();
   42|       |            lambda.template operator()<1>();
   43|       |            lambda.template operator()<2>();
   44|       |            lambda.template operator()<3>();
   45|       |         }
   46|   615k|         else {
   47|   615k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|   615k|               (void)(lambda.template operator()<I>(), ...);
   49|   615k|            }(std::make_index_sequence<N>{});
   50|   615k|         }
   51|   615k|      }
   52|   615k|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   47|   615k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|   615k|               (void)(lambda.template operator()<I>(), ...);
   49|   615k|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   24|  6.38k|   {
   25|  6.38k|      if constexpr (N > 0) {
   26|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   27|       |         // These generate less assembly with O0, but make no difference for higher optimization
   28|       |         if constexpr (N == 1) {
   29|       |            lambda.template operator()<0>();
   30|       |         }
   31|       |         else if constexpr (N == 2) {
   32|       |            lambda.template operator()<0>();
   33|       |            lambda.template operator()<1>();
   34|       |         }
   35|       |         else if constexpr (N == 3) {
   36|       |            lambda.template operator()<0>();
   37|       |            lambda.template operator()<1>();
   38|       |            lambda.template operator()<2>();
   39|       |         }
   40|       |         else if constexpr (N == 4) {
   41|       |            lambda.template operator()<0>();
   42|       |            lambda.template operator()<1>();
   43|       |            lambda.template operator()<2>();
   44|       |            lambda.template operator()<3>();
   45|       |         }
   46|  6.38k|         else {
   47|  6.38k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  6.38k|               (void)(lambda.template operator()<I>(), ...);
   49|  6.38k|            }(std::make_index_sequence<N>{});
   50|  6.38k|         }
   51|  6.38k|      }
   52|  6.38k|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   47|  6.38k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  6.38k|               (void)(lambda.template operator()<I>(), ...);
   49|  6.38k|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   24|  1.38k|   {
   25|  1.38k|      if constexpr (N > 0) {
   26|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   27|       |         // These generate less assembly with O0, but make no difference for higher optimization
   28|       |         if constexpr (N == 1) {
   29|       |            lambda.template operator()<0>();
   30|       |         }
   31|       |         else if constexpr (N == 2) {
   32|       |            lambda.template operator()<0>();
   33|       |            lambda.template operator()<1>();
   34|       |         }
   35|       |         else if constexpr (N == 3) {
   36|       |            lambda.template operator()<0>();
   37|       |            lambda.template operator()<1>();
   38|       |            lambda.template operator()<2>();
   39|       |         }
   40|       |         else if constexpr (N == 4) {
   41|       |            lambda.template operator()<0>();
   42|       |            lambda.template operator()<1>();
   43|       |            lambda.template operator()<2>();
   44|       |            lambda.template operator()<3>();
   45|       |         }
   46|  1.38k|         else {
   47|  1.38k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.38k|               (void)(lambda.template operator()<I>(), ...);
   49|  1.38k|            }(std::make_index_sequence<N>{});
   50|  1.38k|         }
   51|  1.38k|      }
   52|  1.38k|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   47|  1.38k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.38k|               (void)(lambda.template operator()<I>(), ...);
   49|  1.38k|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   24|  1.95M|   {
   25|  1.95M|      if constexpr (N > 0) {
   26|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   27|       |         // These generate less assembly with O0, but make no difference for higher optimization
   28|       |         if constexpr (N == 1) {
   29|       |            lambda.template operator()<0>();
   30|       |         }
   31|       |         else if constexpr (N == 2) {
   32|       |            lambda.template operator()<0>();
   33|       |            lambda.template operator()<1>();
   34|       |         }
   35|       |         else if constexpr (N == 3) {
   36|       |            lambda.template operator()<0>();
   37|       |            lambda.template operator()<1>();
   38|       |            lambda.template operator()<2>();
   39|       |         }
   40|       |         else if constexpr (N == 4) {
   41|       |            lambda.template operator()<0>();
   42|       |            lambda.template operator()<1>();
   43|       |            lambda.template operator()<2>();
   44|       |            lambda.template operator()<3>();
   45|       |         }
   46|  1.95M|         else {
   47|  1.95M|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.95M|               (void)(lambda.template operator()<I>(), ...);
   49|  1.95M|            }(std::make_index_sequence<N>{});
   50|  1.95M|         }
   51|  1.95M|      }
   52|  1.95M|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   47|  1.95M|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.95M|               (void)(lambda.template operator()<I>(), ...);
   49|  1.95M|            }(std::make_index_sequence<N>{});

_ZN3glz10from_charsILb0EdcEENS_10fast_float19from_chars_result_tIT1_EEPKS3_S6_RT0_:
  236|  1.95M|   {
  237|  1.95M|      using namespace glz::fast_float;
  238|  1.95M|      static_assert(is_supported_float_type<T>(), "only some floating-point types are supported");
  239|  1.95M|      static_assert(is_supported_char_type<UC>(), "only char, wchar_t, char16_t and char32_t are supported");
  240|       |
  241|  1.95M|      parsed_number_string_t<UC> pns = glz::parse_number_string<null_terminated, UC>(first, last);
  242|  1.95M|      if (!pns.valid) [[unlikely]] {
  ------------------
  |  Branch (242:11): [True: 1.34k, False: 1.95M]
  ------------------
  243|  1.34k|         return {.ptr = first, .ec = std::errc::invalid_argument};
  244|  1.34k|      }
  245|       |
  246|  1.95M|      return from_chars_advanced(pns, value);
  247|  1.95M|   }
_ZN3glz19parse_number_stringILb0EcEENS_10fast_float22parsed_number_string_tIT0_EEPKS3_S6_:
   18|  1.95M|   {
   19|  1.95M|      using namespace glz::fast_float;
   20|  1.95M|      static constexpr UC decimal_point = '.';
   21|       |
   22|  1.95M|      parsed_number_string_t<UC> answer;
   23|  1.95M|      answer.valid = false;
   24|  1.95M|      answer.too_many_digits = false;
   25|  1.95M|      answer.negative = (*p == UC('-'));
   26|  1.95M|      if (*p == UC('-')) { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here
  ------------------
  |  Branch (26:11): [True: 4.38k, False: 1.94M]
  ------------------
   27|  4.38k|         ++p;
   28|       |
   29|  4.38k|         if constexpr (not null_terminated) {
   30|  4.38k|            if (p == pend) [[unlikely]] {
  ------------------
  |  Branch (30:17): [True: 3, False: 4.37k]
  ------------------
   31|      3|               return answer;
   32|      3|            }
   33|  4.38k|         }
   34|       |
   35|  4.38k|         if (!glz::fast_float::is_integer(*p)) [[unlikely]] { // a sign must be followed by an integer
  ------------------
  |  Branch (35:14): [True: 22, False: 4.35k]
  ------------------
   36|     22|            return answer;
   37|     22|         }
   38|  4.38k|      }
   39|  1.95M|      UC const* const start_digits = p;
   40|       |
   41|  1.95M|      uint64_t i = 0; // an unsigned int avoids signed overflows (which are bad)
   42|       |
   43|  1.95M|      uint64_t digit;
   44|       |      if constexpr (null_terminated) {
   45|       |         while ((digit = glz::fast_float::digit_value(*p)) <= 9) {
   46|       |            // a multiplication by 10 is cheaper than an arbitrary integer
   47|       |            // multiplication
   48|       |            i = 10 * i + digit; // might overflow, we will handle the overflow later
   49|       |            ++p;
   50|       |         }
   51|       |      }
   52|  1.95M|      else {
   53|  11.7M|         while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9) {
  ------------------
  |  Branch (53:17): [True: 11.7M, False: 832]
  |  Branch (53:32): [True: 9.79M, False: 1.95M]
  ------------------
   54|       |            // a multiplication by 10 is cheaper than an arbitrary integer
   55|       |            // multiplication
   56|  9.79M|            i = 10 * i + digit; // might overflow, we will handle the overflow later
   57|  9.79M|            ++p;
   58|  9.79M|         }
   59|  1.95M|      }
   60|       |
   61|  1.95M|      UC const* const end_of_integer_part = p;
   62|  1.95M|      int64_t digit_count = int64_t(end_of_integer_part - start_digits);
   63|  1.95M|      answer.integer = glz::fast_float::span<const UC>(start_digits, size_t(digit_count));
   64|       |
   65|       |      // at least 1 digit in integer part, without leading zeros
   66|  1.95M|      if (digit_count == 0 || (start_digits[0] == UC('0') && digit_count > 1)) {
  ------------------
  |  Branch (66:11): [True: 1.21k, False: 1.95M]
  |  Branch (66:32): [True: 864k, False: 1.08M]
  |  Branch (66:62): [True: 76, False: 864k]
  ------------------
   67|  1.28k|         return answer;
   68|  1.28k|      }
   69|       |
   70|  1.95M|      int64_t exponent = 0;
   71|  1.95M|      const bool has_decimal_point = [&] {
   72|  1.95M|         if constexpr (null_terminated) {
   73|  1.95M|            return (*p == decimal_point);
   74|  1.95M|         }
   75|  1.95M|         else {
   76|  1.95M|            return (p != pend) && (*p == decimal_point);
   77|  1.95M|         }
   78|  1.95M|      }();
   79|  1.95M|      if (has_decimal_point) {
  ------------------
  |  Branch (79:11): [True: 15.7k, False: 1.93M]
  ------------------
   80|  15.7k|         ++p;
   81|  15.7k|         UC const* before = p;
   82|       |         // can occur at most twice without overflowing, but let it occur more, since
   83|       |         // for integers with many digits, digit parsing is the primary bottleneck.
   84|  15.7k|         loop_parse_if_eight_digits(p, pend, i);
   85|       |
   86|       |         if constexpr (null_terminated) {
   87|       |            while ((digit = glz::fast_float::digit_value(*p)) <= 9) {
   88|       |               ++p;
   89|       |               i = i * 10 + digit; // in rare cases, this will overflow, but that's ok
   90|       |            }
   91|       |         }
   92|  15.7k|         else {
   93|  61.1k|            while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9) {
  ------------------
  |  Branch (93:20): [True: 60.1k, False: 990]
  |  Branch (93:35): [True: 45.4k, False: 14.7k]
  ------------------
   94|  45.4k|               ++p;
   95|  45.4k|               i = i * 10 + digit; // in rare cases, this will overflow, but that's ok
   96|  45.4k|            }
   97|  15.7k|         }
   98|  15.7k|         exponent = before - p;
   99|  15.7k|         answer.fraction = glz::fast_float::span<const UC>(before, size_t(p - before));
  100|  15.7k|         digit_count -= exponent;
  101|  15.7k|      }
  102|       |      // at least 1 digit in fractional part
  103|  1.95M|      if (has_decimal_point && exponent == 0) {
  ------------------
  |  Branch (103:11): [True: 15.7k, False: 1.93M]
  |  Branch (103:32): [True: 28, False: 15.6k]
  ------------------
  104|     28|         return answer;
  105|     28|      }
  106|       |
  107|  1.95M|      int64_t exp_number = 0; // explicit exponential part
  108|       |
  109|       |      if constexpr (null_terminated) {
  110|       |         if ((UC('e') == *p) || (UC('E') == *p)) {
  111|       |            UC const* location_of_e = p;
  112|       |            ++p;
  113|       |            bool neg_exp = false;
  114|       |            if (UC('-') == *p) {
  115|       |               neg_exp = true;
  116|       |               ++p;
  117|       |            }
  118|       |            else if (UC('+') == *p) { // '+' on exponent is allowed by C++17 20.19.3.(7.1)
  119|       |               ++p;
  120|       |            }
  121|       |            if ((digit = glz::fast_float::digit_value(*p)) > 9) {
  122|       |               // Otherwise, we will be ignoring the 'e'.
  123|       |               p = location_of_e;
  124|       |            }
  125|       |            else {
  126|       |               do {
  127|       |                  if (exp_number < 0x10000000) {
  128|       |                     exp_number = 10 * exp_number + digit;
  129|       |                  }
  130|       |                  ++p;
  131|       |               } while ((digit = glz::fast_float::digit_value(*p)) <= 9);
  132|       |               if (neg_exp) {
  133|       |                  exp_number = -exp_number;
  134|       |               }
  135|       |               exponent += exp_number;
  136|       |            }
  137|       |         }
  138|       |      }
  139|  1.95M|      else {
  140|  1.95M|         if ((p != pend) && ((UC('e') == *p) || (UC('E') == *p))) {
  ------------------
  |  Branch (140:14): [True: 1.95M, False: 1.78k]
  |  Branch (140:30): [True: 7.51k, False: 1.94M]
  |  Branch (140:49): [True: 8.53k, False: 1.93M]
  ------------------
  141|  16.0k|            UC const* location_of_e = p;
  142|  16.0k|            ++p;
  143|  16.0k|            bool neg_exp = false;
  144|  16.0k|            if ((p != pend) && (UC('-') == *p)) {
  ------------------
  |  Branch (144:17): [True: 16.0k, False: 16]
  |  Branch (144:32): [True: 8.15k, False: 7.88k]
  ------------------
  145|  8.15k|               neg_exp = true;
  146|  8.15k|               ++p;
  147|  8.15k|            }
  148|  7.89k|            else if ((p != pend) && (UC('+') == *p)) { // '+' on exponent is allowed by C++17 20.19.3.(7.1)
  ------------------
  |  Branch (148:22): [True: 7.88k, False: 16]
  |  Branch (148:37): [True: 331, False: 7.55k]
  ------------------
  149|    331|               ++p;
  150|    331|            }
  151|  16.0k|            if ((p == pend) || (digit = glz::fast_float::digit_value(*p)) > 9) {
  ------------------
  |  Branch (151:17): [True: 30, False: 16.0k]
  |  Branch (151:32): [True: 17, False: 16.0k]
  ------------------
  152|       |               // Otherwise, we will be ignoring the 'e'.
  153|     47|               p = location_of_e;
  154|     47|            }
  155|  16.0k|            else {
  156|  43.0k|               do {
  157|  43.0k|                  if (exp_number < 0x10000000) {
  ------------------
  |  Branch (157:23): [True: 42.4k, False: 567]
  ------------------
  158|  42.4k|                     exp_number = 10 * exp_number + digit;
  159|  42.4k|                  }
  160|  43.0k|                  ++p;
  161|  43.0k|               } while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9);
  ------------------
  |  Branch (161:25): [True: 41.8k, False: 1.18k]
  |  Branch (161:40): [True: 26.9k, False: 14.8k]
  ------------------
  162|  16.0k|               if (neg_exp) {
  ------------------
  |  Branch (162:20): [True: 8.15k, False: 7.85k]
  ------------------
  163|  8.15k|                  exp_number = -exp_number;
  164|  8.15k|               }
  165|  16.0k|               exponent += exp_number;
  166|  16.0k|            }
  167|  16.0k|         }
  168|  1.95M|      }
  169|       |
  170|  1.95M|      answer.lastmatch = p;
  171|  1.95M|      answer.valid = true;
  172|       |
  173|       |      // If we frequently had to deal with long strings of digits,
  174|       |      // we could extend our code by using a 128-bit integer instead
  175|       |      // of a 64-bit integer. However, this is uncommon.
  176|       |      //
  177|       |      // We can deal with up to 19 digits.
  178|  1.95M|      if (digit_count > 19) { // this is uncommon
  ------------------
  |  Branch (178:11): [True: 23.6k, False: 1.92M]
  ------------------
  179|       |         // It is possible that the integer had an overflow.
  180|       |         // We have to handle the case where we have 0.0000somenumber.
  181|       |         // We need to be mindful of the case where we only have zeroes...
  182|       |         // E.g., 0.000000000...000.
  183|  23.6k|         UC const* start = start_digits;
  184|       |         if constexpr (null_terminated) {
  185|       |            while ((*start == UC('0') || *start == decimal_point)) {
  186|       |               if (*start == UC('0')) {
  187|       |                  --digit_count;
  188|       |               }
  189|       |               ++start;
  190|       |            }
  191|       |         }
  192|  23.6k|         else {
  193|  1.34M|            while ((start != pend) && (*start == UC('0') || *start == decimal_point)) {
  ------------------
  |  Branch (193:20): [True: 1.34M, False: 26]
  |  Branch (193:40): [True: 1.31M, False: 30.6k]
  |  Branch (193:61): [True: 6.98k, False: 23.6k]
  ------------------
  194|  1.32M|               if (*start == UC('0')) {
  ------------------
  |  Branch (194:20): [True: 1.31M, False: 6.98k]
  ------------------
  195|  1.31M|                  --digit_count;
  196|  1.31M|               }
  197|  1.32M|               ++start;
  198|  1.32M|            }
  199|  23.6k|         }
  200|       |
  201|  23.6k|         if (digit_count > 19) {
  ------------------
  |  Branch (201:14): [True: 23.3k, False: 317]
  ------------------
  202|  23.3k|            answer.too_many_digits = true;
  203|       |            // Let us start again, this time, avoiding overflows.
  204|       |            // We don't need to check if is_integer, since we use the
  205|       |            // pre-tokenized spans from above.
  206|  23.3k|            i = 0;
  207|  23.3k|            p = answer.integer.ptr;
  208|  23.3k|            UC const* int_end = p + answer.integer.len();
  209|  23.3k|            const uint64_t minimal_nineteen_digit_integer{1000000000000000000};
  210|   374k|            while ((i < minimal_nineteen_digit_integer) && (p != int_end)) {
  ------------------
  |  Branch (210:20): [True: 359k, False: 15.6k]
  |  Branch (210:60): [True: 351k, False: 7.66k]
  ------------------
  211|   351k|               i = i * 10 + uint64_t(*p - UC('0'));
  212|   351k|               ++p;
  213|   351k|            }
  214|  23.3k|            if (i >= minimal_nineteen_digit_integer) { // We have a big integers
  ------------------
  |  Branch (214:17): [True: 15.6k, False: 7.66k]
  ------------------
  215|  15.6k|               exponent = end_of_integer_part - p + exp_number;
  216|  15.6k|            }
  217|  7.66k|            else { // We have a value with a fractional component.
  218|  7.66k|               p = answer.fraction.ptr;
  219|  7.66k|               UC const* frac_end = p + answer.fraction.len();
  220|   106k|               while ((i < minimal_nineteen_digit_integer) && (p != frac_end)) {
  ------------------
  |  Branch (220:23): [True: 99.3k, False: 7.66k]
  |  Branch (220:63): [True: 99.3k, False: 0]
  ------------------
  221|  99.3k|                  i = i * 10 + uint64_t(*p - UC('0'));
  222|  99.3k|                  ++p;
  223|  99.3k|               }
  224|  7.66k|               exponent = answer.fraction.ptr - p + exp_number;
  225|  7.66k|            }
  226|       |            // We have now corrected both exponent and i, to a truncated value
  227|  23.3k|         }
  228|  23.6k|      }
  229|  1.95M|      answer.exponent = exponent;
  230|  1.95M|      answer.mantissa = i;
  231|  1.95M|      return answer;
  232|  1.95M|   }
_ZZN3glz19parse_number_stringILb0EcEENS_10fast_float22parsed_number_string_tIT0_EEPKS3_S6_ENKUlvE_clEv:
   71|  1.95M|      const bool has_decimal_point = [&] {
   72|       |         if constexpr (null_terminated) {
   73|       |            return (*p == decimal_point);
   74|       |         }
   75|  1.95M|         else {
   76|  1.95M|            return (p != pend) && (*p == decimal_point);
  ------------------
  |  Branch (76:20): [True: 1.95M, False: 805]
  |  Branch (76:35): [True: 15.7k, False: 1.93M]
  ------------------
   77|  1.95M|         }
   78|  1.95M|      }();
_ZN3glz10from_charsILb1EdcEENS_10fast_float19from_chars_result_tIT1_EEPKS3_S6_RT0_:
  236|  3.90M|   {
  237|  3.90M|      using namespace glz::fast_float;
  238|  3.90M|      static_assert(is_supported_float_type<T>(), "only some floating-point types are supported");
  239|  3.90M|      static_assert(is_supported_char_type<UC>(), "only char, wchar_t, char16_t and char32_t are supported");
  240|       |
  241|  3.90M|      parsed_number_string_t<UC> pns = glz::parse_number_string<null_terminated, UC>(first, last);
  242|  3.90M|      if (!pns.valid) [[unlikely]] {
  ------------------
  |  Branch (242:11): [True: 2.68k, False: 3.90M]
  ------------------
  243|  2.68k|         return {.ptr = first, .ec = std::errc::invalid_argument};
  244|  2.68k|      }
  245|       |
  246|  3.90M|      return from_chars_advanced(pns, value);
  247|  3.90M|   }
_ZN3glz19parse_number_stringILb1EcEENS_10fast_float22parsed_number_string_tIT0_EEPKS3_S6_:
   18|  3.90M|   {
   19|  3.90M|      using namespace glz::fast_float;
   20|  3.90M|      static constexpr UC decimal_point = '.';
   21|       |
   22|  3.90M|      parsed_number_string_t<UC> answer;
   23|  3.90M|      answer.valid = false;
   24|  3.90M|      answer.too_many_digits = false;
   25|  3.90M|      answer.negative = (*p == UC('-'));
   26|  3.90M|      if (*p == UC('-')) { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here
  ------------------
  |  Branch (26:11): [True: 8.76k, False: 3.89M]
  ------------------
   27|  8.76k|         ++p;
   28|       |
   29|       |         if constexpr (not null_terminated) {
   30|       |            if (p == pend) [[unlikely]] {
   31|       |               return answer;
   32|       |            }
   33|       |         }
   34|       |
   35|  8.76k|         if (!glz::fast_float::is_integer(*p)) [[unlikely]] { // a sign must be followed by an integer
  ------------------
  |  Branch (35:14): [True: 50, False: 8.71k]
  ------------------
   36|     50|            return answer;
   37|     50|         }
   38|  8.76k|      }
   39|  3.90M|      UC const* const start_digits = p;
   40|       |
   41|  3.90M|      uint64_t i = 0; // an unsigned int avoids signed overflows (which are bad)
   42|       |
   43|  3.90M|      uint64_t digit;
   44|  3.90M|      if constexpr (null_terminated) {
   45|  23.5M|         while ((digit = glz::fast_float::digit_value(*p)) <= 9) {
  ------------------
  |  Branch (45:17): [True: 19.5M, False: 3.90M]
  ------------------
   46|       |            // a multiplication by 10 is cheaper than an arbitrary integer
   47|       |            // multiplication
   48|  19.5M|            i = 10 * i + digit; // might overflow, we will handle the overflow later
   49|  19.5M|            ++p;
   50|  19.5M|         }
   51|       |      }
   52|       |      else {
   53|       |         while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9) {
   54|       |            // a multiplication by 10 is cheaper than an arbitrary integer
   55|       |            // multiplication
   56|       |            i = 10 * i + digit; // might overflow, we will handle the overflow later
   57|       |            ++p;
   58|       |         }
   59|       |      }
   60|       |
   61|  3.90M|      UC const* const end_of_integer_part = p;
   62|  3.90M|      int64_t digit_count = int64_t(end_of_integer_part - start_digits);
   63|  3.90M|      answer.integer = glz::fast_float::span<const UC>(start_digits, size_t(digit_count));
   64|       |
   65|       |      // at least 1 digit in integer part, without leading zeros
   66|  3.90M|      if (digit_count == 0 || (start_digits[0] == UC('0') && digit_count > 1)) {
  ------------------
  |  Branch (66:11): [True: 2.42k, False: 3.90M]
  |  Branch (66:32): [True: 1.72M, False: 2.17M]
  |  Branch (66:62): [True: 152, False: 1.72M]
  ------------------
   67|  2.57k|         return answer;
   68|  2.57k|      }
   69|       |
   70|  3.90M|      int64_t exponent = 0;
   71|  3.90M|      const bool has_decimal_point = [&] {
   72|  3.90M|         if constexpr (null_terminated) {
   73|  3.90M|            return (*p == decimal_point);
   74|  3.90M|         }
   75|  3.90M|         else {
   76|  3.90M|            return (p != pend) && (*p == decimal_point);
   77|  3.90M|         }
   78|  3.90M|      }();
   79|  3.90M|      if (has_decimal_point) {
  ------------------
  |  Branch (79:11): [True: 31.4k, False: 3.87M]
  ------------------
   80|  31.4k|         ++p;
   81|  31.4k|         UC const* before = p;
   82|       |         // can occur at most twice without overflowing, but let it occur more, since
   83|       |         // for integers with many digits, digit parsing is the primary bottleneck.
   84|  31.4k|         loop_parse_if_eight_digits(p, pend, i);
   85|       |
   86|  31.4k|         if constexpr (null_terminated) {
   87|   122k|            while ((digit = glz::fast_float::digit_value(*p)) <= 9) {
  ------------------
  |  Branch (87:20): [True: 90.8k, False: 31.4k]
  ------------------
   88|  90.8k|               ++p;
   89|  90.8k|               i = i * 10 + digit; // in rare cases, this will overflow, but that's ok
   90|  90.8k|            }
   91|       |         }
   92|       |         else {
   93|       |            while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9) {
   94|       |               ++p;
   95|       |               i = i * 10 + digit; // in rare cases, this will overflow, but that's ok
   96|       |            }
   97|       |         }
   98|  31.4k|         exponent = before - p;
   99|  31.4k|         answer.fraction = glz::fast_float::span<const UC>(before, size_t(p - before));
  100|  31.4k|         digit_count -= exponent;
  101|  31.4k|      }
  102|       |      // at least 1 digit in fractional part
  103|  3.90M|      if (has_decimal_point && exponent == 0) {
  ------------------
  |  Branch (103:11): [True: 31.4k, False: 3.87M]
  |  Branch (103:32): [True: 56, False: 31.3k]
  ------------------
  104|     56|         return answer;
  105|     56|      }
  106|       |
  107|  3.90M|      int64_t exp_number = 0; // explicit exponential part
  108|       |
  109|  3.90M|      if constexpr (null_terminated) {
  110|  3.90M|         if ((UC('e') == *p) || (UC('E') == *p)) {
  ------------------
  |  Branch (110:14): [True: 15.0k, False: 3.89M]
  |  Branch (110:33): [True: 17.0k, False: 3.87M]
  ------------------
  111|  32.1k|            UC const* location_of_e = p;
  112|  32.1k|            ++p;
  113|  32.1k|            bool neg_exp = false;
  114|  32.1k|            if (UC('-') == *p) {
  ------------------
  |  Branch (114:17): [True: 16.3k, False: 15.7k]
  ------------------
  115|  16.3k|               neg_exp = true;
  116|  16.3k|               ++p;
  117|  16.3k|            }
  118|  15.7k|            else if (UC('+') == *p) { // '+' on exponent is allowed by C++17 20.19.3.(7.1)
  ------------------
  |  Branch (118:22): [True: 662, False: 15.1k]
  ------------------
  119|    662|               ++p;
  120|    662|            }
  121|  32.1k|            if ((digit = glz::fast_float::digit_value(*p)) > 9) {
  ------------------
  |  Branch (121:17): [True: 94, False: 32.0k]
  ------------------
  122|       |               // Otherwise, we will be ignoring the 'e'.
  123|     94|               p = location_of_e;
  124|     94|            }
  125|  32.0k|            else {
  126|  86.0k|               do {
  127|  86.0k|                  if (exp_number < 0x10000000) {
  ------------------
  |  Branch (127:23): [True: 84.8k, False: 1.13k]
  ------------------
  128|  84.8k|                     exp_number = 10 * exp_number + digit;
  129|  84.8k|                  }
  130|  86.0k|                  ++p;
  131|  86.0k|               } while ((digit = glz::fast_float::digit_value(*p)) <= 9);
  ------------------
  |  Branch (131:25): [True: 53.9k, False: 32.0k]
  ------------------
  132|  32.0k|               if (neg_exp) {
  ------------------
  |  Branch (132:20): [True: 16.3k, False: 15.7k]
  ------------------
  133|  16.3k|                  exp_number = -exp_number;
  134|  16.3k|               }
  135|  32.0k|               exponent += exp_number;
  136|  32.0k|            }
  137|  32.1k|         }
  138|       |      }
  139|       |      else {
  140|       |         if ((p != pend) && ((UC('e') == *p) || (UC('E') == *p))) {
  141|       |            UC const* location_of_e = p;
  142|       |            ++p;
  143|       |            bool neg_exp = false;
  144|       |            if ((p != pend) && (UC('-') == *p)) {
  145|       |               neg_exp = true;
  146|       |               ++p;
  147|       |            }
  148|       |            else if ((p != pend) && (UC('+') == *p)) { // '+' on exponent is allowed by C++17 20.19.3.(7.1)
  149|       |               ++p;
  150|       |            }
  151|       |            if ((p == pend) || (digit = glz::fast_float::digit_value(*p)) > 9) {
  152|       |               // Otherwise, we will be ignoring the 'e'.
  153|       |               p = location_of_e;
  154|       |            }
  155|       |            else {
  156|       |               do {
  157|       |                  if (exp_number < 0x10000000) {
  158|       |                     exp_number = 10 * exp_number + digit;
  159|       |                  }
  160|       |                  ++p;
  161|       |               } while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9);
  162|       |               if (neg_exp) {
  163|       |                  exp_number = -exp_number;
  164|       |               }
  165|       |               exponent += exp_number;
  166|       |            }
  167|       |         }
  168|       |      }
  169|       |
  170|  3.90M|      answer.lastmatch = p;
  171|  3.90M|      answer.valid = true;
  172|       |
  173|       |      // If we frequently had to deal with long strings of digits,
  174|       |      // we could extend our code by using a 128-bit integer instead
  175|       |      // of a 64-bit integer. However, this is uncommon.
  176|       |      //
  177|       |      // We can deal with up to 19 digits.
  178|  3.90M|      if (digit_count > 19) { // this is uncommon
  ------------------
  |  Branch (178:11): [True: 47.3k, False: 3.85M]
  ------------------
  179|       |         // It is possible that the integer had an overflow.
  180|       |         // We have to handle the case where we have 0.0000somenumber.
  181|       |         // We need to be mindful of the case where we only have zeroes...
  182|       |         // E.g., 0.000000000...000.
  183|  47.3k|         UC const* start = start_digits;
  184|  47.3k|         if constexpr (null_terminated) {
  185|  2.68M|            while ((*start == UC('0') || *start == decimal_point)) {
  ------------------
  |  Branch (185:21): [True: 2.62M, False: 61.3k]
  |  Branch (185:42): [True: 13.9k, False: 47.3k]
  ------------------
  186|  2.64M|               if (*start == UC('0')) {
  ------------------
  |  Branch (186:20): [True: 2.62M, False: 13.9k]
  ------------------
  187|  2.62M|                  --digit_count;
  188|  2.62M|               }
  189|  2.64M|               ++start;
  190|  2.64M|            }
  191|       |         }
  192|       |         else {
  193|       |            while ((start != pend) && (*start == UC('0') || *start == decimal_point)) {
  194|       |               if (*start == UC('0')) {
  195|       |                  --digit_count;
  196|       |               }
  197|       |               ++start;
  198|       |            }
  199|       |         }
  200|       |
  201|  47.3k|         if (digit_count > 19) {
  ------------------
  |  Branch (201:14): [True: 46.7k, False: 634]
  ------------------
  202|  46.7k|            answer.too_many_digits = true;
  203|       |            // Let us start again, this time, avoiding overflows.
  204|       |            // We don't need to check if is_integer, since we use the
  205|       |            // pre-tokenized spans from above.
  206|  46.7k|            i = 0;
  207|  46.7k|            p = answer.integer.ptr;
  208|  46.7k|            UC const* int_end = p + answer.integer.len();
  209|  46.7k|            const uint64_t minimal_nineteen_digit_integer{1000000000000000000};
  210|   749k|            while ((i < minimal_nineteen_digit_integer) && (p != int_end)) {
  ------------------
  |  Branch (210:20): [True: 718k, False: 31.3k]
  |  Branch (210:60): [True: 702k, False: 15.3k]
  ------------------
  211|   702k|               i = i * 10 + uint64_t(*p - UC('0'));
  212|   702k|               ++p;
  213|   702k|            }
  214|  46.7k|            if (i >= minimal_nineteen_digit_integer) { // We have a big integers
  ------------------
  |  Branch (214:17): [True: 31.3k, False: 15.3k]
  ------------------
  215|  31.3k|               exponent = end_of_integer_part - p + exp_number;
  216|  31.3k|            }
  217|  15.3k|            else { // We have a value with a fractional component.
  218|  15.3k|               p = answer.fraction.ptr;
  219|  15.3k|               UC const* frac_end = p + answer.fraction.len();
  220|   213k|               while ((i < minimal_nineteen_digit_integer) && (p != frac_end)) {
  ------------------
  |  Branch (220:23): [True: 198k, False: 15.3k]
  |  Branch (220:63): [True: 198k, False: 0]
  ------------------
  221|   198k|                  i = i * 10 + uint64_t(*p - UC('0'));
  222|   198k|                  ++p;
  223|   198k|               }
  224|  15.3k|               exponent = answer.fraction.ptr - p + exp_number;
  225|  15.3k|            }
  226|       |            // We have now corrected both exponent and i, to a truncated value
  227|  46.7k|         }
  228|  47.3k|      }
  229|  3.90M|      answer.exponent = exponent;
  230|  3.90M|      answer.mantissa = i;
  231|  3.90M|      return answer;
  232|  3.90M|   }
_ZZN3glz19parse_number_stringILb1EcEENS_10fast_float22parsed_number_string_tIT0_EEPKS3_S6_ENKUlvE_clEv:
   71|  3.90M|      const bool has_decimal_point = [&] {
   72|  3.90M|         if constexpr (null_terminated) {
   73|  3.90M|            return (*p == decimal_point);
   74|       |         }
   75|       |         else {
   76|       |            return (p != pend) && (*p == decimal_point);
   77|       |         }
   78|  3.90M|      }();

_ZN3glz7skip_wsIXtlNS_7ws_optsEEETkNS_10is_contextERNS_7contextERPKcS5_EEbOT0_OT1_T2_:
  622|  7.78M|   {
  623|  7.78M|      using namespace glz::detail;
  624|       |
  625|  7.78M|      if constexpr (not Opts.minified) {
  626|       |         if constexpr (Opts.null_terminated) {
  627|       |            if constexpr (Opts.comments) {
  628|       |               while (whitespace_comment_table[uint8_t(*it)]) {
  629|       |                  if (*it == '/') [[unlikely]] {
  630|       |                     skip_comment(ctx, it, end);
  631|       |                     if (bool(ctx.error)) [[unlikely]] {
  632|       |                        return true;
  633|       |                     }
  634|       |                  }
  635|       |                  else [[likely]] {
  636|       |                     ++it;
  637|       |                  }
  638|       |               }
  639|       |            }
  640|       |            else {
  641|       |               while (whitespace_table[uint8_t(*it)]) {
  642|       |                  ++it;
  643|       |               }
  644|       |            }
  645|       |         }
  646|  7.78M|         else {
  647|       |            if constexpr (Opts.comments) {
  648|       |               while (it < end && whitespace_comment_table[uint8_t(*it)]) {
  649|       |                  if (*it == '/') [[unlikely]] {
  650|       |                     skip_comment(ctx, it, end);
  651|       |                     if (bool(ctx.error)) [[unlikely]] {
  652|       |                        return true;
  653|       |                     }
  654|       |                  }
  655|       |                  else [[likely]] {
  656|       |                     ++it;
  657|       |                  }
  658|       |               }
  659|       |               if (it == end) [[unlikely]] {
  660|       |                  ctx.error = error_code::end_reached;
  661|       |                  return true;
  662|       |               }
  663|       |            }
  664|  7.78M|            else {
  665|  25.5M|               while (it < end && whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (665:23): [True: 25.5M, False: 1.45k]
  |  Branch (665:35): [True: 17.7M, False: 7.78M]
  ------------------
  666|  17.7M|                  ++it;
  667|  17.7M|               }
  668|  7.78M|               if (it == end) [[unlikely]] {
  ------------------
  |  Branch (668:20): [True: 1.45k, False: 7.78M]
  ------------------
  669|  1.45k|                  ctx.error = error_code::end_reached;
  670|  1.45k|                  return true;
  671|  1.45k|               }
  672|  7.78M|            }
  673|  7.78M|         }
  674|       |      }
  675|       |      else if constexpr (not Opts.null_terminated) {
  676|       |         // Minified input has no whitespace to skip, but a non-null-terminated buffer can still
  677|       |         // be exhausted at this point. The non-minified branch above performs the same check; a
  678|       |         // null-terminated buffer relies on the trailing sentinel and keeps this a pure no-op.
  679|       |         if (it == end) [[unlikely]] {
  680|       |            ctx.error = error_code::end_reached;
  681|       |            return true;
  682|       |         }
  683|       |      }
  684|       |
  685|  7.78M|      return false;
  686|  7.78M|   }
_ZN3glz17match_invalid_endILc44EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|   847k|   {
  412|   847k|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 356, False: 847k]
  ------------------
  413|       |         if constexpr (C == '"') {
  414|       |            ctx.error = error_code::expected_quote;
  415|       |         }
  416|    356|         else if constexpr (C == ',') {
  417|    356|            ctx.error = error_code::expected_comma;
  418|       |         }
  419|       |         else if constexpr (C == ':') {
  420|       |            ctx.error = error_code::expected_colon;
  421|       |         }
  422|       |         else if constexpr (C == '[' || C == ']') {
  423|       |            ctx.error = error_code::expected_bracket;
  424|       |         }
  425|       |         else if constexpr (C == '{' || C == '}') {
  426|       |            ctx.error = error_code::expected_brace;
  427|       |         }
  428|       |         else {
  429|       |            ctx.error = error_code::syntax_error;
  430|       |         }
  431|    356|         return true;
  432|    356|      }
  433|   847k|      else [[likely]] {
  434|   847k|         ++it;
  435|   847k|      }
  436|   847k|      if constexpr (not Opts.null_terminated) {
  437|   847k|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (437:14): [True: 40, False: 847k]
  ------------------
  438|     40|            ctx.error = error_code::unexpected_end;
  439|     40|            return true;
  440|     40|         }
  441|   847k|      }
  442|   847k|      return false;
  443|   847k|   }
_ZN3glz17match_invalid_endILc34EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|   877k|   {
  412|   877k|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 260, False: 876k]
  ------------------
  413|    260|         if constexpr (C == '"') {
  414|    260|            ctx.error = error_code::expected_quote;
  415|       |         }
  416|       |         else if constexpr (C == ',') {
  417|       |            ctx.error = error_code::expected_comma;
  418|       |         }
  419|       |         else if constexpr (C == ':') {
  420|       |            ctx.error = error_code::expected_colon;
  421|       |         }
  422|       |         else if constexpr (C == '[' || C == ']') {
  423|       |            ctx.error = error_code::expected_bracket;
  424|       |         }
  425|       |         else if constexpr (C == '{' || C == '}') {
  426|       |            ctx.error = error_code::expected_brace;
  427|       |         }
  428|       |         else {
  429|       |            ctx.error = error_code::syntax_error;
  430|       |         }
  431|    260|         return true;
  432|    260|      }
  433|   876k|      else [[likely]] {
  434|   876k|         ++it;
  435|   876k|      }
  436|   876k|      if constexpr (not Opts.null_terminated) {
  437|   876k|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (437:14): [True: 104, False: 876k]
  ------------------
  438|    104|            ctx.error = error_code::unexpected_end;
  439|    104|            return true;
  440|    104|         }
  441|   876k|      }
  442|   876k|      return false;
  443|   877k|   }
_ZN3glz9has_quoteEm:
  534|  17.7M|   {
  535|  17.7M|      return has_zero(chunk ^ repeat_byte8('"'));
  536|  17.7M|   }
_ZN3glz8has_zeroEm:
  529|  17.7M|   {
  530|  17.7M|      return (((chunk - 0x0101010101010101u) & ~chunk) & 0x8080808080808080u);
  531|  17.7M|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  832|   869k|   {
  833|       |      if constexpr (not check_validate_utf8(Opts)) {
  834|       |         // Everything the caller computed for us is dead, which lets its scan loop drop the
  835|       |         // accumulator entirely.
  836|       |         (void)ctx, (void)start, (void)fin, (void)ascii_acc;
  837|       |         return false;
  838|       |      }
  839|   869k|      else {
  840|   869k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (840:14): [True: 849k, False: 20.1k]
  ------------------
  841|   849k|            return false; // pure ASCII is trivially well formed UTF-8
  842|   849k|         }
  843|  20.1k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (843:14): [True: 263, False: 19.8k]
  ------------------
  844|    263|            ctx.error = error_code::invalid_utf8;
  845|    263|            return true;
  846|    263|         }
  847|  19.8k|         return false;
  848|  20.1k|      }
  849|   869k|   }
_ZN3glz13validate_utf8IcEEbPKT_m:
  801|  65.0k|   {
  802|  65.0k|      const uint8_t* it = reinterpret_cast<const uint8_t*>(str);
  803|  65.0k|      const uint8_t* const end = it + size;
  804|       |#if defined(GLZ_UTF8_SIMD)
  805|       |      // 16 is a measured compromise, not a register-size coincidence. The scalar path skips ASCII 8
  806|       |      // bytes at a time, so on ASCII it stays ahead of the vector path's fixed setup cost until the
  807|       |      // input is long enough for the 64 byte ASCII step to engage; on non-ASCII the vector path
  808|       |      // wins from roughly 8 bytes. Raising the threshold buys a few percent on short ASCII and
  809|       |      // costs up to 2.3x on mid length non-ASCII strings, so it stays low.
  810|       |      if (size >= 16) {
  811|       |         return detail::utf8_simd::validate(it, end);
  812|       |      }
  813|       |#endif
  814|  65.0k|      return validate_utf8_scalar(it, end);
  815|  65.0k|   }
_ZN3glz20validate_utf8_scalarEPKhS1_:
  752|  65.0k|   {
  753|  1.54M|      while (it < end) {
  ------------------
  |  Branch (753:14): [True: 1.48M, False: 63.4k]
  ------------------
  754|       |         // Optimistic SWAR check for ASCII
  755|  1.48M|         if (it + 8 <= end) {
  ------------------
  |  Branch (755:14): [True: 1.33M, False: 144k]
  ------------------
  756|  1.33M|            uint64_t chunk;
  757|  1.33M|            std::memcpy(&chunk, it, 8);
  758|  1.33M|            if ((chunk & glz::repeat_byte8(0x80)) == 0) {
  ------------------
  |  Branch (758:17): [True: 1.26M, False: 71.3k]
  ------------------
  759|  1.26M|               it += 8;
  760|  1.26M|               continue;
  761|  1.26M|            }
  762|  1.33M|         }
  763|       |
  764|       |         // Byte-by-byte validation (standard conformant)
  765|   215k|         uint8_t byte = *it;
  766|       |
  767|   215k|         if (byte < 0x80) {
  ------------------
  |  Branch (767:14): [True: 157k, False: 58.5k]
  ------------------
  768|   157k|            it++;
  769|   157k|         }
  770|  58.5k|         else if ((byte & 0xE0) == 0xC0) {
  ------------------
  |  Branch (770:19): [True: 47.4k, False: 11.1k]
  ------------------
  771|       |            // 2-byte sequence
  772|  47.4k|            if (it + 2 > end || (it[1] & 0xC0) != 0x80) return false;
  ------------------
  |  Branch (772:17): [True: 44, False: 47.3k]
  |  Branch (772:33): [True: 158, False: 47.2k]
  ------------------
  773|  47.2k|            if (byte < 0xC2) return false; // Overlong
  ------------------
  |  Branch (773:17): [True: 38, False: 47.1k]
  ------------------
  774|  47.1k|            it += 2;
  775|  47.1k|         }
  776|  11.1k|         else if ((byte & 0xF0) == 0xE0) {
  ------------------
  |  Branch (776:19): [True: 6.29k, False: 4.80k]
  ------------------
  777|       |            // 3-byte sequence
  778|  6.29k|            if (it + 3 > end || (it[1] & 0xC0) != 0x80 || (it[2] & 0xC0) != 0x80) return false;
  ------------------
  |  Branch (778:17): [True: 45, False: 6.25k]
  |  Branch (778:33): [True: 90, False: 6.16k]
  |  Branch (778:59): [True: 92, False: 6.06k]
  ------------------
  779|  6.06k|            if (byte == 0xE0 && it[1] < 0xA0) return false; // Overlong
  ------------------
  |  Branch (779:17): [True: 1.96k, False: 4.10k]
  |  Branch (779:33): [True: 80, False: 1.88k]
  ------------------
  780|  5.98k|            if (byte == 0xED && it[1] >= 0xA0) return false; // Surrogate
  ------------------
  |  Branch (780:17): [True: 1.59k, False: 4.39k]
  |  Branch (780:33): [True: 41, False: 1.55k]
  ------------------
  781|  5.94k|            it += 3;
  782|  5.94k|         }
  783|  4.80k|         else if ((byte & 0xF8) == 0xF0) {
  ------------------
  |  Branch (783:19): [True: 4.29k, False: 509]
  ------------------
  784|       |            // 4-byte sequence
  785|  4.29k|            if (it + 4 > end || (it[1] & 0xC0) != 0x80 || (it[2] & 0xC0) != 0x80 || (it[3] & 0xC0) != 0x80)
  ------------------
  |  Branch (785:17): [True: 42, False: 4.25k]
  |  Branch (785:33): [True: 75, False: 4.18k]
  |  Branch (785:59): [True: 76, False: 4.10k]
  |  Branch (785:85): [True: 71, False: 4.03k]
  ------------------
  786|    264|               return false;
  787|  4.03k|            if (byte == 0xF0 && it[1] < 0x90) return false; // Overlong
  ------------------
  |  Branch (787:17): [True: 1.44k, False: 2.58k]
  |  Branch (787:33): [True: 77, False: 1.36k]
  ------------------
  788|  3.95k|            if (byte == 0xF4 && it[1] >= 0x90) return false; // > U+10FFFF
  ------------------
  |  Branch (788:17): [True: 1.64k, False: 2.31k]
  |  Branch (788:33): [True: 42, False: 1.60k]
  ------------------
  789|  3.91k|            if (byte > 0xF4) return false; // > U+10FFFF
  ------------------
  |  Branch (789:17): [True: 39, False: 3.87k]
  ------------------
  790|  3.87k|            it += 4;
  791|  3.87k|         }
  792|    509|         else {
  793|    509|            return false;
  794|    509|         }
  795|   215k|      }
  796|       |
  797|  63.4k|      return true;
  798|  65.0k|   }
_ZN3glz25handle_unicode_code_pointIccEEjRPKT_RPT0_S3_:
  288|  41.5k|   {
  289|  41.5k|      using namespace unicode;
  290|       |
  291|  41.5k|      if (it + 4 >= end) [[unlikely]] {
  ------------------
  |  Branch (291:11): [True: 127, False: 41.4k]
  ------------------
  292|    127|         return false;
  293|    127|      }
  294|  41.4k|      const uint32_t high = hex_to_u32(it);
  295|  41.4k|      if (high == 0xFFFFFFFFu) [[unlikely]] {
  ------------------
  |  Branch (295:11): [True: 192, False: 41.2k]
  ------------------
  296|    192|         return false;
  297|    192|      }
  298|  41.2k|      it += 4; // skip the code point characters
  299|       |
  300|  41.2k|      uint32_t code_point;
  301|       |
  302|  41.2k|      if ((high & generic_surrogate_mask) == generic_surrogate_value) {
  ------------------
  |  Branch (302:11): [True: 3.48k, False: 37.7k]
  ------------------
  303|       |         // surrogate pair code points
  304|  3.48k|         if ((high & surrogate_mask) != high_surrogate_value) {
  ------------------
  |  Branch (304:14): [True: 27, False: 3.46k]
  ------------------
  305|     27|            return false;
  306|     27|         }
  307|       |
  308|  3.46k|         if (it + 6 >= end) [[unlikely]] {
  ------------------
  |  Branch (308:14): [True: 58, False: 3.40k]
  ------------------
  309|     58|            return false;
  310|     58|         }
  311|       |         // The next two characters must be `\u`
  312|  3.40k|         uint16_t u;
  313|  3.40k|         std::memcpy(&u, it, 2);
  314|  3.40k|         if (u != to_uint16_t(R"(\u)")) [[unlikely]] {
  ------------------
  |  Branch (314:14): [True: 327, False: 3.07k]
  ------------------
  315|    327|            return false;
  316|    327|         }
  317|  3.07k|         it += 2;
  318|       |         // verify that second unicode escape sequence is present
  319|  3.07k|         const uint32_t low = hex_to_u32(it);
  320|  3.07k|         if (low == 0xFFFFFFFFu) [[unlikely]] {
  ------------------
  |  Branch (320:14): [True: 73, False: 3.00k]
  ------------------
  321|     73|            return false;
  322|     73|         }
  323|  3.00k|         it += 4;
  324|       |
  325|  3.00k|         if ((low & surrogate_mask) != low_surrogate_value) [[unlikely]] {
  ------------------
  |  Branch (325:14): [True: 171, False: 2.83k]
  ------------------
  326|    171|            return false;
  327|    171|         }
  328|       |
  329|  2.83k|         code_point = (high & surrogate_codepoint_mask) << surrogate_codepoint_bits;
  330|  2.83k|         code_point |= (low & surrogate_codepoint_mask);
  331|  2.83k|         code_point += surrogate_codepoint_offset;
  332|  2.83k|      }
  333|  37.7k|      else {
  334|  37.7k|         code_point = high;
  335|  37.7k|      }
  336|  40.6k|      const uint32_t offset = code_point_to_utf8(code_point, dst);
  337|  40.6k|      dst += offset;
  338|  40.6k|      return offset;
  339|  41.2k|   }
_ZN3glz10hex_to_u32EPKc:
  203|  44.5k|   {
  204|  44.5k|      constexpr auto& t = digit_hex_table;
  205|  44.5k|      const uint8_t arr[4]{t[uint8_t(c[3])], t[uint8_t(c[2])], t[uint8_t(c[1])], t[uint8_t(c[0])]};
  206|  44.5k|      auto chunk = std::bit_cast<uint32_t>(arr);
  207|       |      // On big-endian, bit_cast produces bytes in opposite order than expected
  208|       |      // byteswap to get consistent little-endian representation
  209|       |      if constexpr (std::endian::native == std::endian::big) {
  210|       |         chunk = std::byteswap(chunk);
  211|       |      }
  212|       |      // check that all hex characters are valid
  213|  44.5k|      if (chunk & repeat_byte4(0b11110000u)) [[unlikely]] {
  ------------------
  |  Branch (213:11): [True: 265, False: 44.2k]
  ------------------
  214|    265|         return 0xFFFFFFFFu;
  215|    265|      }
  216|       |
  217|       |      // now pack into first four bytes of uint32_t
  218|  44.2k|      uint32_t packed{};
  219|  44.2k|      packed |= (chunk & 0x0000000F);
  220|  44.2k|      packed |= (chunk & 0x00000F00) >> 4;
  221|  44.2k|      packed |= (chunk & 0x000F0000) >> 8;
  222|  44.2k|      packed |= (chunk & 0x0F000000) >> 12;
  223|  44.2k|      return packed;
  224|  44.5k|   }
_ZN3glz18code_point_to_utf8IcEEjjPT_:
  228|  40.6k|   {
  229|  40.6k|      if (code_point <= 0x7F) {
  ------------------
  |  Branch (229:11): [True: 15.1k, False: 25.4k]
  ------------------
  230|  15.1k|         c[0] = Char(code_point);
  231|  15.1k|         return 1;
  232|  15.1k|      }
  233|  25.4k|      if (code_point <= 0x7FF) {
  ------------------
  |  Branch (233:11): [True: 14.6k, False: 10.7k]
  ------------------
  234|  14.6k|         c[0] = Char(0xC0 | ((code_point >> 6) & 0x1F));
  235|  14.6k|         c[1] = Char(0x80 | (code_point & 0x3F));
  236|  14.6k|         return 2;
  237|  14.6k|      }
  238|  10.7k|      if (code_point <= 0xFFFF) {
  ------------------
  |  Branch (238:11): [True: 7.89k, False: 2.83k]
  ------------------
  239|  7.89k|         c[0] = Char(0xE0 | ((code_point >> 12) & 0x0F));
  240|  7.89k|         c[1] = Char(0x80 | ((code_point >> 6) & 0x3F));
  241|  7.89k|         c[2] = Char(0x80 | (code_point & 0x3F));
  242|  7.89k|         return 3;
  243|  7.89k|      }
  244|  2.83k|      if (code_point <= 0x10FFFF) {
  ------------------
  |  Branch (244:11): [True: 2.83k, False: 0]
  ------------------
  245|  2.83k|         c[0] = Char(0xF0 | ((code_point >> 18) & 0x07));
  246|  2.83k|         c[1] = Char(0x80 | ((code_point >> 12) & 0x3F));
  247|  2.83k|         c[2] = Char(0x80 | ((code_point >> 6) & 0x3F));
  248|  2.83k|         c[3] = Char(0x80 | (code_point & 0x3F));
  249|  2.83k|         return 4;
  250|  2.83k|      }
  251|      0|      return 0;
  252|  2.83k|   }
_ZN3glz17match_invalid_endILc58EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|   869k|   {
  412|   869k|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 481, False: 868k]
  ------------------
  413|       |         if constexpr (C == '"') {
  414|       |            ctx.error = error_code::expected_quote;
  415|       |         }
  416|       |         else if constexpr (C == ',') {
  417|       |            ctx.error = error_code::expected_comma;
  418|       |         }
  419|    481|         else if constexpr (C == ':') {
  420|    481|            ctx.error = error_code::expected_colon;
  421|       |         }
  422|       |         else if constexpr (C == '[' || C == ']') {
  423|       |            ctx.error = error_code::expected_bracket;
  424|       |         }
  425|       |         else if constexpr (C == '{' || C == '}') {
  426|       |            ctx.error = error_code::expected_brace;
  427|       |         }
  428|       |         else {
  429|       |            ctx.error = error_code::syntax_error;
  430|       |         }
  431|    481|         return true;
  432|    481|      }
  433|   868k|      else [[likely]] {
  434|   868k|         ++it;
  435|   868k|      }
  436|   868k|      if constexpr (not Opts.null_terminated) {
  437|   868k|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (437:14): [True: 977, False: 867k]
  ------------------
  438|    977|            ctx.error = error_code::unexpected_end;
  439|    977|            return true;
  440|    977|         }
  441|   868k|      }
  442|   867k|      return false;
  443|   869k|   }
_ZN3glz17match_invalid_endILc91EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|   615k|   {
  412|   615k|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 0, False: 615k]
  ------------------
  413|       |         if constexpr (C == '"') {
  414|       |            ctx.error = error_code::expected_quote;
  415|       |         }
  416|       |         else if constexpr (C == ',') {
  417|       |            ctx.error = error_code::expected_comma;
  418|       |         }
  419|       |         else if constexpr (C == ':') {
  420|       |            ctx.error = error_code::expected_colon;
  421|       |         }
  422|      0|         else if constexpr (C == '[' || C == ']') {
  423|      0|            ctx.error = error_code::expected_bracket;
  424|       |         }
  425|       |         else if constexpr (C == '{' || C == '}') {
  426|       |            ctx.error = error_code::expected_brace;
  427|       |         }
  428|       |         else {
  429|       |            ctx.error = error_code::syntax_error;
  430|       |         }
  431|      0|         return true;
  432|      0|      }
  433|   615k|      else [[likely]] {
  434|   615k|         ++it;
  435|   615k|      }
  436|   615k|      if constexpr (not Opts.null_terminated) {
  437|   615k|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (437:14): [True: 110, False: 615k]
  ------------------
  438|    110|            ctx.error = error_code::unexpected_end;
  439|    110|            return true;
  440|    110|         }
  441|   615k|      }
  442|   615k|      return false;
  443|   615k|   }
_ZN3glz16skip_matching_wsIcRPKcEEvPKT_OT0_m:
  689|  56.2k|   {
  690|  56.2k|      if (length > 7) {
  ------------------
  |  Branch (690:11): [True: 11.7k, False: 44.4k]
  ------------------
  691|  11.7k|         uint64_t v[2];
  692|  16.4k|         while (length > 8) {
  ------------------
  |  Branch (692:17): [True: 9.99k, False: 6.43k]
  ------------------
  693|  9.99k|            std::memcpy(v, ws, 8);
  694|  9.99k|            std::memcpy(v + 1, it, 8);
  695|  9.99k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (695:17): [True: 5.30k, False: 4.68k]
  ------------------
  696|  5.30k|               return;
  697|  5.30k|            }
  698|  4.68k|            length -= 8;
  699|  4.68k|            ws += 8;
  700|  4.68k|            it += 8;
  701|  4.68k|         }
  702|       |
  703|  6.43k|         const auto shift = 8 - length;
  704|  6.43k|         ws -= shift;
  705|  6.43k|         it -= shift;
  706|       |
  707|  6.43k|         std::memcpy(v, ws, 8);
  708|  6.43k|         std::memcpy(v + 1, it, 8);
  709|  6.43k|         if (v[0] != v[1]) {
  ------------------
  |  Branch (709:14): [True: 4.14k, False: 2.28k]
  ------------------
  710|  4.14k|            return;
  711|  4.14k|         }
  712|  2.28k|         it += 8;
  713|  2.28k|         return;
  714|  6.43k|      }
  715|  44.4k|      {
  716|  44.4k|         constexpr uint64_t n{sizeof(uint32_t)};
  717|  44.4k|         if (length >= n) {
  ------------------
  |  Branch (717:14): [True: 25.9k, False: 18.5k]
  ------------------
  718|  25.9k|            uint32_t v[2];
  719|  25.9k|            std::memcpy(v, ws, n);
  720|  25.9k|            std::memcpy(v + 1, it, n);
  721|  25.9k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (721:17): [True: 15.6k, False: 10.2k]
  ------------------
  722|  15.6k|               return;
  723|  15.6k|            }
  724|  10.2k|            length -= n;
  725|  10.2k|            ws += n;
  726|  10.2k|            it += n;
  727|  10.2k|         }
  728|  44.4k|      }
  729|  28.8k|      {
  730|  28.8k|         constexpr uint64_t n{sizeof(uint16_t)};
  731|  28.8k|         if (length >= n) {
  ------------------
  |  Branch (731:14): [True: 7.47k, False: 21.3k]
  ------------------
  732|  7.47k|            uint16_t v[2];
  733|  7.47k|            std::memcpy(v, ws, n);
  734|  7.47k|            std::memcpy(v + 1, it, n);
  735|  7.47k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (735:17): [True: 4.04k, False: 3.42k]
  ------------------
  736|  4.04k|               return;
  737|  4.04k|            }
  738|       |            // length -= n;
  739|       |            // ws += n;
  740|  3.42k|            it += n;
  741|  3.42k|         }
  742|  28.8k|      }
  743|       |      // We have to call a whitespace check after this function
  744|       |      // in case the whitespace is mismatching.
  745|       |      // So, we forgo this check as to not duplicate.
  746|       |      /*if (length && *ws == *it) {
  747|       |         ++it;
  748|       |      }*/
  749|  28.8k|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  832|  6.01k|   {
  833|       |      if constexpr (not check_validate_utf8(Opts)) {
  834|       |         // Everything the caller computed for us is dead, which lets its scan loop drop the
  835|       |         // accumulator entirely.
  836|       |         (void)ctx, (void)start, (void)fin, (void)ascii_acc;
  837|       |         return false;
  838|       |      }
  839|  6.01k|      else {
  840|  6.01k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (840:14): [True: 3.79k, False: 2.21k]
  ------------------
  841|  3.79k|            return false; // pure ASCII is trivially well formed UTF-8
  842|  3.79k|         }
  843|  2.21k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (843:14): [True: 225, False: 1.98k]
  ------------------
  844|    225|            ctx.error = error_code::invalid_utf8;
  845|    225|            return true;
  846|    225|         }
  847|  1.98k|         return false;
  848|  2.21k|      }
  849|  6.01k|   }
_ZN3glz5matchITnNS_14string_literalEXtlNS1_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS8_Qntcl15check_is_paddedT0_EEEvOT1_OT2_T3_:
  491|    662|   {
  492|    662|      const auto n = size_t(end - it);
  493|    662|      static constexpr auto S = str.sv();
  494|    662|      if ((n < str.size()) || not comparitor<S>(it)) [[unlikely]] {
  ------------------
  |  Branch (494:11): [True: 70, False: 592]
  |  Branch (494:31): [True: 112, False: 480]
  ------------------
  495|    182|         ctx.error = error_code::syntax_error;
  496|    182|      }
  497|    480|      else [[likely]] {
  498|    480|         it += str.size();
  499|    480|      }
  500|    662|   }
_ZN3glz7skip_wsIXtlNS_7ws_optsELb0ELb1EEETkNS_10is_contextERNS_7contextERPKcS5_EEbOT0_OT1_T2_:
  622|  15.5M|   {
  623|  15.5M|      using namespace glz::detail;
  624|       |
  625|  15.5M|      if constexpr (not Opts.minified) {
  626|  15.5M|         if constexpr (Opts.null_terminated) {
  627|       |            if constexpr (Opts.comments) {
  628|       |               while (whitespace_comment_table[uint8_t(*it)]) {
  629|       |                  if (*it == '/') [[unlikely]] {
  630|       |                     skip_comment(ctx, it, end);
  631|       |                     if (bool(ctx.error)) [[unlikely]] {
  632|       |                        return true;
  633|       |                     }
  634|       |                  }
  635|       |                  else [[likely]] {
  636|       |                     ++it;
  637|       |                  }
  638|       |               }
  639|       |            }
  640|  15.5M|            else {
  641|  51.1M|               while (whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (641:23): [True: 35.5M, False: 15.5M]
  ------------------
  642|  35.5M|                  ++it;
  643|  35.5M|               }
  644|  15.5M|            }
  645|       |         }
  646|       |         else {
  647|       |            if constexpr (Opts.comments) {
  648|       |               while (it < end && whitespace_comment_table[uint8_t(*it)]) {
  649|       |                  if (*it == '/') [[unlikely]] {
  650|       |                     skip_comment(ctx, it, end);
  651|       |                     if (bool(ctx.error)) [[unlikely]] {
  652|       |                        return true;
  653|       |                     }
  654|       |                  }
  655|       |                  else [[likely]] {
  656|       |                     ++it;
  657|       |                  }
  658|       |               }
  659|       |               if (it == end) [[unlikely]] {
  660|       |                  ctx.error = error_code::end_reached;
  661|       |                  return true;
  662|       |               }
  663|       |            }
  664|       |            else {
  665|       |               while (it < end && whitespace_table[uint8_t(*it)]) {
  666|       |                  ++it;
  667|       |               }
  668|       |               if (it == end) [[unlikely]] {
  669|       |                  ctx.error = error_code::end_reached;
  670|       |                  return true;
  671|       |               }
  672|       |            }
  673|       |         }
  674|       |      }
  675|       |      else if constexpr (not Opts.null_terminated) {
  676|       |         // Minified input has no whitespace to skip, but a non-null-terminated buffer can still
  677|       |         // be exhausted at this point. The non-minified branch above performs the same check; a
  678|       |         // null-terminated buffer relies on the trailing sentinel and keeps this a pure no-op.
  679|       |         if (it == end) [[unlikely]] {
  680|       |            ctx.error = error_code::end_reached;
  681|       |            return true;
  682|       |         }
  683|       |      }
  684|       |
  685|  15.5M|      return false;
  686|  15.5M|   }
_ZN3glz17match_invalid_endILc44EXtlNS_22match_invalid_end_optsELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|  1.69M|   {
  412|  1.69M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 1.04k, False: 1.69M]
  ------------------
  413|       |         if constexpr (C == '"') {
  414|       |            ctx.error = error_code::expected_quote;
  415|       |         }
  416|  1.04k|         else if constexpr (C == ',') {
  417|  1.04k|            ctx.error = error_code::expected_comma;
  418|       |         }
  419|       |         else if constexpr (C == ':') {
  420|       |            ctx.error = error_code::expected_colon;
  421|       |         }
  422|       |         else if constexpr (C == '[' || C == ']') {
  423|       |            ctx.error = error_code::expected_bracket;
  424|       |         }
  425|       |         else if constexpr (C == '{' || C == '}') {
  426|       |            ctx.error = error_code::expected_brace;
  427|       |         }
  428|       |         else {
  429|       |            ctx.error = error_code::syntax_error;
  430|       |         }
  431|  1.04k|         return true;
  432|  1.04k|      }
  433|  1.69M|      else [[likely]] {
  434|  1.69M|         ++it;
  435|  1.69M|      }
  436|       |      if constexpr (not Opts.null_terminated) {
  437|       |         if (it == end) [[unlikely]] {
  438|       |            ctx.error = error_code::unexpected_end;
  439|       |            return true;
  440|       |         }
  441|       |      }
  442|  1.69M|      return false;
  443|  1.69M|   }
_ZN3glz17match_invalid_endILc34EXtlNS_22match_invalid_end_optsELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|  1.75M|   {
  412|  1.75M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 778, False: 1.75M]
  ------------------
  413|    778|         if constexpr (C == '"') {
  414|    778|            ctx.error = error_code::expected_quote;
  415|       |         }
  416|       |         else if constexpr (C == ',') {
  417|       |            ctx.error = error_code::expected_comma;
  418|       |         }
  419|       |         else if constexpr (C == ':') {
  420|       |            ctx.error = error_code::expected_colon;
  421|       |         }
  422|       |         else if constexpr (C == '[' || C == ']') {
  423|       |            ctx.error = error_code::expected_bracket;
  424|       |         }
  425|       |         else if constexpr (C == '{' || C == '}') {
  426|       |            ctx.error = error_code::expected_brace;
  427|       |         }
  428|       |         else {
  429|       |            ctx.error = error_code::syntax_error;
  430|       |         }
  431|    778|         return true;
  432|    778|      }
  433|  1.75M|      else [[likely]] {
  434|  1.75M|         ++it;
  435|  1.75M|      }
  436|       |      if constexpr (not Opts.null_terminated) {
  437|       |         if (it == end) [[unlikely]] {
  438|       |            ctx.error = error_code::unexpected_end;
  439|       |            return true;
  440|       |         }
  441|       |      }
  442|  1.75M|      return false;
  443|  1.75M|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  832|   869k|   {
  833|       |      if constexpr (not check_validate_utf8(Opts)) {
  834|       |         // Everything the caller computed for us is dead, which lets its scan loop drop the
  835|       |         // accumulator entirely.
  836|       |         (void)ctx, (void)start, (void)fin, (void)ascii_acc;
  837|       |         return false;
  838|       |      }
  839|   869k|      else {
  840|   869k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (840:14): [True: 849k, False: 19.9k]
  ------------------
  841|   849k|            return false; // pure ASCII is trivially well formed UTF-8
  842|   849k|         }
  843|  19.9k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (843:14): [True: 268, False: 19.6k]
  ------------------
  844|    268|            ctx.error = error_code::invalid_utf8;
  845|    268|            return true;
  846|    268|         }
  847|  19.6k|         return false;
  848|  19.9k|      }
  849|   869k|   }
_ZN3glz17match_invalid_endILc58EXtlNS_22match_invalid_end_optsELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|  1.73M|   {
  412|  1.73M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 1.52k, False: 1.73M]
  ------------------
  413|       |         if constexpr (C == '"') {
  414|       |            ctx.error = error_code::expected_quote;
  415|       |         }
  416|       |         else if constexpr (C == ',') {
  417|       |            ctx.error = error_code::expected_comma;
  418|       |         }
  419|  1.52k|         else if constexpr (C == ':') {
  420|  1.52k|            ctx.error = error_code::expected_colon;
  421|       |         }
  422|       |         else if constexpr (C == '[' || C == ']') {
  423|       |            ctx.error = error_code::expected_bracket;
  424|       |         }
  425|       |         else if constexpr (C == '{' || C == '}') {
  426|       |            ctx.error = error_code::expected_brace;
  427|       |         }
  428|       |         else {
  429|       |            ctx.error = error_code::syntax_error;
  430|       |         }
  431|  1.52k|         return true;
  432|  1.52k|      }
  433|  1.73M|      else [[likely]] {
  434|  1.73M|         ++it;
  435|  1.73M|      }
  436|       |      if constexpr (not Opts.null_terminated) {
  437|       |         if (it == end) [[unlikely]] {
  438|       |            ctx.error = error_code::unexpected_end;
  439|       |            return true;
  440|       |         }
  441|       |      }
  442|  1.73M|      return false;
  443|  1.73M|   }
_ZN3glz17match_invalid_endILc91EXtlNS_22match_invalid_end_optsELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|  1.23M|   {
  412|  1.23M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 0, False: 1.23M]
  ------------------
  413|       |         if constexpr (C == '"') {
  414|       |            ctx.error = error_code::expected_quote;
  415|       |         }
  416|       |         else if constexpr (C == ',') {
  417|       |            ctx.error = error_code::expected_comma;
  418|       |         }
  419|       |         else if constexpr (C == ':') {
  420|       |            ctx.error = error_code::expected_colon;
  421|       |         }
  422|      0|         else if constexpr (C == '[' || C == ']') {
  423|      0|            ctx.error = error_code::expected_bracket;
  424|       |         }
  425|       |         else if constexpr (C == '{' || C == '}') {
  426|       |            ctx.error = error_code::expected_brace;
  427|       |         }
  428|       |         else {
  429|       |            ctx.error = error_code::syntax_error;
  430|       |         }
  431|      0|         return true;
  432|      0|      }
  433|  1.23M|      else [[likely]] {
  434|  1.23M|         ++it;
  435|  1.23M|      }
  436|       |      if constexpr (not Opts.null_terminated) {
  437|       |         if (it == end) [[unlikely]] {
  438|       |            ctx.error = error_code::unexpected_end;
  439|       |            return true;
  440|       |         }
  441|       |      }
  442|  1.23M|      return false;
  443|  1.23M|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  832|  6.04k|   {
  833|       |      if constexpr (not check_validate_utf8(Opts)) {
  834|       |         // Everything the caller computed for us is dead, which lets its scan loop drop the
  835|       |         // accumulator entirely.
  836|       |         (void)ctx, (void)start, (void)fin, (void)ascii_acc;
  837|       |         return false;
  838|       |      }
  839|  6.04k|      else {
  840|  6.04k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (840:14): [True: 3.84k, False: 2.20k]
  ------------------
  841|  3.84k|            return false; // pure ASCII is trivially well formed UTF-8
  842|  3.84k|         }
  843|  2.20k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (843:14): [True: 244, False: 1.95k]
  ------------------
  844|    244|            ctx.error = error_code::invalid_utf8;
  845|    244|            return true;
  846|    244|         }
  847|  1.95k|         return false;
  848|  2.20k|      }
  849|  6.04k|   }
_ZN3glz5matchITnNS_14string_literalEXtlNS1_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS8_Qntcl15check_is_paddedT0_EEEvOT1_OT2_T3_:
  491|    662|   {
  492|    662|      const auto n = size_t(end - it);
  493|    662|      static constexpr auto S = str.sv();
  494|    662|      if ((n < str.size()) || not comparitor<S>(it)) [[unlikely]] {
  ------------------
  |  Branch (494:11): [True: 36, False: 626]
  |  Branch (494:31): [True: 146, False: 480]
  ------------------
  495|    182|         ctx.error = error_code::syntax_error;
  496|    182|      }
  497|    480|      else [[likely]] {
  498|    480|         it += str.size();
  499|    480|      }
  500|    662|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  832|   869k|   {
  833|       |      if constexpr (not check_validate_utf8(Opts)) {
  834|       |         // Everything the caller computed for us is dead, which lets its scan loop drop the
  835|       |         // accumulator entirely.
  836|       |         (void)ctx, (void)start, (void)fin, (void)ascii_acc;
  837|       |         return false;
  838|       |      }
  839|   869k|      else {
  840|   869k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (840:14): [True: 851k, False: 18.4k]
  ------------------
  841|   851k|            return false; // pure ASCII is trivially well formed UTF-8
  842|   851k|         }
  843|  18.4k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (843:14): [True: 270, False: 18.1k]
  ------------------
  844|    270|            ctx.error = error_code::invalid_utf8;
  845|    270|            return true;
  846|    270|         }
  847|  18.1k|         return false;
  848|  18.4k|      }
  849|   869k|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  832|  6.06k|   {
  833|       |      if constexpr (not check_validate_utf8(Opts)) {
  834|       |         // Everything the caller computed for us is dead, which lets its scan loop drop the
  835|       |         // accumulator entirely.
  836|       |         (void)ctx, (void)start, (void)fin, (void)ascii_acc;
  837|       |         return false;
  838|       |      }
  839|  6.06k|      else {
  840|  6.06k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (840:14): [True: 3.97k, False: 2.08k]
  ------------------
  841|  3.97k|            return false; // pure ASCII is trivially well formed UTF-8
  842|  3.97k|         }
  843|  2.08k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (843:14): [True: 249, False: 1.83k]
  ------------------
  844|    249|            ctx.error = error_code::invalid_utf8;
  845|    249|            return true;
  846|    249|         }
  847|  1.83k|         return false;
  848|  2.08k|      }
  849|  6.06k|   }
_ZN3glz5matchITnNS_14string_literalEXtlNS1_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEETkNS_10is_contextERNS_7contextERPKcS8_Qaacl15check_is_paddedT0_ElecldtT_4sizeEL_ZNS_13padding_bytesEEEEvOT1_OT2_T3_:
  478|    662|   {
  479|    662|      static constexpr auto S = str.sv();
  480|    662|      if (not comparitor<S>(it)) [[unlikely]] {
  ------------------
  |  Branch (480:11): [True: 182, False: 480]
  ------------------
  481|    182|         ctx.error = error_code::syntax_error;
  482|    182|      }
  483|    480|      else [[likely]] {
  484|    480|         it += str.size();
  485|    480|      }
  486|    662|   }

_ZNK3glz14string_literalILm5EE4sizeEv:
   25|  2.76k|      [[nodiscard]] constexpr size_t size() const noexcept { return length; }

