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

_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEED2Ev:
  567|   175k|      {
  568|   175k|         free_data();
  569|   175k|         free_index();
  570|   175k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE9free_dataEv:
  264|   175k|      {
  265|   175k|         destroy_all();
  266|   175k|         ::operator delete(data_);
  267|   175k|         data_ = nullptr;
  268|   175k|         size_ = 0;
  269|   175k|         capacity_ = 0;
  270|   175k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE11destroy_allEv:
  257|   438k|      {
  258|  5.36M|         for (uint32_t i = 0; i < size_; ++i) {
  ------------------
  |  Branch (258:31): [True: 4.92M, False: 438k]
  ------------------
  259|  4.92M|            std::destroy_at(data_ + i);
  260|  4.92M|         }
  261|   438k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE10free_indexEv:
  306|   175k|      {
  307|   175k|         std::free(index_);
  308|   175k|         index_ = nullptr;
  309|   175k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEC2Ev:
  564|  82.6k|      ordered_small_map() = default;
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEC2EOS4_:
  608|  92.5k|         : data_(other.data_), size_(other.size_), capacity_(other.capacity_), index_(other.index_)
  609|  92.5k|      {
  610|  92.5k|         other.data_ = nullptr;
  611|  92.5k|         other.size_ = 0;
  612|  92.5k|         other.capacity_ = 0;
  613|  92.5k|         other.index_ = nullptr;
  614|  92.5k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEixERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE:
  930|  2.80M|      {
  931|  2.80M|         return subscript_or_insert(key, [&] { emplace_back_impl(key, mapped_type{}); });
  932|  2.80M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE19subscript_or_insertINSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEZNS4_ixERKSC_EUlvE_EERS3_RKT_OT0_:
  489|  2.80M|      {
  490|  2.80M|         if (size_ <= linear_search_threshold) {
  ------------------
  |  Branch (490:14): [True: 551k, False: 2.25M]
  ------------------
  491|   551k|            auto it = linear_find(key);
  492|   551k|            if (it != end()) return it->second;
  ------------------
  |  Branch (492:17): [True: 33.7k, False: 517k]
  ------------------
  493|   517k|            append_fn();
  494|   517k|            return data_[size_ - 1].second;
  495|   551k|         }
  496|       |
  497|  2.25M|         const uint32_t h = hash_key(key);
  498|  2.25M|         if (try_bloom_insert(h, append_fn)) {
  ------------------
  |  Branch (498:14): [True: 1.43M, False: 816k]
  ------------------
  499|  1.43M|            return data_[size_ - 1].second;
  500|  1.43M|         }
  501|       |
  502|   816k|         auto [it, pos, _] = index_find_or_pos(key, h);
  503|   816k|         if (it != end()) return it->second;
  ------------------
  |  Branch (503:14): [True: 701k, False: 115k]
  ------------------
  504|       |
  505|   115k|         append_fn();
  506|   115k|         bloom_set(h);
  507|   115k|         if (index_size() > 0) {
  ------------------
  |  Branch (507:14): [True: 115k, False: 0]
  ------------------
  508|   115k|            const uint32_t n = index_->size;
  509|   115k|            ensure_index_capacity(static_cast<size_type>(n) + 1);
  510|   115k|            auto* entries = index_entries();
  511|   115k|            if (pos < n) {
  ------------------
  |  Branch (511:17): [True: 113k, False: 2.16k]
  ------------------
  512|   113k|               std::memmove(entries + pos + 1, entries + pos, (n - pos) * sizeof(hash_index_entry));
  513|   113k|            }
  514|   115k|            entries[pos] = {h, size_ - 1};
  515|   115k|            index_->size = size_;
  516|   115k|         }
  517|   115k|         return data_[size_ - 1].second;
  518|   816k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE11linear_findINSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEEEPNS6_4pairISC_S3_EERKT_:
  419|   551k|      {
  420|  2.58M|         for (uint32_t i = 0; i < size_; ++i) {
  ------------------
  |  Branch (420:31): [True: 2.06M, False: 517k]
  ------------------
  421|  2.06M|            if (data_[i].first == key) return data_ + i;
  ------------------
  |  Branch (421:17): [True: 33.7k, False: 2.03M]
  ------------------
  422|  2.06M|         }
  423|   517k|         return data_ + size_;
  424|   551k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE3endEv:
  647|  1.36M|      iterator end() noexcept { return data_ + size_; }
_ZZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEixERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEENKUlvE_clEv:
  931|  2.06M|         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_:
  241|  2.06M|      {
  242|  2.06M|         grow_if_needed();
  243|  2.06M|         std::construct_at(data_ + size_, std::forward<Args>(args)...);
  244|  2.06M|         ++size_;
  245|  2.06M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE14grow_if_neededEv:
  215|  2.06M|      {
  216|  2.06M|         if (size_ == capacity_) {
  ------------------
  |  Branch (216:14): [True: 263k, False: 1.80M]
  ------------------
  217|   263k|            if (size_ == max_u32) {
  ------------------
  |  Branch (217:17): [True: 0, False: 263k]
  ------------------
  218|      0|               throw_capacity_overflow();
  219|      0|            }
  220|   263k|            const uint32_t new_cap = next_data_capacity(capacity_);
  221|   263k|            reallocate_data(new_cap);
  222|   263k|         }
  223|  2.06M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE18next_data_capacityEj:
  118|   263k|      {
  119|   263k|         if (current == 0) return 4;
  ------------------
  |  Branch (119:14): [True: 74.9k, False: 188k]
  ------------------
  120|   188k|         if (current > (max_u32 / 2)) return max_u32;
  ------------------
  |  Branch (120:14): [True: 0, False: 188k]
  ------------------
  121|   188k|         return current * 2;
  122|   188k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE15reallocate_dataEj:
  203|   263k|      {
  204|   263k|         if (new_cap < size_) {
  ------------------
  |  Branch (204:14): [True: 0, False: 263k]
  ------------------
  205|      0|            throw_capacity_overflow();
  206|      0|         }
  207|   263k|         auto* new_data = allocate_and_relocate(new_cap);
  208|   263k|         destroy_all();
  209|   263k|         ::operator delete(data_);
  210|   263k|         data_ = new_data;
  211|   263k|         capacity_ = new_cap;
  212|   263k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE21allocate_and_relocateEj:
  157|   263k|      {
  158|   263k|         auto* new_data = static_cast<value_type*>(::operator new(checked_data_allocation_bytes(new_cap)));
  159|   263k|#if __cpp_exceptions
  160|   263k|         uint32_t constructed = 0;
  161|   263k|         try {
  162|  3.11M|            for (; constructed < size_; ++constructed) {
  ------------------
  |  Branch (162:20): [True: 2.85M, False: 263k]
  ------------------
  163|  2.85M|               std::construct_at(new_data + constructed, std::move_if_noexcept(data_[constructed]));
  164|  2.85M|            }
  165|   263k|         }
  166|   263k|         catch (...) {
  167|      0|            destroy_range(new_data, constructed);
  168|      0|            ::operator delete(new_data);
  169|      0|            throw;
  170|      0|         }
  171|       |#else
  172|       |         for (uint32_t i = 0; i < size_; ++i) {
  173|       |            std::construct_at(new_data + i, std::move_if_noexcept(data_[i]));
  174|       |         }
  175|       |#endif
  176|   263k|         return new_data;
  177|   263k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE29checked_data_allocation_bytesEj:
  132|   263k|      {
  133|   263k|         if (count > ((std::numeric_limits<size_t>::max)() / sizeof(value_type))) {
  ------------------
  |  Branch (133:14): [True: 0, False: 263k]
  ------------------
  134|      0|            GLZ_THROW_OR_ABORT(std::bad_alloc{});
  ------------------
  |  |    8|      0|#define GLZ_THROW_OR_ABORT(EXC) (throw(EXC))
  ------------------
  135|      0|         }
  136|   263k|         return static_cast<size_t>(count) * sizeof(value_type);
  137|   263k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE8hash_keyENSt3__117basic_string_viewIcNS5_11char_traitsIcEEEE:
   95|  5.93M|      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_:
  527|  2.25M|      {
  528|  2.25M|         if (index_ && size_ <= bloom_threshold && !bloom_maybe_contains(h)) {
  ------------------
  |  Branch (528:14): [True: 2.19M, False: 53.1k]
  |  Branch (528:24): [True: 2.09M, False: 104k]
  |  Branch (528:52): [True: 1.43M, False: 658k]
  ------------------
  529|       |            // Definitely not present — skip the search
  530|  1.43M|            append_fn();
  531|  1.43M|            bloom_set(h);
  532|       |            // Index is now stale (index_->size < size_), will rebuild on next lookup or false positive
  533|  1.43M|            return true;
  534|  1.43M|         }
  535|   816k|         return false;
  536|  2.25M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE20bloom_maybe_containsEj:
  283|  2.09M|      {
  284|  2.09M|         const uint32_t a = h & bloom_mask;
  285|  2.09M|         const uint32_t b = (h >> 10) & bloom_mask;
  286|  2.09M|         return (index_->bloom[a >> 3] & (uint8_t(1) << (a & 7))) && (index_->bloom[b >> 3] & (uint8_t(1) << (b & 7)));
  ------------------
  |  Branch (286:17): [True: 729k, False: 1.36M]
  |  Branch (286:70): [True: 658k, False: 70.7k]
  ------------------
  287|  2.09M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE17index_find_or_posINSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEEENS4_17index_find_resultERKT_j:
  398|   816k|      {
  399|   816k|         ensure_index();
  400|       |
  401|   816k|         const auto* base = index_entries();
  402|   816k|         const auto* idx_end = base + index_->size;
  403|   816k|         const auto* p = branchless_lower_bound(base, index_->size, h);
  404|   816k|         const size_t pos = static_cast<size_t>(p - base);
  405|       |
  406|       |         // Scan adjacent entries with matching hash
  407|   818k|         for (auto* scan = p; scan != idx_end && scan->key_hash == h; ++scan) {
  ------------------
  |  Branch (407:31): [True: 816k, False: 2.16k]
  |  Branch (407:50): [True: 702k, False: 113k]
  ------------------
  408|   702k|            if (data_[scan->index].first == key) {
  ------------------
  |  Branch (408:17): [True: 701k, False: 1.56k]
  ------------------
  409|   701k|               return {data_ + scan->index, pos, h};
  410|   701k|            }
  411|   702k|         }
  412|       |
  413|   115k|         return {data_ + size_, pos, h};
  414|   816k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE12ensure_indexEv:
  358|   816k|      {
  359|   816k|         if (size_ <= linear_search_threshold) return;
  ------------------
  |  Branch (359:14): [True: 0, False: 816k]
  ------------------
  360|   816k|         const auto current = index_size();
  361|   816k|         if (current == size_) return; // fully current
  ------------------
  |  Branch (361:14): [True: 538k, False: 278k]
  ------------------
  362|       |
  363|   278k|         if (current == 0 || (size_ - current) > linear_search_threshold) {
  ------------------
  |  Branch (363:14): [True: 53.1k, False: 225k]
  |  Branch (363:30): [True: 65.8k, False: 159k]
  ------------------
  364|   119k|            rebuild_index(); // full rebuild
  365|   119k|            return;
  366|   119k|         }
  367|       |
  368|       |         // Incrementally insert-sort the few new entries
  369|   578k|         for (uint32_t i = current; i < size_; ++i) {
  ------------------
  |  Branch (369:37): [True: 419k, False: 159k]
  ------------------
  370|   419k|            const hash_index_entry entry{hash_key(data_[i].first), i};
  371|   419k|            const auto* base = index_entries();
  372|   419k|            const auto* p = branchless_lower_bound(base, index_->size, entry.key_hash);
  373|   419k|            auto pos = static_cast<size_t>(p - base);
  374|       |
  375|   419k|            const uint32_t m = index_->size;
  376|   419k|            ensure_index_capacity(static_cast<size_type>(m) + 1);
  377|   419k|            auto* entries = index_entries();
  378|   419k|            if (pos < m) {
  ------------------
  |  Branch (378:17): [True: 373k, False: 45.6k]
  ------------------
  379|   373k|               std::memmove(entries + pos + 1, entries + pos, (m - pos) * sizeof(hash_index_entry));
  380|   373k|            }
  381|   419k|            entries[pos] = entry;
  382|   419k|            index_->size = i + 1;
  383|   419k|         }
  384|   159k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE13rebuild_indexEv:
  341|   119k|      {
  342|   119k|         ensure_index_capacity(static_cast<size_type>(size_));
  343|   119k|         bloom_clear();
  344|   119k|         auto* entries = index_entries();
  345|  3.38M|         for (uint32_t i = 0; i < size_; ++i) {
  ------------------
  |  Branch (345:31): [True: 3.26M, False: 119k]
  ------------------
  346|  3.26M|            const uint32_t h = hash_key(data_[i].first);
  347|  3.26M|            entries[i] = {h, i};
  348|  3.26M|            bloom_set(h);
  349|  3.26M|         }
  350|   119k|         std::sort(entries, entries + size_, [](const auto& a, const auto& b) { return a.key_hash < b.key_hash; });
  351|   119k|         index_->size = size_;
  352|   119k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE11bloom_clearEv:
  289|   119k|      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_:
  350|  19.9M|         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:
  438|  1.23M|      {
  439|  8.26M|         while (len > 1) {
  ------------------
  |  Branch (439:17): [True: 7.03M, False: 1.23M]
  ------------------
  440|  7.03M|            size_t half = len / 2;
  441|  7.03M|            p += (p[half - 1].key_hash < target) * half;
  442|  7.03M|            len -= half;
  443|  7.03M|         }
  444|       |         // Final element check: advance past it if it's less than target
  445|  1.23M|         p += (len == 1 && p->key_hash < target);
  ------------------
  |  Branch (445:16): [True: 1.23M, False: 0]
  |  Branch (445:28): [True: 47.8k, False: 1.18M]
  ------------------
  446|  1.23M|         return p;
  447|  1.23M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE9bloom_setEj:
  275|  4.81M|      {
  276|  4.81M|         const uint32_t a = h & bloom_mask;
  277|  4.81M|         const uint32_t b = (h >> 10) & bloom_mask;
  278|  4.81M|         index_->bloom[a >> 3] |= uint8_t(1) << (a & 7);
  279|  4.81M|         index_->bloom[b >> 3] |= uint8_t(1) << (b & 7);
  280|  4.81M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE10index_sizeEv:
  298|   932k|      uint32_t index_size() const noexcept { return index_ ? index_->size : 0; }
  ------------------
  |  Branch (298:53): [True: 879k, False: 53.1k]
  ------------------
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE21ensure_index_capacityEm:
  312|   653k|      {
  313|   653k|         if (needed == 0) return;
  ------------------
  |  Branch (313:14): [True: 0, False: 653k]
  ------------------
  314|   653k|         if (needed > static_cast<size_type>(max_u32)) {
  ------------------
  |  Branch (314:14): [True: 0, False: 653k]
  ------------------
  315|      0|            throw_index_overflow();
  316|      0|         }
  317|   653k|         const auto needed_u32 = static_cast<uint32_t>(needed);
  318|   653k|         if (index_ && index_->capacity >= needed_u32) return;
  ------------------
  |  Branch (318:14): [True: 600k, False: 53.1k]
  |  Branch (318:24): [True: 528k, False: 72.5k]
  ------------------
  319|   125k|         uint32_t cap = index_ ? index_->capacity : 0;
  ------------------
  |  Branch (319:25): [True: 72.5k, False: 53.1k]
  ------------------
  320|   256k|         while (cap < needed_u32) {
  ------------------
  |  Branch (320:17): [True: 130k, False: 125k]
  ------------------
  321|   130k|            const uint32_t next = next_index_capacity(cap);
  322|   130k|            if (next <= cap) {
  ------------------
  |  Branch (322:17): [True: 0, False: 130k]
  ------------------
  323|      0|               throw_index_overflow();
  324|      0|            }
  325|   130k|            cap = next;
  326|   130k|         }
  327|   125k|         auto* block = static_cast<index_header*>(std::realloc(index_, checked_index_allocation_bytes(cap)));
  328|   125k|         if (!block) GLZ_THROW_OR_ABORT(std::bad_alloc{});
  ------------------
  |  |    8|      0|#define GLZ_THROW_OR_ABORT(EXC) (throw(EXC))
  ------------------
  |  Branch (328:14): [True: 0, False: 125k]
  ------------------
  329|   125k|         if (!index_) {
  ------------------
  |  Branch (329:14): [True: 53.1k, False: 72.5k]
  ------------------
  330|  53.1k|            block->size = 0;
  331|  53.1k|            std::memset(block->bloom, 0, bloom_bytes);
  332|  53.1k|         }
  333|   125k|         block->capacity = cap;
  334|   125k|         index_ = block;
  335|   125k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE19next_index_capacityEj:
  125|   130k|      {
  126|   130k|         if (current == 0) return 16;
  ------------------
  |  Branch (126:14): [True: 53.1k, False: 77.4k]
  ------------------
  127|  77.4k|         if (current > (max_u32 / 2)) return max_u32;
  ------------------
  |  Branch (127:14): [True: 0, False: 77.4k]
  ------------------
  128|  77.4k|         return current * 2;
  129|  77.4k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE30checked_index_allocation_bytesEj:
  140|   125k|      {
  141|   125k|         constexpr size_t header = sizeof(index_header);
  142|   125k|         constexpr size_t entry = sizeof(hash_index_entry);
  143|   125k|         if (count > (((std::numeric_limits<size_t>::max)() - header) / entry)) {
  ------------------
  |  Branch (143:14): [True: 0, False: 125k]
  ------------------
  144|      0|            GLZ_THROW_OR_ABORT(std::bad_alloc{});
  ------------------
  |  |    8|      0|#define GLZ_THROW_OR_ABORT(EXC) (throw(EXC))
  ------------------
  145|      0|         }
  146|   125k|         return header + static_cast<size_t>(count) * entry;
  147|   125k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE13index_entriesEv:
  294|  1.88M|      {
  295|  1.88M|         return static_cast<hash_index_entry*>(static_cast<void*>(index_ + 1));
  296|  1.88M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE4sizeEv:
  661|     30|      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|  8.13M|   {
  617|  8.13M|      using V = std::decay_t<decltype(element)>;
  618|  8.13M|      if constexpr (std::is_member_object_pointer_v<V>) {
  619|  8.13M|         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|  8.13M|   }

_ZNK3glz9error_ctxcvbEv:
  129|  31.6k|      operator bool() const noexcept { return ec != error_code::none; }
_ZN3glz11enter_depthITkNS_10is_contextENS_7contextEEEbRT_:
  250|  2.01M|   {
  251|  2.01M|      if (ctx.depth >= max_recursive_depth_limit) [[unlikely]] {
  ------------------
  |  Branch (251:11): [True: 44, False: 2.01M]
  ------------------
  252|     44|         ctx.error = error_code::exceeded_max_recursive_depth;
  253|     44|         return true;
  254|     44|      }
  255|  2.01M|      ++ctx.depth;
  256|  2.01M|      return false;
  257|  2.01M|   }
_ZN3glz18charge_speculationITkNS_10is_contextENS_7contextEEEbRT_m:
  218|  50.2k|   {
  219|  50.2k|      if constexpr (requires { ctx.speculation_budget; }) {
  220|  50.2k|         if (ctx.speculation_budget == 0) {
  ------------------
  |  Branch (220:14): [True: 0, False: 50.2k]
  ------------------
  221|      0|            return true;
  222|      0|         }
  223|  50.2k|         ctx.speculation_budget = consumed >= ctx.speculation_budget ? 1 : ctx.speculation_budget - consumed;
  ------------------
  |  Branch (223:35): [True: 0, False: 50.2k]
  ------------------
  224|  50.2k|         return ctx.speculation_budget > 1;
  225|       |      }
  226|       |      else {
  227|       |         return true;
  228|       |      }
  229|  50.2k|   }
_ZN3glz21speculation_exhaustedITkNS_10is_contextENS_7contextEEEbRT_:
  235|  2.85k|   {
  236|  2.85k|      if constexpr (requires { ctx.speculation_budget; }) {
  237|  2.85k|         return ctx.speculation_budget == 1; // the latched floor; 0 means unbudgeted
  238|       |      }
  239|       |      else {
  240|       |         return false;
  241|       |      }
  242|  2.85k|   }

_ZN3glz4readITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10contiguousERKNSt3__16vectorIcNS6_9allocatorIcEEEEQaa14read_supportedIT0_XdtT_6formatEEnt18is_input_streamingIT1_EEENS_9error_ctxERSD_OSE_:
  219|  10.5k|   {
  220|  10.5k|      format_context_t<Opts.format> ctx{};
  221|  10.5k|      return read<Opts>(value, buffer, ctx);
  222|  10.5k|   }
_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|  10.5k|   {
  137|  10.5k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
  138|  10.5k|      using Buffer = std::remove_reference_t<decltype(buffer)>;
  139|       |
  140|  10.5k|      if constexpr (Opts.format != NDJSON) {
  141|  10.5k|         if (buffer.empty()) [[unlikely]] {
  ------------------
  |  Branch (141:14): [True: 0, False: 10.5k]
  ------------------
  142|      0|            ctx.error = error_code::no_read_input;
  143|      0|            return {0, ctx.error, ctx.custom_error_message};
  144|      0|         }
  145|  10.5k|      }
  146|       |
  147|  10.5k|      constexpr bool use_padded = resizable<Buffer> && non_const_buffer<Buffer> && !check_disable_padding(Opts);
  ------------------
  |  Branch (147:35): [Folded, False: 10.5k]
  |  Branch (147:56): [Folded, False: 0]
  |  Branch (147:84): [True: 0, Folded]
  ------------------
  148|       |
  149|  10.5k|      [[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|  10.5k|      auto [it, end] = read_iterators<Opts, use_padded>(buffer);
  157|  10.5k|      auto start = it;
  158|  10.5k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (158:11): [True: 0, False: 10.5k]
  ------------------
  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|  10.5k|      if constexpr (requires { ctx.speculation_budget; }) {
  165|  10.5k|         const size_t proportional = max_speculative_parse_factor * size_t(end - it);
  166|  10.5k|         ctx.speculation_budget =
  167|  10.5k|            (proportional > min_speculative_parse_bytes ? proportional : min_speculative_parse_bytes) + 2;
  ------------------
  |  Branch (167:14): [True: 296, False: 10.2k]
  ------------------
  168|  10.5k|      }
  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|  10.5k|      else {
  183|  10.5k|         parse<Opts.format>::template op<is_padded_off<Opts>()>(value, ctx, it, end);
  184|  10.5k|      }
  185|       |
  186|  10.5k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (186:11): [True: 7.87k, False: 2.66k]
  ------------------
  187|  7.87k|         goto finish;
  188|  7.87k|      }
  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|  10.5k|   finish:
  206|  10.5k|      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|  10.5k|      return {size_t(it - start), ctx.error, ctx.custom_error_message};
  214|  2.66k|   }
_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEELb0ETkNS_10contiguousERKNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT1_:
   40|  10.5k|   {
   41|  10.5k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  10.5k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  10.5k|      auto end = reinterpret_cast<const char*>(buffer.data()); // to be incremented
   45|       |
   46|       |      if constexpr (Padded) {
   47|       |         end += buffer.size() - padding_bytes;
   48|       |      }
   49|  10.5k|      else {
   50|  10.5k|         end += buffer.size();
   51|  10.5k|      }
   52|       |
   53|  10.5k|      return std::pair{it, end};
   54|  10.5k|   }
_ZN3glz23finalize_top_level_readITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEEEvOT0_PKcS7_S7_:
  115|  10.5k|   {
  116|  10.5k|      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|  10.5k|         if (ctx.error == error_code::end_reached && ctx.depth == 0 && it == end && start < it) {
  ------------------
  |  Branch (121:14): [True: 1.45k, False: 9.08k]
  |  Branch (121:54): [True: 15, False: 1.43k]
  |  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|  10.5k|      }
  130|  10.5k|      finalize_read_context<Opts>(ctx);
  131|  10.5k|   }
_ZN3glz21finalize_read_contextITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEEEvOT0_:
   76|  10.5k|   {
   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|  10.5k|      settle_end_reached(ctx);
   96|  10.5k|   }
_ZN3glz18settle_end_reachedITkNS_10is_contextERNS_7contextEEEvOT_:
   68|  31.6k|   {
   69|  31.6k|      if (ctx.error == error_code::end_reached) {
  ------------------
  |  Branch (69:11): [True: 1.44k, False: 30.1k]
  ------------------
   70|  1.44k|         ctx.error = (ctx.depth == 0) ? error_code::none : error_code::unexpected_end;
  ------------------
  |  Branch (70:22): [True: 2, False: 1.43k]
  ------------------
   71|  1.44k|      }
   72|  31.6k|   }
_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|  10.5k|   {
  137|  10.5k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
  138|  10.5k|      using Buffer = std::remove_reference_t<decltype(buffer)>;
  139|       |
  140|  10.5k|      if constexpr (Opts.format != NDJSON) {
  141|  10.5k|         if (buffer.empty()) [[unlikely]] {
  ------------------
  |  Branch (141:14): [True: 0, False: 10.5k]
  ------------------
  142|      0|            ctx.error = error_code::no_read_input;
  143|      0|            return {0, ctx.error, ctx.custom_error_message};
  144|      0|         }
  145|  10.5k|      }
  146|       |
  147|  10.5k|      constexpr bool use_padded = resizable<Buffer> && non_const_buffer<Buffer> && !check_disable_padding(Opts);
  ------------------
  |  Branch (147:35): [Folded, False: 10.5k]
  |  Branch (147:56): [Folded, False: 0]
  |  Branch (147:84): [True: 0, Folded]
  ------------------
  148|       |
  149|  10.5k|      [[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|  10.5k|      auto [it, end] = read_iterators<Opts, use_padded>(buffer);
  157|  10.5k|      auto start = it;
  158|  10.5k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (158:11): [True: 0, False: 10.5k]
  ------------------
  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|  10.5k|      if constexpr (requires { ctx.speculation_budget; }) {
  165|  10.5k|         const size_t proportional = max_speculative_parse_factor * size_t(end - it);
  166|  10.5k|         ctx.speculation_budget =
  167|  10.5k|            (proportional > min_speculative_parse_bytes ? proportional : min_speculative_parse_bytes) + 2;
  ------------------
  |  Branch (167:14): [True: 300, False: 10.2k]
  ------------------
  168|  10.5k|      }
  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|  10.5k|      else {
  183|  10.5k|         parse<Opts.format>::template op<is_padded_off<Opts>()>(value, ctx, it, end);
  184|  10.5k|      }
  185|       |
  186|  10.5k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (186:11): [True: 7.86k, False: 2.67k]
  ------------------
  187|  7.86k|         goto finish;
  188|  7.86k|      }
  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|  10.5k|   finish:
  206|  10.5k|      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|  10.5k|      return {size_t(it - start), ctx.error, ctx.custom_error_message};
  214|  2.67k|   }
_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEELb0ETkNS_10contiguousERKNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT1_:
   40|  10.5k|   {
   41|  10.5k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  10.5k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  10.5k|      auto end = reinterpret_cast<const char*>(buffer.data()); // to be incremented
   45|       |
   46|       |      if constexpr (Padded) {
   47|       |         end += buffer.size() - padding_bytes;
   48|       |      }
   49|  10.5k|      else {
   50|  10.5k|         end += buffer.size();
   51|  10.5k|      }
   52|       |
   53|  10.5k|      return std::pair{it, end};
   54|  10.5k|   }
_ZN3glz23finalize_top_level_readITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEEEvOT0_PKcS7_S7_:
  115|  21.0k|   {
  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|  21.0k|      finalize_read_context<Opts>(ctx);
  131|  21.0k|   }
_ZN3glz21finalize_read_contextITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEEEvOT0_:
   76|  21.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|  21.0k|      settle_end_reached(ctx);
   96|  21.0k|   }
_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|  10.5k|   {
  137|  10.5k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
  138|  10.5k|      using Buffer = std::remove_reference_t<decltype(buffer)>;
  139|       |
  140|  10.5k|      if constexpr (Opts.format != NDJSON) {
  141|  10.5k|         if (buffer.empty()) [[unlikely]] {
  ------------------
  |  Branch (141:14): [True: 0, False: 10.5k]
  ------------------
  142|      0|            ctx.error = error_code::no_read_input;
  143|      0|            return {0, ctx.error, ctx.custom_error_message};
  144|      0|         }
  145|  10.5k|      }
  146|       |
  147|  10.5k|      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|  10.5k|      [[maybe_unused]] size_t original_size{};
  150|  10.5k|      if constexpr (use_padded) {
  151|       |         // Pad the buffer for SWAR
  152|  10.5k|         original_size = buffer.size();
  153|  10.5k|         buffer.resize(original_size + padding_bytes);
  154|  10.5k|      }
  155|       |
  156|  10.5k|      auto [it, end] = read_iterators<Opts, use_padded>(buffer);
  157|  10.5k|      auto start = it;
  158|  10.5k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (158:11): [True: 0, False: 10.5k]
  ------------------
  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|  10.5k|      if constexpr (requires { ctx.speculation_budget; }) {
  165|  10.5k|         const size_t proportional = max_speculative_parse_factor * size_t(end - it);
  166|  10.5k|         ctx.speculation_budget =
  167|  10.5k|            (proportional > min_speculative_parse_bytes ? proportional : min_speculative_parse_bytes) + 2;
  ------------------
  |  Branch (167:14): [True: 300, False: 10.2k]
  ------------------
  168|  10.5k|      }
  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|  10.5k|      if constexpr (use_padded) {
  180|  10.5k|         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|  10.5k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (186:11): [True: 7.86k, False: 2.67k]
  ------------------
  187|  7.86k|         goto finish;
  188|  7.86k|      }
  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|  10.5k|   finish:
  206|  10.5k|      finalize_top_level_read<Opts>(ctx, start, it, end);
  207|       |
  208|  10.5k|      if constexpr (use_padded) {
  209|       |         // Restore the original buffer state
  210|  10.5k|         buffer.resize(original_size);
  211|  10.5k|      }
  212|       |
  213|  10.5k|      return {size_t(it - start), ctx.error, ctx.custom_error_message};
  214|  2.67k|   }
_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEELb1ETkNS_10contiguousERNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT1_:
   40|  10.5k|   {
   41|  10.5k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  10.5k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  10.5k|      auto end = reinterpret_cast<const char*>(buffer.data()); // to be incremented
   45|       |
   46|  10.5k|      if constexpr (Padded) {
   47|  10.5k|         end += buffer.size() - padding_bytes;
   48|       |      }
   49|       |      else {
   50|       |         end += buffer.size();
   51|       |      }
   52|       |
   53|  10.5k|      return std::pair{it, end};
   54|  10.5k|   }

_ZN3glz9sweethash7sweet32ITkNS0_16contiguous_rangeENSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEEjRKT_j:
  270|  5.93M|   {
  271|  5.93M|      return sweet32(static_cast<const void*>(s.data()), s.size(), seed);
  272|  5.93M|   }
_ZN3glz9sweethash7sweet32EPKvmj:
  154|  5.93M|   {
  155|  5.93M|      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|  5.93M|      if (len <= 8) {
  ------------------
  |  Branch (158:11): [True: 3.27M, False: 2.65M]
  ------------------
  159|  3.27M|         uint64_t v = 0;
  160|  3.27M|         switch (len) {
  161|   135k|         case 8:
  ------------------
  |  Branch (161:10): [True: 135k, False: 3.14M]
  ------------------
  162|   135k|            std::memcpy(&v, p, 8);
  163|   135k|            break;
  164|   422k|         case 7:
  ------------------
  |  Branch (164:10): [True: 422k, False: 2.85M]
  ------------------
  165|   422k|            std::memcpy(&v, p, 7);
  166|   422k|            break;
  167|   118k|         case 6:
  ------------------
  |  Branch (167:10): [True: 118k, False: 3.16M]
  ------------------
  168|   118k|            std::memcpy(&v, p, 6);
  169|   118k|            break;
  170|  9.79k|         case 5:
  ------------------
  |  Branch (170:10): [True: 9.79k, False: 3.26M]
  ------------------
  171|  9.79k|            std::memcpy(&v, p, 5);
  172|  9.79k|            break;
  173|   223k|         case 4:
  ------------------
  |  Branch (173:10): [True: 223k, False: 3.05M]
  ------------------
  174|   223k|            std::memcpy(&v, p, 4);
  175|   223k|            break;
  176|   111k|         case 3:
  ------------------
  |  Branch (176:10): [True: 111k, False: 3.16M]
  ------------------
  177|   111k|            std::memcpy(&v, p, 3);
  178|   111k|            break;
  179|  1.23M|         case 2:
  ------------------
  |  Branch (179:10): [True: 1.23M, False: 2.04M]
  ------------------
  180|  1.23M|            std::memcpy(&v, p, 2);
  181|  1.23M|            break;
  182|   989k|         case 1:
  ------------------
  |  Branch (182:10): [True: 989k, False: 2.29M]
  ------------------
  183|   989k|            v = p[0];
  184|   989k|            break;
  185|  33.7k|         default:
  ------------------
  |  Branch (185:10): [True: 33.7k, False: 3.24M]
  ------------------
  186|  33.7k|            break;
  187|  3.27M|         }
  188|  3.27M|         v = v ^ seed ^ (len + 1);
  189|  3.27M|         return static_cast<uint32_t>(v) ^ static_cast<uint32_t>(v >> 32);
  190|  3.27M|      }
  191|       |
  192|       |      // Full hash for inputs > 8 bytes
  193|  2.65M|      uint64_t seed64 = (static_cast<uint64_t>(seed) << 32) | static_cast<uint64_t>(seed);
  194|  2.65M|      uint64_t h = (seed64 ^ prime4) + (len * prime1);
  195|  2.65M|      const uint8_t* const end = p + len;
  196|       |
  197|  2.65M|      if (len >= 32) {
  ------------------
  |  Branch (197:11): [True: 1.51M, False: 1.13M]
  ------------------
  198|  1.51M|         uint64_t h1 = h;
  199|  1.51M|         uint64_t h2 = (seed64 * prime2) ^ prime3;
  200|  1.51M|         uint64_t h3 = (seed64 * prime3) ^ prime4;
  201|  1.51M|         uint64_t h4 = (seed64 * prime4) ^ prime5;
  202|       |
  203|  4.95M|         do {
  204|  4.95M|            uint64_t k1, k2, k3, k4;
  205|  4.95M|            std::memcpy(&k1, p, 8);
  206|  4.95M|            std::memcpy(&k2, p + 8, 8);
  207|  4.95M|            std::memcpy(&k3, p + 16, 8);
  208|  4.95M|            std::memcpy(&k4, p + 24, 8);
  209|       |
  210|  4.95M|            k1 = k1 * prime2;
  211|  4.95M|            k1 = k1 ^ (k1 >> 47);
  212|  4.95M|            h1 = h1 ^ k1;
  213|  4.95M|            h1 = h1 * prime1;
  214|       |
  215|  4.95M|            k2 = k2 * prime3;
  216|  4.95M|            k2 = k2 ^ (k2 >> 47);
  217|  4.95M|            h2 = h2 ^ k2;
  218|  4.95M|            h2 = h2 * prime2;
  219|       |
  220|  4.95M|            k3 = k3 * prime4;
  221|  4.95M|            k3 = k3 ^ (k3 >> 47);
  222|  4.95M|            h3 = h3 ^ k3;
  223|  4.95M|            h3 = h3 * prime3;
  224|       |
  225|  4.95M|            k4 = k4 * prime5;
  226|  4.95M|            k4 = k4 ^ (k4 >> 47);
  227|  4.95M|            h4 = h4 ^ k4;
  228|  4.95M|            h4 = h4 * prime4;
  229|       |
  230|  4.95M|            p = p + 32;
  231|  4.95M|            len = len - 32;
  232|  4.95M|         } while (len >= 32);
  ------------------
  |  Branch (232:19): [True: 3.43M, False: 1.51M]
  ------------------
  233|       |
  234|  1.51M|         h = h1 + h2 + h3 + h4;
  235|  1.51M|      }
  236|       |
  237|  6.84M|      while (len >= 8) {
  ------------------
  |  Branch (237:14): [True: 4.19M, False: 2.65M]
  ------------------
  238|  4.19M|         uint64_t k;
  239|  4.19M|         std::memcpy(&k, p, 8);
  240|  4.19M|         k = k * prime2;
  241|  4.19M|         k = k ^ (k >> 47);
  242|  4.19M|         h = h ^ k;
  243|  4.19M|         h = h * prime1;
  244|  4.19M|         p = p + 8;
  245|  4.19M|         len = len - 8;
  246|  4.19M|      }
  247|       |
  248|  2.65M|      if (len > 0) {
  ------------------
  |  Branch (248:11): [True: 2.21M, False: 444k]
  ------------------
  249|  2.21M|         uint64_t k;
  250|  2.21M|         std::memcpy(&k, end - 8, 8);
  251|  2.21M|         k = k * prime2;
  252|  2.21M|         k = k ^ (k >> 47);
  253|  2.21M|         k = k * prime3;
  254|  2.21M|         h = h ^ k;
  255|  2.21M|      }
  256|       |
  257|  2.65M|      h = mix64(h);
  258|  2.65M|      return static_cast<uint32_t>(h) ^ static_cast<uint32_t>(h >> 32);
  259|  5.93M|   }
_ZN3glz9sweethash5mix64Em:
   33|  2.65M|   {
   34|  2.65M|      v = v ^ (v >> 33);
   35|  2.65M|      v = v * prime2;
   36|  2.65M|      v = v ^ (v >> 29);
   37|  2.65M|      v = v * prime3;
   38|  2.65M|      return v;
   39|  2.65M|   }

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

_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  10.5k|      {
   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|  10.5k|         else {
   60|  10.5k|            using V = std::remove_cvref_t<T>;
   61|  10.5k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  10.5k|                                             end);
   63|  10.5k|         }
   64|  10.5k|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  10.5k|      {
  151|  10.5k|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  10.5k|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  10.5k|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  10.5k|      }
_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_:
 4093|  10.5k|      {
 4094|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 4095|       |            read_adjacent<Options>(value, ctx, it, end);
 4096|       |         }
 4097|  10.5k|         else {
 4098|  10.5k|            read_deduced<Options>(value, ctx, it, end);
 4099|  10.5k|         }
 4100|  10.5k|      }
_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_:
 4104|  10.5k|      {
 4105|  10.5k|         constexpr auto Opts = ws_handled_off<Options>();
 4106|  10.5k|         if constexpr (variant_is_auto_deducible<T>()) {
 4107|  10.5k|            if constexpr (not check_ws_handled(Options)) {
 4108|  10.5k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (4108:20): [True: 13, False: 10.5k]
  ------------------
 4109|     13|                  return;
 4110|     13|               }
 4111|  10.5k|            }
 4112|       |
 4113|  10.5k|            switch (*it) {
 4114|      3|            case '\0':
  ------------------
  |  Branch (4114:13): [True: 3, False: 10.5k]
  ------------------
 4115|      3|               ctx.error = error_code::unexpected_end;
 4116|      3|               return;
 4117|  4.67k|            case '{': {
  ------------------
  |  Branch (4117:13): [True: 4.67k, False: 5.86k]
  ------------------
 4118|       |               // This branch consumes the brace itself and hands the object to a reader with
 4119|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 4120|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 4121|       |               // the reader below.
 4122|  4.67k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (4122:20): [True: 0, False: 4.67k]
  ------------------
 4123|      0|                  return;
 4124|      0|               }
 4125|       |
 4126|  4.67k|               ++it;
 4127|  4.67k|               if constexpr (not Opts.null_terminated) {
 4128|  4.67k|                  if (it == end) [[unlikely]] {
  ------------------
  |  Branch (4128:23): [True: 1, False: 4.66k]
  ------------------
 4129|      1|                     ctx.error = error_code::unexpected_end;
 4130|      1|                     return;
 4131|      1|                  }
 4132|  4.67k|               }
 4133|  4.66k|               using type_counts = variant_type_count<T>;
 4134|  4.67k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 4135|       |               if constexpr (n_object_candidates < 1) {
 4136|       |                  ctx.error = error_code::no_matching_variant_type;
 4137|       |                  return;
 4138|       |               }
 4139|  4.67k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 4140|  4.67k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 4141|  4.67k|                  using V = std::variant_alternative_t<first_idx, T>;
 4142|  4.67k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4142:23): [True: 4.66k, False: 1]
  ------------------
 4143|  4.67k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 4144|  4.67k|                  return;
 4145|       |               }
 4146|       |               else {
 4147|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 4148|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 4149|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 4150|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 4151|       |
 4152|       |                  // Track if we've encountered a tag and what value it had
 4153|       |                  std::optional<size_t> tag_specified_index{};
 4154|       |
 4155|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 4156|       |                     return;
 4157|       |                  }
 4158|       |                  auto start = it;
 4159|       |                  bool first_key = true;
 4160|       |                  // Parse bifurcation for tagged variants:
 4161|       |                  //
 4162|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 4163|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 4164|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 4165|       |                  //
 4166|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 4167|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 4168|       |                  // it advances past the trailing comma so the object parser picks up at the
 4169|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 4170|       |                  //
 4171|       |                  // One exception: if the tag name is also a field on the resolved struct
 4172|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 4173|       |                  // the struct field. This override is applied inside each std::visit lambda.
 4174|       |                  auto position_after_tag = [&] {
 4175|       |                     if (first_key) {
 4176|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 4177|       |                     }
 4178|       |                     else {
 4179|       |                        it = start; // tag was not the first key, re-parse from the beginning
 4180|       |                     }
 4181|       |                  };
 4182|       |                  while (*it != '}') {
 4183|       |                     if (it != start) {
 4184|       |                        first_key = false;
 4185|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 4186|       |                           return;
 4187|       |                        }
 4188|       |                     }
 4189|       |
 4190|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4191|       |                        return;
 4192|       |                     }
 4193|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4194|       |                        return;
 4195|       |                     }
 4196|       |
 4197|       |                     auto* key_start = it;
 4198|       |                     skip_string_view(ctx, it, end);
 4199|       |                     if (bool(ctx.error)) [[unlikely]]
 4200|       |                        return;
 4201|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 4202|       |                        return;
 4203|       |                     const sv key = {key_start, size_t(it - key_start)};
 4204|       |
 4205|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4206|       |                        return;
 4207|       |                     }
 4208|       |
 4209|       |                     if constexpr (deduction_key_count > 0) {
 4210|       |                        // We first check if a tag is defined and see if the key matches the tag
 4211|       |                        if constexpr (not tag_v<T>.empty()) {
 4212|       |                           if (key == tag_v<T>) {
 4213|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 4214|       |                                 return;
 4215|       |                              }
 4216|       |
 4217|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 4218|       |
 4219|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 4220|       |                              if constexpr (std::integral<id_type>) {
 4221|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4222|       |                              }
 4223|       |                              else {
 4224|       |                                 from<JSON, sv>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4225|       |                              }
 4226|       |                              if (bool(ctx.error)) [[unlikely]]
 4227|       |                                 return;
 4228|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4229|       |                                 return;
 4230|       |                              }
 4231|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4232|       |                                 ctx.error = error_code::syntax_error;
 4233|       |                                 return;
 4234|       |                              }
 4235|       |
 4236|       |                              size_t type_index;
 4237|       |                              if constexpr (std::integral<id_type>) {
 4238|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4239|       |                              }
 4240|       |                              else {
 4241|       |                                 type_index = variant_id_to_index<T>::op(
 4242|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4243|       |                              }
 4244|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4245|       |                                 // Check if the deduced types include the tag-specified type
 4246|       |                                 // If not, the tag doesn't match the fields
 4247|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4248|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4249|       |                                 // Check if the tag-specified type is still possible
 4250|       |                                 const bool type_is_possible = possible_types[type_index];
 4251|       |                                 if (!type_is_possible) {
 4252|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4253|       |                                    ctx.error = error_code::no_matching_variant_type;
 4254|       |                                    return;
 4255|       |                                 }
 4256|       |
 4257|       |                                 position_after_tag();
 4258|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4259|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4260|       |                                 std::visit(
 4261|       |                                    [&](auto&& v) {
 4262|       |                                       using V = std::decay_t<decltype(v)>;
 4263|       |                                       constexpr bool is_object =
 4264|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4265|       |                                       if constexpr (variant_unit_alternative<V>) {
 4266|       |                                          // A unit alternative carries no data; its object holds only the
 4267|       |                                          // discriminator. Consume that body through an empty reflected object so
 4268|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4269|       |                                          detail::variant_unit_body unit_body{};
 4270|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4271|       |                                                                                             tag_literal>(unit_body,
 4272|       |                                                                                                          ctx, it, end);
 4273|       |                                       }
 4274|       |                                       else if constexpr (is_object) {
 4275|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4276|       |                                             it = start; // tag is a struct field, must re-parse
 4277|       |                                          }
 4278|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4279|       |                                                                                                           end);
 4280|       |                                       }
 4281|       |                                       else if constexpr (is_memory_object<V>) {
 4282|       |                                          if (!v) {
 4283|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4284|       |                                                if constexpr (requires { v.emplace(); }) {
 4285|       |                                                   v.emplace();
 4286|       |                                                }
 4287|       |                                                else {
 4288|       |                                                   v = typename V::value_type{};
 4289|       |                                                }
 4290|       |                                             }
 4291|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4292|       |                                                v = std::make_unique<typename V::element_type>();
 4293|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4294|       |                                                v = std::make_shared<typename V::element_type>();
 4295|       |                                             else if constexpr (constructible<V>) {
 4296|       |                                                v = meta_construct_v<V>();
 4297|       |                                             }
 4298|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4299|       |                                                                can_allocate_raw_pointer<Opts,
 4300|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4301|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4302|       |                                                   return;
 4303|       |                                                }
 4304|       |                                             }
 4305|       |                                             else {
 4306|       |                                                ctx.error = error_code::invalid_nullable_read;
 4307|       |                                                return;
 4308|       |                                                // Cannot read into unset nullable that is not std::optional,
 4309|       |                                                // std::unique_ptr, or std::shared_ptr
 4310|       |                                             }
 4311|       |                                          }
 4312|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4313|       |                                             it = start; // tag is a struct field, must re-parse
 4314|       |                                          }
 4315|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4316|       |                                             *v, ctx, it, end);
 4317|       |                                       }
 4318|       |                                       else if constexpr (custom_read<V>) {
 4319|       |                                          // Custom handlers parse the remaining body themselves and do not
 4320|       |                                          // accept the tag template parameter; the tag was already consumed.
 4321|       |                                          // This only works when the tag was the first key. If it came later,
 4322|       |                                          // we were reset to the object start and the custom handler would
 4323|       |                                          // absorb the tag, so error rather than corrupt the value.
 4324|       |                                          if (it == start) {
 4325|       |                                             ctx.error = error_code::feature_not_supported;
 4326|       |                                             ctx.custom_error_message =
 4327|       |                                                "the tag must be the first key for a custom variant alternative";
 4328|       |                                             return;
 4329|       |                                          }
 4330|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4331|       |                                       }
 4332|       |                                    },
 4333|       |                                    value);
 4334|       |
 4335|       |                                 return; // we've decoded our target type
 4336|       |                              }
 4337|       |                              else [[unlikely]] {
 4338|       |                                 // Check if we have a default type (ids array shorter than variant)
 4339|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4340|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4341|       |                                 if constexpr (ids_size < variant_size) {
 4342|       |                                    // Use the first unlabeled type as the default
 4343|       |                                    const auto default_type_index = ids_size;
 4344|       |
 4345|       |                                    position_after_tag();
 4346|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4347|       |                                    if (value.index() != default_type_index)
 4348|       |                                       emplace_runtime_variant(value, default_type_index);
 4349|       |                                    std::visit(
 4350|       |                                       [&](auto&& v) {
 4351|       |                                          using V = std::decay_t<decltype(v)>;
 4352|       |                                          constexpr bool is_object =
 4353|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4354|       |                                          if constexpr (variant_unit_alternative<V>) {
 4355|       |                                             // A unit alternative carries no data; its object holds only the
 4356|       |                                             // discriminator. Consume that body through an empty reflected object so
 4357|       |                                             // unknown-key policy and terminator handling match every other
 4358|       |                                             // alternative.
 4359|       |                                             detail::variant_unit_body unit_body{};
 4360|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4361|       |                                                                                                tag_literal>(
 4362|       |                                                unit_body, ctx, it, end);
 4363|       |                                          }
 4364|       |                                          else if constexpr (is_object) {
 4365|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4366|       |                                                it = start; // tag is a struct field, must re-parse
 4367|       |                                             }
 4368|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4369|       |                                          }
 4370|       |                                          else if constexpr (is_memory_object<V>) {
 4371|       |                                             if (!v) {
 4372|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4373|       |                                                   if constexpr (requires { v.emplace(); }) {
 4374|       |                                                      v.emplace();
 4375|       |                                                   }
 4376|       |                                                   else {
 4377|       |                                                      v = typename V::value_type{};
 4378|       |                                                   }
 4379|       |                                                }
 4380|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4381|       |                                                   v = std::make_unique<typename V::element_type>();
 4382|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4383|       |                                                   v = std::make_shared<typename V::element_type>();
 4384|       |                                                else if constexpr (constructible<V>) {
 4385|       |                                                   v = meta_construct_v<V>();
 4386|       |                                                }
 4387|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4388|       |                                                                   can_allocate_raw_pointer<
 4389|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4390|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4391|       |                                                      return;
 4392|       |                                                   }
 4393|       |                                                }
 4394|       |                                                else {
 4395|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4396|       |                                                   return;
 4397|       |                                                }
 4398|       |                                             }
 4399|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4400|       |                                                it = start; // tag is a struct field, must re-parse
 4401|       |                                             }
 4402|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4403|       |                                                                                                              it, end);
 4404|       |                                          }
 4405|       |                                          else if constexpr (custom_read<V>) {
 4406|       |                                             // Custom handlers parse the remaining body themselves; this only
 4407|       |                                             // works when the tag was the first key (see above). If it came
 4408|       |                                             // later we were reset to the object start, so error rather than
 4409|       |                                             // let the custom handler absorb the tag.
 4410|       |                                             if (it == start) {
 4411|       |                                                ctx.error = error_code::feature_not_supported;
 4412|       |                                                ctx.custom_error_message =
 4413|       |                                                   "the tag must be the first key for a custom variant alternative";
 4414|       |                                                return;
 4415|       |                                             }
 4416|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4417|       |                                          }
 4418|       |                                       },
 4419|       |                                       value);
 4420|       |
 4421|       |                                    return;
 4422|       |                                 }
 4423|       |                                 else {
 4424|       |                                    ctx.error = error_code::no_matching_variant_type;
 4425|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4426|       |                                    return;
 4427|       |                                 }
 4428|       |                              }
 4429|       |                           }
 4430|       |                        }
 4431|       |
 4432|       |                        // Inline decode_hash lookup for variant deduction
 4433|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4434|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4435|       |                        const auto deduction_index =
 4436|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4437|       |                              key.data(), key.data() + key.size(), key.size());
 4438|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4439|       |                           [[likely]] {
 4440|       |                           possible_types &= deduction_bits[deduction_index];
 4441|       |                        }
 4442|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4443|       |                           ctx.error = error_code::unknown_key;
 4444|       |                           return;
 4445|       |                        }
 4446|       |                     }
 4447|       |                     else if constexpr (not tag_v<T>.empty()) {
 4448|       |                        // empty object case for variant, if there are no normal elements
 4449|       |                        if (key == tag_v<T>) {
 4450|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4451|       |                              return;
 4452|       |                           }
 4453|       |
 4454|       |                           std::string_view type_id{};
 4455|       |                           parse<JSON>::op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4456|       |                           if (bool(ctx.error)) [[unlikely]]
 4457|       |                              return;
 4458|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4459|       |                              return;
 4460|       |                           }
 4461|       |
 4462|       |                           const auto type_index = variant_id_to_index<T>::op(
 4463|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4464|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4465|       |                              position_after_tag();
 4466|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4467|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4468|       |                           }
 4469|       |                           else {
 4470|       |                              // Check if we have a default type (ids array shorter than variant)
 4471|       |                              constexpr auto ids_size = ids_v<T>.size();
 4472|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4473|       |                              if constexpr (ids_size < variant_size) {
 4474|       |                                 // Use the first unlabeled type as the default
 4475|       |                                 position_after_tag();
 4476|       |                                 const auto default_index = ids_size;
 4477|       |                                 tag_specified_index = default_index; // Store the default type index
 4478|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4479|       |                              }
 4480|       |                              else {
 4481|       |                                 ctx.error = error_code::no_matching_variant_type;
 4482|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4483|       |                                 return;
 4484|       |                              }
 4485|       |                           }
 4486|       |                           // Parse the type (handles tag skipping and unknown keys)
 4487|       |                           std::visit(
 4488|       |                              [&](auto&& v) {
 4489|       |                                 using V = std::decay_t<decltype(v)>;
 4490|       |                                 if constexpr (custom_read<V>) {
 4491|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4492|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4493|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4494|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4495|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4496|       |                                    // into its value, so error here rather than corrupt the result.
 4497|       |                                    if (it == start) {
 4498|       |                                       ctx.error = error_code::feature_not_supported;
 4499|       |                                       ctx.custom_error_message =
 4500|       |                                          "the tag must be the first key for a custom variant alternative";
 4501|       |                                       return;
 4502|       |                                    }
 4503|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4504|       |                                 }
 4505|       |                                 else {
 4506|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4507|       |                                       it = start; // tag is a struct field, must re-parse
 4508|       |                                    }
 4509|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4510|       |                                 }
 4511|       |                              },
 4512|       |                              value);
 4513|       |                           return;
 4514|       |                        }
 4515|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4516|       |                           ctx.error = error_code::unknown_key;
 4517|       |                           return;
 4518|       |                        }
 4519|       |                        else {
 4520|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4521|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4522|       |                              return;
 4523|       |                           }
 4524|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4525|       |                           if (bool(ctx.error)) [[unlikely]]
 4526|       |                              return;
 4527|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4528|       |                              return;
 4529|       |                           }
 4530|       |                           continue; // Continue loop to find the tag
 4531|       |                        }
 4532|       |                     }
 4533|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4534|       |                        ctx.error = error_code::unknown_key;
 4535|       |                        return;
 4536|       |                     }
 4537|       |
 4538|       |                     auto matching_types = possible_types.popcount();
 4539|       |                     if (matching_types == 0) {
 4540|       |                        ctx.error = error_code::no_matching_variant_type;
 4541|       |                        return;
 4542|       |                     }
 4543|       |                     // Only short-circuit for variants without tags
 4544|       |                     else if constexpr (tag_v<T>.empty()) {
 4545|       |                        if (matching_types == 1) {
 4546|       |                           it = start;
 4547|       |                           const auto type_index = possible_types.countr_zero();
 4548|       |
 4549|       |                           if (value.index() != static_cast<size_t>(type_index))
 4550|       |                              emplace_runtime_variant(value, type_index);
 4551|       |                           std::visit(
 4552|       |                              [&](auto&& v) {
 4553|       |                                 using V = std::decay_t<decltype(v)>;
 4554|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4555|       |                                 if constexpr (variant_unit_alternative<V>) {
 4556|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4557|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4558|       |                                    // terminator handling match every other alternative.
 4559|       |                                    detail::variant_unit_body unit_body{};
 4560|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4561|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4562|       |                                                                                                    end);
 4563|       |                                 }
 4564|       |                                 else if constexpr (is_object) {
 4565|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4566|       |                                 }
 4567|       |                                 else if constexpr (is_memory_object<V>) {
 4568|       |                                    if (!v) {
 4569|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4570|       |                                          if constexpr (requires { v.emplace(); }) {
 4571|       |                                             v.emplace();
 4572|       |                                          }
 4573|       |                                          else {
 4574|       |                                             v = typename V::value_type{};
 4575|       |                                          }
 4576|       |                                       }
 4577|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4578|       |                                          v = std::make_unique<typename V::element_type>();
 4579|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4580|       |                                          v = std::make_shared<typename V::element_type>();
 4581|       |                                       else if constexpr (constructible<V>) {
 4582|       |                                          v = meta_construct_v<V>();
 4583|       |                                       }
 4584|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4585|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4586|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4587|       |                                             return;
 4588|       |                                          }
 4589|       |                                       }
 4590|       |                                       else {
 4591|       |                                          ctx.error = error_code::invalid_nullable_read;
 4592|       |                                          return;
 4593|       |                                          // Cannot read into unset nullable that is not std::optional,
 4594|       |                                          // std::unique_ptr, or std::shared_ptr
 4595|       |                                       }
 4596|       |                                    }
 4597|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4598|       |                                       *v, ctx, it, end);
 4599|       |                                 }
 4600|       |                                 else if constexpr (custom_read<V>) {
 4601|       |                                    // Custom handlers parse the remaining body themselves.
 4602|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4603|       |                                 }
 4604|       |                              },
 4605|       |                              value);
 4606|       |
 4607|       |                           return; // we've decoded our target type
 4608|       |                        }
 4609|       |                     }
 4610|       |                     // For tagged variants, continue processing to validate tags
 4611|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4612|       |                        return;
 4613|       |                     }
 4614|       |
 4615|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4616|       |                     if (bool(ctx.error)) [[unlikely]]
 4617|       |                        return;
 4618|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4619|       |                        return;
 4620|       |                     }
 4621|       |                  }
 4622|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4623|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4624|       |                     // After parsing all keys, check if we have multiple matching types
 4625|       |                     // If so, choose the one with the fewest fields
 4626|       |                     auto final_matching = possible_types.popcount();
 4627|       |                     if (final_matching == 0) {
 4628|       |                        ctx.error = error_code::no_matching_variant_type;
 4629|       |                     }
 4630|       |                     else if (final_matching == 1) {
 4631|       |                        // Single type remains after field deduction
 4632|       |                        const auto type_index = possible_types.countr_zero();
 4633|       |
 4634|       |                        // Validate against tag if one was specified
 4635|       |                        if (tag_specified_index.has_value() &&
 4636|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4637|       |                           ctx.error = error_code::no_matching_variant_type;
 4638|       |                           return;
 4639|       |                        }
 4640|       |
 4641|       |                        it = start;
 4642|       |                        if (value.index() != static_cast<size_t>(type_index))
 4643|       |                           emplace_runtime_variant(value, type_index);
 4644|       |                        std::visit(
 4645|       |                           [&](auto&& v) {
 4646|       |                              using V = std::decay_t<decltype(v)>;
 4647|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4648|       |                              if constexpr (variant_unit_alternative<V>) {
 4649|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4650|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4651|       |                                 // terminator handling match every other alternative.
 4652|       |                                 detail::variant_unit_body unit_body{};
 4653|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4654|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4655|       |                                                                                                 end);
 4656|       |                              }
 4657|       |                              else if constexpr (is_object) {
 4658|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4659|       |                              }
 4660|       |                              else if constexpr (is_memory_object<V>) {
 4661|       |                                 if (!v) {
 4662|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4663|       |                                       if constexpr (requires { v.emplace(); }) {
 4664|       |                                          v.emplace();
 4665|       |                                       }
 4666|       |                                       else {
 4667|       |                                          v = typename V::value_type{};
 4668|       |                                       }
 4669|       |                                    }
 4670|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4671|       |                                       v = std::make_unique<typename V::element_type>();
 4672|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4673|       |                                       v = std::make_shared<typename V::element_type>();
 4674|       |                                    else if constexpr (constructible<V>) {
 4675|       |                                       v = meta_construct_v<V>();
 4676|       |                                    }
 4677|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4678|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4679|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4680|       |                                          return;
 4681|       |                                       }
 4682|       |                                    }
 4683|       |                                    else {
 4684|       |                                       ctx.error = error_code::invalid_nullable_read;
 4685|       |                                       return;
 4686|       |                                    }
 4687|       |                                 }
 4688|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4689|       |                                                                                                               it, end);
 4690|       |                              }
 4691|       |                              else if constexpr (custom_read<V>) {
 4692|       |                                 // Custom handlers parse the remaining body themselves.
 4693|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4694|       |                              }
 4695|       |                           },
 4696|       |                           value);
 4697|       |                     }
 4698|       |                     else if (final_matching > 1) {
 4699|       |                        constexpr auto N = std::variant_size_v<T>;
 4700|       |
 4701|       |                        // Compile-time array of field counts for each variant type
 4702|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4703|       |                           return std::array<size_t, N> {
 4704|       |                              ([]<size_t J = I>() -> size_t {
 4705|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4706|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4707|       |                                    return reflect<V>::size;
 4708|       |                                 }
 4709|       |                                 else if constexpr (is_memory_object<V>) {
 4710|       |                                    using X = memory_type<V>;
 4711|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4712|       |                                       return reflect<X>::size;
 4713|       |                                    }
 4714|       |                                    else {
 4715|       |                                       return (std::numeric_limits<size_t>::max)();
 4716|       |                                    }
 4717|       |                                 }
 4718|       |                                 else {
 4719|       |                                    return (std::numeric_limits<size_t>::max)();
 4720|       |                                 }
 4721|       |                              }.template operator()<I>())...
 4722|       |                           };
 4723|       |                        }(std::make_index_sequence<N>{});
 4724|       |
 4725|       |                        // Find the type with minimum field count among the possible types
 4726|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4727|       |                        size_t chosen_index = N; // Invalid index initially
 4728|       |
 4729|       |                        for (size_t i = 0; i < N; ++i) {
 4730|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4731|       |                              min_fields = field_counts[i];
 4732|       |                              chosen_index = i;
 4733|       |                           }
 4734|       |                        }
 4735|       |
 4736|       |                        if (chosen_index < N) {
 4737|       |                           // Validate against tag if one was specified
 4738|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4739|       |                              ctx.error = error_code::no_matching_variant_type;
 4740|       |                              return;
 4741|       |                           }
 4742|       |
 4743|       |                           it = start;
 4744|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4745|       |                           std::visit(
 4746|       |                              [&](auto&& v) {
 4747|       |                                 using V = std::decay_t<decltype(v)>;
 4748|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4749|       |                                 if constexpr (variant_unit_alternative<V>) {
 4750|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4751|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4752|       |                                    // terminator handling match every other alternative.
 4753|       |                                    detail::variant_unit_body unit_body{};
 4754|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4755|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4756|       |                                                                                                    end);
 4757|       |                                 }
 4758|       |                                 else if constexpr (is_object) {
 4759|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4760|       |                                 }
 4761|       |                                 else if constexpr (is_memory_object<V>) {
 4762|       |                                    if (!v) {
 4763|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4764|       |                                          if constexpr (requires { v.emplace(); }) {
 4765|       |                                             v.emplace();
 4766|       |                                          }
 4767|       |                                          else {
 4768|       |                                             v = typename V::value_type{};
 4769|       |                                          }
 4770|       |                                       }
 4771|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4772|       |                                          v = std::make_unique<typename V::element_type>();
 4773|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4774|       |                                          v = std::make_shared<typename V::element_type>();
 4775|       |                                       else if constexpr (constructible<V>) {
 4776|       |                                          v = meta_construct_v<V>();
 4777|       |                                       }
 4778|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4779|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4780|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4781|       |                                             return;
 4782|       |                                          }
 4783|       |                                       }
 4784|       |                                       else {
 4785|       |                                          ctx.error = error_code::invalid_nullable_read;
 4786|       |                                          return;
 4787|       |                                       }
 4788|       |                                    }
 4789|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4790|       |                                       *v, ctx, it, end);
 4791|       |                                 }
 4792|       |                                 else if constexpr (custom_read<V>) {
 4793|       |                                    // Custom handlers parse the remaining body themselves.
 4794|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4795|       |                                 }
 4796|       |                              },
 4797|       |                              value);
 4798|       |                        }
 4799|       |                        else {
 4800|       |                           ctx.error = error_code::no_matching_variant_type;
 4801|       |                        }
 4802|       |                     }
 4803|       |                  }
 4804|       |                  else {
 4805|       |                     // For variants with 0 or 1 object types, use the original error handling
 4806|       |                     ctx.error = error_code::no_matching_variant_type;
 4807|       |                  }
 4808|       |               }
 4809|      0|               break;
 4810|  4.67k|            }
 4811|  2.00k|            case '[':
  ------------------
  |  Branch (4811:13): [True: 2.00k, False: 8.53k]
  ------------------
 4812|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4813|  2.00k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4814|  2.00k|               break;
 4815|  1.06k|            case '"': {
  ------------------
  |  Branch (4815:13): [True: 1.06k, False: 9.47k]
  ------------------
 4816|  1.06k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4817|  1.06k|               break;
 4818|  4.67k|            }
 4819|     65|            case 't':
  ------------------
  |  Branch (4819:13): [True: 65, False: 10.4k]
  ------------------
 4820|    180|            case 'f': {
  ------------------
  |  Branch (4820:13): [True: 115, False: 10.4k]
  ------------------
 4821|    180|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4822|    180|               break;
 4823|     65|            }
 4824|     73|            case 'n':
  ------------------
  |  Branch (4824:13): [True: 73, False: 10.4k]
  ------------------
 4825|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4826|       |                  ctx.error = error_code::no_matching_variant_type;
 4827|       |               }
 4828|     73|               else {
 4829|     73|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4830|     73|                  using V = std::variant_alternative_t<first_idx, T>;
 4831|     73|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4831:23): [True: 0, False: 73]
  ------------------
 4832|     73|                  match<"null", Opts>(ctx, it, end);
 4833|     73|               }
 4834|     73|               break;
 4835|  2.52k|            default: {
  ------------------
  |  Branch (4835:13): [True: 2.52k, False: 8.01k]
  ------------------
 4836|       |               // Not bool, string, object, or array so must be number or null
 4837|  2.52k|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4838|  2.52k|            }
 4839|  10.5k|            }
 4840|       |         }
 4841|       |         else {
 4842|       |            // For non-auto-deducible variants, try each type until one succeeds
 4843|       |            constexpr auto N = std::variant_size_v<T>;
 4844|       |            bool parsed = false;
 4845|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4846|       |
 4847|       |            for_each<N>([&]<size_t I>() {
 4848|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4849|       |
 4850|       |               auto copy_it = it;
 4851|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4852|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4853|       |               const auto copy_depth = ctx.depth;
 4854|       |
 4855|       |               // Try parsing as this type
 4856|       |               if (value.index() != I) {
 4857|       |                  emplace_runtime_variant(value, I);
 4858|       |               }
 4859|       |
 4860|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4861|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4862|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4863|       |               }
 4864|       |
 4865|       |               if (!bool(ctx.error)) {
 4866|       |                  parsed = true;
 4867|       |               }
 4868|       |               else if constexpr (not Options.null_terminated) {
 4869|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4870|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4871|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4872|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4873|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4874|       |                     parsed = true;
 4875|       |                     ctx.error = error_code::none;
 4876|       |                  }
 4877|       |                  else {
 4878|       |                     // Reset for next attempt (unless this is the last type)
 4879|       |                     it = copy_it;
 4880|       |                     rewind_depth<Options>(ctx, copy_depth);
 4881|       |                     if constexpr (I + 1 < N) {
 4882|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4883|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4884|       |                        }
 4885|       |                     }
 4886|       |                  }
 4887|       |               }
 4888|       |               else {
 4889|       |                  // Reset for next attempt (unless this is the last type)
 4890|       |                  it = copy_it;
 4891|       |                  rewind_depth<Options>(ctx, copy_depth);
 4892|       |                  if constexpr (I + 1 < N) {
 4893|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4894|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4895|       |                     }
 4896|       |                  }
 4897|       |               }
 4898|       |            });
 4899|       |         }
 4900|  10.5k|      }
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEERNS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES4_EEEETkNS_10is_contextERNS_7contextERPKcSD_EEvOT0_OT1_OT2_T3_:
   49|  27.9k|      {
   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|  27.9k|         else {
   60|  27.9k|            using V = std::remove_cvref_t<T>;
   61|  27.9k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  27.9k|                                             end);
   63|  27.9k|         }
   64|  27.9k|      }
_ZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_:
 3085|  27.9k|      {
 3086|  27.9k|         static constexpr auto num_members = reflect<T>::size;
 3087|       |
 3088|  27.9k|         static constexpr auto Opts = opening_handled_off<ws_handled_off<Options>()>();
 3089|       |         if constexpr (!check_opening_handled(Options)) {
 3090|       |            if constexpr (!check_ws_handled(Options)) {
 3091|       |               if (skip_ws<Opts>(ctx, it, end)) {
 3092|       |                  return;
 3093|       |               }
 3094|       |            }
 3095|       |            if (match_invalid_end<'{', Opts>(ctx, it, end)) {
 3096|       |               return;
 3097|       |            }
 3098|       |            if constexpr (not Opts.null_terminated) {
 3099|       |               if (it == end) [[unlikely]] {
 3100|       |                  ctx.error = error_code::unexpected_end;
 3101|       |                  return;
 3102|       |               }
 3103|       |            }
 3104|       |            // one nesting level (see enter_depth): counted in both modes so the limit binds,
 3105|       |            // released at each syntactic close below
 3106|       |            if (enter_depth(ctx)) [[unlikely]] {
 3107|       |               return;
 3108|       |            }
 3109|       |         }
 3110|  27.9k|         const auto ws_start = it;
 3111|  27.9k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3111:14): [True: 21, False: 27.8k]
  ------------------
 3112|     21|            return;
 3113|     21|         }
 3114|  27.8k|         const size_t ws_size = size_t(it - ws_start);
 3115|       |
 3116|       |         if constexpr ((glaze_object_t<T> || reflectable<T>) && num_members == 0 && Opts.error_on_unknown_keys) {
 3117|       |            if constexpr (not tag.sv().empty()) {
 3118|       |               if (*it == '"') {
 3119|       |                  ++it;
 3120|       |                  if constexpr (not Opts.null_terminated) {
 3121|       |                     if (it == end) [[unlikely]] {
 3122|       |                        ctx.error = error_code::unexpected_end;
 3123|       |                        return;
 3124|       |                     }
 3125|       |                  }
 3126|       |
 3127|       |                  const auto start = it;
 3128|       |                  skip_string_view(ctx, it, end);
 3129|       |                  if (bool(ctx.error)) [[unlikely]]
 3130|       |                     return;
 3131|       |                  if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3132|       |                     return;
 3133|       |                  const sv key{start, size_t(it - start)};
 3134|       |                  ++it;
 3135|       |                  if constexpr (not Opts.null_terminated) {
 3136|       |                     if (it == end) [[unlikely]] {
 3137|       |                        ctx.error = error_code::unexpected_end;
 3138|       |                        return;
 3139|       |                     }
 3140|       |                  }
 3141|       |
 3142|       |                  if (key == tag.sv()) {
 3143|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3144|       |                        return;
 3145|       |                     }
 3146|       |
 3147|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3148|       |                     if (bool(ctx.error)) [[unlikely]]
 3149|       |                        return;
 3150|       |
 3151|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3152|       |                        return;
 3153|       |                     }
 3154|       |                  }
 3155|       |                  else {
 3156|       |                     ctx.error = error_code::unknown_key;
 3157|       |                     return;
 3158|       |                  }
 3159|       |               }
 3160|       |            }
 3161|       |
 3162|       |            if (*it == '}') [[likely]] {
 3163|       |               --ctx.depth;
 3164|       |               if constexpr (glaze_object_t<T> || reflectable<T>) {
 3165|       |                  if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 3166|       |                     auto wrapper = self_constraint_v<T>(value);
 3167|       |                     from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 3168|       |                     if (bool(ctx.error)) {
 3169|       |                        return;
 3170|       |                     }
 3171|       |                  }
 3172|       |               }
 3173|       |               ++it;
 3174|       |               if constexpr (not Opts.null_terminated) {
 3175|       |                  if (it == end) {
 3176|       |                     ctx.error = error_code::end_reached;
 3177|       |                     return;
 3178|       |                  }
 3179|       |               }
 3180|       |               if constexpr (Opts.partial_read) {
 3181|       |                  ctx.error = error_code::partial_read_complete;
 3182|       |               }
 3183|       |               return;
 3184|       |            }
 3185|       |            ctx.error = error_code::unknown_key;
 3186|       |            return;
 3187|       |         }
 3188|  27.8k|         else {
 3189|  27.8k|            decltype(auto) fields = [&]() -> decltype(auto) {
 3190|  27.8k|               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 3191|  27.8k|                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 3192|  27.8k|                  return bit_array<num_members>{};
 3193|  27.8k|               }
 3194|  27.8k|               else {
 3195|  27.8k|                  return nullptr;
 3196|  27.8k|               }
 3197|  27.8k|            }();
 3198|       |
 3199|  27.8k|            size_t read_count{}; // for partial_read
 3200|       |
 3201|  27.8k|            bool first = true;
 3202|   964k|            while (true) {
  ------------------
  |  Branch (3202:20): [True: 940k, Folded]
  ------------------
 3203|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.partial_read) {
 3204|       |                  static constexpr bit_array<num_members> all_fields = [] {
 3205|       |                     bit_array<num_members> arr{};
 3206|       |                     for (size_t i = 0; i < num_members; ++i) {
 3207|       |                        arr[i] = true;
 3208|       |                     }
 3209|       |                     return arr;
 3210|       |                  }();
 3211|       |
 3212|       |                  if ((all_fields & fields) == all_fields) {
 3213|       |                     ctx.error = error_code::partial_read_complete;
 3214|       |                     --ctx.depth; // as above: an early success still closes this level
 3215|       |                     return;
 3216|       |                  }
 3217|       |               }
 3218|       |
 3219|       |               // Streaming refill point: at start of each iteration, ensure buffer has data
 3220|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 3221|       |                  if (ctx.stream.enabled()) {
 3222|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 3223|       |                     const size_t remaining = ctx.stream.size() - consumed;
 3224|       |                     // Refill when less than half of buffer remains to ensure space for next key-value pair
 3225|       |                     if (remaining <= ctx.stream.size() / 2 || it >= end) {
 3226|       |                        const char* new_it;
 3227|       |                        const char* new_end;
 3228|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 3229|       |                        it = new_it;
 3230|       |                        end = new_end;
 3231|       |                        if (it >= end && ctx.stream.at_eof()) {
 3232|       |                           ctx.error = error_code::unexpected_end;
 3233|       |                           return;
 3234|       |                        }
 3235|       |                     }
 3236|       |                  }
 3237|       |               }
 3238|       |
 3239|   940k|               if (*it == '}') {
  ------------------
  |  Branch (3239:20): [True: 2.74k, False: 937k]
  ------------------
 3240|  2.74k|                  --ctx.depth;
 3241|       |                  if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.error_on_missing_keys) {
 3242|       |                     constexpr auto req_fields = required_fields<T, Opts>();
 3243|       |                     if ((req_fields & fields) != req_fields) {
 3244|       |                        for (size_t i = 0; i < num_members; ++i) {
 3245|       |                           if (not fields[i] && req_fields[i]) {
 3246|       |                              ctx.custom_error_message = reflect<T>::keys[i];
 3247|       |                              // We just return the first missing key in order to avoid heap allocations
 3248|       |                              break;
 3249|       |                           }
 3250|       |                        }
 3251|       |
 3252|       |                        ctx.error = error_code::missing_key;
 3253|       |                        return;
 3254|       |                     }
 3255|       |                  }
 3256|       |                  if constexpr (glaze_object_t<T> || reflectable<T>) {
 3257|       |                     if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 3258|       |                        auto wrapper = self_constraint_v<T>(value);
 3259|       |                        from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 3260|       |                        if (bool(ctx.error)) {
 3261|       |                           return;
 3262|       |                        }
 3263|       |                     }
 3264|       |                  }
 3265|  2.74k|                  ++it; // Increment after checking for missing keys so errors are within buffer bounds
 3266|  2.74k|                  if constexpr (not Opts.null_terminated) {
 3267|  2.74k|                     if (it == end) {
  ------------------
  |  Branch (3267:26): [True: 14, False: 2.72k]
  ------------------
 3268|     14|                        ctx.error = error_code::end_reached;
 3269|     14|                        return;
 3270|     14|                     }
 3271|  2.74k|                  }
 3272|  2.72k|                  return;
 3273|  2.74k|               }
 3274|   937k|               else if (first) {
  ------------------
  |  Branch (3274:25): [True: 26.0k, False: 911k]
  ------------------
 3275|  26.0k|                  first = false;
 3276|  26.0k|               }
 3277|   911k|               else {
 3278|   911k|                  if (match_invalid_end<',', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3278:23): [True: 348, False: 911k]
  ------------------
 3279|    348|                     return;
 3280|    348|                  }
 3281|   911k|                  if constexpr (not Opts.null_terminated) {
 3282|   911k|                     if (it == end) [[unlikely]] {
  ------------------
  |  Branch (3282:26): [True: 0, False: 911k]
  ------------------
 3283|      0|                        ctx.error = error_code::unexpected_end;
 3284|      0|                        return;
 3285|      0|                     }
 3286|   911k|                  }
 3287|       |
 3288|       |                  if constexpr ((not Opts.minified) && (num_members > 1 || not Opts.error_on_unknown_keys) &&
 3289|       |                                (!Opts.comments)) {
 3290|       |                     if (ws_size && ws_size < size_t(end - it)) {
 3291|       |                        skip_matching_ws(ws_start, it, ws_size);
 3292|       |                     }
 3293|       |                  }
 3294|       |
 3295|   911k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3295:23): [True: 20, False: 911k]
  ------------------
 3296|     20|                     return;
 3297|     20|                  }
 3298|   911k|               }
 3299|       |
 3300|   937k|               constexpr auto reflection_type = glaze_object_t<T> || reflectable<T>;
  ------------------
  |  Branch (3300:49): [Folded, False: 0]
  |  Branch (3300:70): [Folded, False: 0]
  ------------------
 3301|       |
 3302|       |               if constexpr (reflection_type && (num_members == 0)) {
 3303|       |                  if constexpr (Opts.error_on_unknown_keys) {
 3304|       |                     static_assert(false_v<T>, "This should be unreachable");
 3305|       |                  }
 3306|       |                  else {
 3307|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 3308|       |                        return;
 3309|       |                     }
 3310|       |
 3311|       |                     // parsing to an empty object, but at this point the JSON presents keys
 3312|       |
 3313|       |                     // Unknown key handler does not unescape keys. Unknown escaped keys are
 3314|       |                     // handled by the user.
 3315|       |
 3316|       |                     const auto start = it;
 3317|       |                     skip_string_view(ctx, it, end);
 3318|       |                     if (bool(ctx.error)) [[unlikely]]
 3319|       |                        return;
 3320|       |                     if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3321|       |                        return;
 3322|       |                     const sv key{start, size_t(it - start)};
 3323|       |                     ++it;
 3324|       |                     if constexpr (not Opts.null_terminated) {
 3325|       |                        if (it == end) [[unlikely]] {
 3326|       |                           ctx.error = error_code::unexpected_end;
 3327|       |                           return;
 3328|       |                        }
 3329|       |                     }
 3330|       |
 3331|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3332|       |                        return;
 3333|       |                     }
 3334|       |
 3335|       |                     // Check if this key is the variant tag that should be skipped
 3336|       |                     if constexpr (not tag.sv().empty()) {
 3337|       |                        if (key == tag.sv()) {
 3338|       |                           // Skip the tag value
 3339|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3340|       |                           if (bool(ctx.error)) [[unlikely]]
 3341|       |                              return;
 3342|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 3343|       |                              return;
 3344|       |                           }
 3345|       |                           continue;
 3346|       |                        }
 3347|       |                     }
 3348|       |
 3349|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3350|       |                     if (bool(ctx.error)) [[unlikely]]
 3351|       |                        return;
 3352|       |                     if constexpr (not Opts.null_terminated) {
 3353|       |                        if (it == end) [[unlikely]] {
 3354|       |                           ctx.error = error_code::unexpected_end;
 3355|       |                           return;
 3356|       |                        }
 3357|       |                     }
 3358|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3359|       |                        return;
 3360|       |                     }
 3361|       |                  }
 3362|       |               }
 3363|       |               else if constexpr (reflection_type) {
 3364|       |                  static_assert(bool(hash_info<T>.type));
 3365|       |
 3366|       |                  if (*it != '"') [[unlikely]] {
 3367|       |                     ctx.error = error_code::expected_quote;
 3368|       |                     return;
 3369|       |                  }
 3370|       |                  ++it;
 3371|       |                  if constexpr (not Opts.null_terminated) {
 3372|       |                     if (it == end) [[unlikely]] {
 3373|       |                        ctx.error = error_code::unexpected_end;
 3374|       |                        return;
 3375|       |                     }
 3376|       |                  }
 3377|       |
 3378|       |                  if constexpr (not tag.sv().empty() && not contains_tag<T, tag>()) {
 3379|       |                     // For tagged variants we first check to see if the key matches the tag
 3380|       |                     // We only need to do this if the tag is not part of the keys
 3381|       |
 3382|       |                     const auto start = it;
 3383|       |                     skip_string_view(ctx, it, end);
 3384|       |                     if (bool(ctx.error)) [[unlikely]]
 3385|       |                        return;
 3386|       |                     if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3387|       |                        return;
 3388|       |                     const sv key{start, size_t(it - start)};
 3389|       |                     ++it;
 3390|       |                     if constexpr (not Opts.null_terminated) {
 3391|       |                        if (it == end) [[unlikely]] {
 3392|       |                           ctx.error = error_code::unexpected_end;
 3393|       |                           return;
 3394|       |                        }
 3395|       |                     }
 3396|       |
 3397|       |                     if (key == tag.sv()) {
 3398|       |                        if (parse_ws_colon<Opts>(ctx, it, end)) {
 3399|       |                           return;
 3400|       |                        }
 3401|       |
 3402|       |                        parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3403|       |                        if (bool(ctx.error)) [[unlikely]]
 3404|       |                           return;
 3405|       |
 3406|       |                        if (skip_ws<Opts>(ctx, it, end)) {
 3407|       |                           return;
 3408|       |                        }
 3409|       |                        continue;
 3410|       |                     }
 3411|       |                     else {
 3412|       |                        it = start; // reset the iterator
 3413|       |                     }
 3414|       |                  }
 3415|       |
 3416|       |                  if constexpr (Opts.error_on_missing_keys || Opts.partial_read) {
 3417|       |                     size_t index = num_members;
 3418|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end, index);
 3419|       |                     if (bool(ctx.error)) [[unlikely]]
 3420|       |                        return;
 3421|       |                     if (index < num_members) {
 3422|       |                        fields[index] = true;
 3423|       |                     }
 3424|       |                  }
 3425|       |                  else {
 3426|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end);
 3427|       |                     if (bool(ctx.error)) [[unlikely]]
 3428|       |                        return;
 3429|       |                  }
 3430|       |               }
 3431|   937k|               else {
 3432|       |                  // For types like std::map, std::unordered_map
 3433|       |
 3434|   937k|                  auto reading = [&](auto&& key) {
 3435|   937k|                     if constexpr (Opts.partial_read) {
 3436|   937k|                        if (auto element = value.find(key); element != value.end()) {
 3437|   937k|                           ++read_count;
 3438|   937k|                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3439|   937k|                        }
 3440|   937k|                        else {
 3441|   937k|                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3442|   937k|                        }
 3443|   937k|                     }
 3444|   937k|                     else {
 3445|   937k|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3446|   937k|                     }
 3447|   937k|                  };
 3448|       |
 3449|       |                  // using Key = std::conditional_t<heterogeneous_map<T>, sv, typename T::key_type>;
 3450|   937k|                  using Key = typename T::key_type;
 3451|   937k|                  if constexpr (std::is_same_v<Key, std::string>) {
 3452|   937k|                     ctx.scratch.clear();
 3453|   937k|                     parse<JSON>::op<Opts>(ctx.scratch, ctx, it, end);
 3454|   937k|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3454:26): [True: 1.58k, False: 935k]
  ------------------
 3455|  1.58k|                        return;
 3456|       |
 3457|   935k|                     if (parse_ws_colon<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3457:26): [True: 1.44k, False: 934k]
  ------------------
 3458|  1.44k|                        return;
 3459|  1.44k|                     }
 3460|       |
 3461|   934k|                     reading(ctx.scratch);
 3462|       |                     if constexpr (Opts.partial_read) {
 3463|       |                        if (read_count == value.size()) {
 3464|       |                           return;
 3465|       |                        }
 3466|       |                     }
 3467|   934k|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3467:26): [True: 21.6k, False: 912k]
  ------------------
 3468|  21.6k|                        return;
 3469|       |                  }
 3470|       |                  else if constexpr (str_t<Key>) {
 3471|       |                     Key key;
 3472|       |                     parse<JSON>::op<Opts>(key, ctx, it, end);
 3473|       |                     if (bool(ctx.error)) [[unlikely]]
 3474|       |                        return;
 3475|       |
 3476|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3477|       |                        return;
 3478|       |                     }
 3479|       |
 3480|       |                     reading(key);
 3481|       |                     if constexpr (Opts.partial_read) {
 3482|       |                        if (read_count == value.size()) {
 3483|       |                           return;
 3484|       |                        }
 3485|       |                     }
 3486|       |                     if (bool(ctx.error)) [[unlikely]]
 3487|       |                        return;
 3488|       |                  }
 3489|       |                  else {
 3490|       |                     Key key_value{};
 3491|       |                     if constexpr (is_named_enum<Key> || mimics_str_t<Key>) {
 3492|       |                        parse<JSON>::op<Opts>(key_value, ctx, it, end);
 3493|       |                     }
 3494|       |                     else if constexpr (std::is_arithmetic_v<Key>) {
 3495|       |                        // prefer over quoted_t below to avoid double parsing of quoted_t
 3496|       |                        parse<JSON>::op<opt_true<Opts, quoted_num_opt_tag{}>>(key_value, ctx, it, end);
 3497|       |                     }
 3498|       |                     else {
 3499|       |                        parse<JSON>::op<opt_false<Opts, raw_string_opt_tag{}>>(quoted_t<Key>{key_value}, ctx, it, end);
 3500|       |                     }
 3501|       |                     if (bool(ctx.error)) [[unlikely]]
 3502|       |                        return;
 3503|       |
 3504|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3505|       |                        return;
 3506|       |                     }
 3507|       |
 3508|       |                     reading(key_value);
 3509|       |                     if constexpr (Opts.partial_read) {
 3510|       |                        if (read_count == value.size()) {
 3511|       |                           return;
 3512|       |                        }
 3513|       |                     }
 3514|       |                     if (bool(ctx.error)) [[unlikely]]
 3515|       |                        return;
 3516|       |                  }
 3517|   937k|               }
 3518|       |
 3519|       |               // Streaming refill point: after parsing each key-value pair, refill if buffer is low
 3520|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 3521|       |                  if (ctx.stream.enabled()) {
 3522|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 3523|       |                     // Refill when less than 25% of buffer remains to ensure enough space for next element
 3524|       |                     if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 3525|       |                        const char* new_it;
 3526|       |                        const char* new_end;
 3527|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 3528|       |                        it = new_it;
 3529|       |                        end = new_end;
 3530|       |                        if (it >= end && ctx.stream.at_eof()) {
 3531|       |                           ctx.error = error_code::unexpected_end;
 3532|       |                           return;
 3533|       |                        }
 3534|       |                     }
 3535|       |                  }
 3536|       |               }
 3537|       |
 3538|   937k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3538:20): [True: 112, False: 937k]
  ------------------
 3539|    112|                  return;
 3540|    112|               }
 3541|   937k|            }
 3542|  27.8k|         }
 3543|  27.8k|      }
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlvE_clEv:
 3189|  27.8k|            decltype(auto) fields = [&]() -> decltype(auto) {
 3190|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 3191|       |                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 3192|       |                  return bit_array<num_members>{};
 3193|       |               }
 3194|  27.8k|               else {
 3195|  27.8k|                  return nullptr;
 3196|  27.8k|               }
 3197|  27.8k|            }();
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|   937k|      {
   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|   937k|         else {
   60|   937k|            using V = std::remove_cvref_t<T>;
   61|   937k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|   937k|                                             end);
   63|   937k|         }
   64|   937k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEQntcl15check_is_paddedTL0__EEEvRT2_OT3_OT0_T1_:
 1084|   937k|      {
 1085|       |         if constexpr (check_string_as_number(Opts)) {
 1086|       |            auto start = it;
 1087|       |            skip_number<Opts>(ctx, it, end);
 1088|       |            if (bool(ctx.error)) [[unlikely]] {
 1089|       |               return;
 1090|       |            }
 1091|       |            if (start == it) [[unlikely]] {
 1092|       |               ctx.error = error_code::parse_number_failure;
 1093|       |               return;
 1094|       |            }
 1095|       |            value.append(start, size_t(it - start));
 1096|       |         }
 1097|   937k|         else {
 1098|   937k|            if constexpr (!check_opening_handled(Opts)) {
 1099|   937k|               if constexpr (!check_ws_handled(Opts)) {
 1100|   937k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (1100:23): [True: 0, False: 937k]
  ------------------
 1101|      0|                     return;
 1102|      0|                  }
 1103|   937k|               }
 1104|       |
 1105|   937k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (1105:20): [True: 236, False: 936k]
  ------------------
 1106|    236|                  return;
 1107|    236|               }
 1108|   937k|            }
 1109|       |
 1110|   937k|            if constexpr (not check_raw_string(Opts)) {
 1111|   937k|               static constexpr auto string_padding_bytes = 8;
 1112|       |
 1113|   937k|               if (size_t(end - it) >= 8) {
  ------------------
  |  Branch (1113:20): [True: 935k, False: 1.81k]
  ------------------
 1114|   935k|                  auto start = it;
 1115|   935k|                  uint64_t ascii_acc{};
 1116|   935k|                  const auto end8 = end - 8;
 1117|  5.29M|                  while (true) {
  ------------------
  |  Branch (1117:26): [True: 5.29M, Folded]
  ------------------
 1118|  5.29M|                     if (it >= end8) [[unlikely]] {
  ------------------
  |  Branch (1118:26): [True: 984, False: 5.29M]
  ------------------
 1119|    984|                        break;
 1120|    984|                     }
 1121|       |
 1122|  5.29M|                     uint64_t chunk;
 1123|  5.29M|                     std::memcpy(&chunk, it, 8);
 1124|       |                     if constexpr (std::endian::native == std::endian::big) {
 1125|       |                        chunk = std::byteswap(chunk);
 1126|       |                     }
 1127|  5.29M|                     ascii_acc |= chunk;
 1128|  5.29M|                     const uint64_t test_chars = has_quote(chunk);
 1129|  5.29M|                     if (test_chars) {
  ------------------
  |  Branch (1129:26): [True: 935k, False: 4.35M]
  ------------------
 1130|   935k|                        it += (countr_zero(test_chars) >> 3);
 1131|       |
 1132|   935k|                        auto* prev = it - 1;
 1133|   937k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1133:32): [True: 2.19k, False: 935k]
  ------------------
 1134|  2.19k|                           --prev;
 1135|  2.19k|                        }
 1136|   935k|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1136:29): [True: 934k, False: 1.36k]
  ------------------
 1137|   934k|                           goto continue_decode;
 1138|   934k|                        }
 1139|  1.36k|                        ++it; // skip the escaped quote
 1140|  1.36k|                     }
 1141|  4.35M|                     else {
 1142|  4.35M|                        it += 8;
 1143|  4.35M|                     }
 1144|  5.29M|                  }
 1145|       |
 1146|  2.84k|                  while (it[-1] == '\\') [[unlikely]] {
  ------------------
  |  Branch (1146:26): [True: 1.86k, False: 984]
  ------------------
 1147|       |                     // if we ended on an escape character then we need to rewind
 1148|       |                     // because we lost our context
 1149|  1.86k|                     --it;
 1150|  1.86k|                  }
 1151|       |
 1152|       |                  // The byte-wise tail keeps feeding the accumulator: it has to cover every byte of
 1153|       |                  // the string, or a non-ASCII byte reached here would be waved through unvalidated.
 1154|  5.68k|                  for (; it < end; ++it) {
  ------------------
  |  Branch (1154:26): [True: 5.36k, False: 319]
  ------------------
 1155|  5.36k|                     ascii_acc |= uint8_t(*it);
 1156|  5.36k|                     if (*it == '"') {
  ------------------
  |  Branch (1156:26): [True: 740, False: 4.62k]
  ------------------
 1157|    740|                        auto* prev = it - 1;
 1158|  1.52k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1158:32): [True: 783, False: 740]
  ------------------
 1159|    783|                           --prev;
 1160|    783|                        }
 1161|    740|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1161:29): [True: 665, False: 75]
  ------------------
 1162|    665|                           goto continue_decode;
 1163|    665|                        }
 1164|    740|                     }
 1165|  5.36k|                  }
 1166|       |
 1167|    319|                  ctx.error = error_code::unexpected_end;
 1168|    319|                  return;
 1169|       |
 1170|   935k|               continue_decode:
 1171|       |
 1172|   935k|                  if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (1172:23): [True: 275, False: 934k]
  ------------------
 1173|    275|                     return;
 1174|    275|                  }
 1175|       |
 1176|   934k|                  const auto available_padding = size_t(end - it);
 1177|   934k|                  auto n = size_t(it - start);
 1178|   934k|                  if (available_padding >= 8) [[likely]] {
  ------------------
  |  Branch (1178:23): [True: 934k, False: 624]
  ------------------
 1179|   934k|                     value.resize(n + string_padding_bytes);
 1180|       |
 1181|   934k|                     auto* p = value.data();
 1182|       |
 1183|  5.63M|                     while (true) {
  ------------------
  |  Branch (1183:29): [True: 5.63M, Folded]
  ------------------
 1184|  5.63M|                        if (start >= it) {
  ------------------
  |  Branch (1184:29): [True: 933k, False: 4.69M]
  ------------------
 1185|   933k|                           break;
 1186|   933k|                        }
 1187|       |
 1188|  4.69M|                        std::memcpy(p, start, 8);
 1189|  4.69M|                        uint64_t swar;
 1190|  4.69M|                        std::memcpy(&swar, p, 8);
 1191|       |                        if constexpr (std::endian::native == std::endian::big) {
 1192|       |                           swar = std::byteswap(swar);
 1193|       |                        }
 1194|       |
 1195|  4.69M|                        constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1196|  4.69M|                        const uint64_t lo7 = swar & lo7_mask;
 1197|  4.69M|                        const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1198|  4.69M|                        const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1199|  4.69M|                        uint64_t next = ~((backslash & less_32) | swar);
 1200|       |
 1201|  4.69M|                        next &= repeat_byte8(0b10000000);
 1202|  4.69M|                        if (next == 0) {
  ------------------
  |  Branch (1202:29): [True: 4.67M, False: 26.2k]
  ------------------
 1203|  4.67M|                           start += 8;
 1204|  4.67M|                           p += 8;
 1205|  4.67M|                           continue;
 1206|  4.67M|                        }
 1207|       |
 1208|  26.2k|                        next = countr_zero(next) >> 3;
 1209|  26.2k|                        start += next;
 1210|  26.2k|                        if (start >= it) {
  ------------------
  |  Branch (1210:29): [True: 485, False: 25.7k]
  ------------------
 1211|    485|                           break;
 1212|    485|                        }
 1213|       |
 1214|  25.7k|                        if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1214:29): [True: 101, False: 25.6k]
  ------------------
 1215|    101|                           ctx.error = error_code::syntax_error;
 1216|    101|                           return;
 1217|    101|                        }
 1218|  25.6k|                        ++start; // skip the escape
 1219|  25.6k|                        if (*start == 'u') {
  ------------------
  |  Branch (1219:29): [True: 19.0k, False: 6.61k]
  ------------------
 1220|  19.0k|                           ++start;
 1221|  19.0k|                           p += next;
 1222|  19.0k|                           const auto mark = start;
 1223|  19.0k|                           const auto offset = handle_unicode_code_point(start, p, end);
 1224|  19.0k|                           if (offset == 0) [[unlikely]] {
  ------------------
  |  Branch (1224:32): [True: 48, False: 18.9k]
  ------------------
 1225|     48|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1226|     48|                              return;
 1227|     48|                           }
 1228|  18.9k|                           n += offset;
 1229|       |                           // escape + u + unicode code points
 1230|  18.9k|                           n -= 2 + uint32_t(start - mark);
 1231|  18.9k|                        }
 1232|  6.61k|                        else {
 1233|  6.61k|                           p += next;
 1234|  6.61k|                           *p = char_unescape_table[uint8_t(*start)];
 1235|  6.61k|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1235:32): [True: 10, False: 6.60k]
  ------------------
 1236|     10|                              ctx.error = error_code::invalid_escape;
 1237|     10|                              return;
 1238|     10|                           }
 1239|  6.60k|                           ++p;
 1240|  6.60k|                           ++start;
 1241|  6.60k|                           --n;
 1242|  6.60k|                        }
 1243|  25.6k|                     }
 1244|       |
 1245|   933k|                     value.resize(n);
 1246|   933k|                     ++it;
 1247|   933k|                  }
 1248|    624|                  else {
 1249|       |                     // For large inputs this case of running out of buffer is very rare
 1250|    624|                     value.resize(n);
 1251|    624|                     auto* p = value.data();
 1252|       |
 1253|    624|                     it = start;
 1254|  30.9k|                     while (it < end) [[likely]] {
  ------------------
  |  Branch (1254:29): [True: 30.9k, False: 0]
  ------------------
 1255|  30.9k|                        if (*it == '"') {
  ------------------
  |  Branch (1255:29): [True: 461, False: 30.4k]
  ------------------
 1256|    461|                           value.resize(size_t(p - value.data()));
 1257|    461|                           ++it;
 1258|    461|                           return;
 1259|    461|                        }
 1260|       |
 1261|  30.4k|                        if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1261:29): [True: 57, False: 30.4k]
  ------------------
 1262|     57|                           ctx.error = error_code::syntax_error;
 1263|     57|                           return;
 1264|     57|                        }
 1265|       |
 1266|  30.4k|                        *p = *it;
 1267|       |
 1268|  30.4k|                        if (*it == '\\') {
  ------------------
  |  Branch (1268:29): [True: 2.44k, False: 27.9k]
  ------------------
 1269|  2.44k|                           ++it; // skip the escape
 1270|  2.44k|                           if (*it == 'u') {
  ------------------
  |  Branch (1270:32): [True: 1.13k, False: 1.30k]
  ------------------
 1271|  1.13k|                              ++it;
 1272|  1.13k|                              if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1272:35): [True: 90, False: 1.04k]
  ------------------
 1273|     90|                                 ctx.error = error_code::unicode_escape_conversion_failure;
 1274|     90|                                 return;
 1275|     90|                              }
 1276|  1.13k|                           }
 1277|  1.30k|                           else {
 1278|  1.30k|                              *p = char_unescape_table[uint8_t(*it)];
 1279|  1.30k|                              if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1279:35): [True: 16, False: 1.28k]
  ------------------
 1280|     16|                                 ctx.error = error_code::invalid_escape;
 1281|     16|                                 return;
 1282|     16|                              }
 1283|  1.28k|                              ++p;
 1284|  1.28k|                              ++it;
 1285|  1.28k|                           }
 1286|  2.44k|                        }
 1287|  27.9k|                        else {
 1288|  27.9k|                           ++it;
 1289|  27.9k|                           ++p;
 1290|  27.9k|                        }
 1291|  30.4k|                     }
 1292|       |
 1293|      0|                     ctx.error = error_code::unexpected_end;
 1294|      0|                  }
 1295|   934k|               }
 1296|  1.81k|               else {
 1297|       |                  // For short strings
 1298|       |
 1299|  1.81k|                  std::array<char, 8> buffer{};
 1300|       |
 1301|  1.81k|                  auto* p = buffer.data();
 1302|  1.81k|                  const auto* const utf8_start = it;
 1303|       |
 1304|  3.75k|                  while (it < end) [[likely]] {
  ------------------
  |  Branch (1304:26): [True: 3.40k, False: 353]
  ------------------
 1305|  3.40k|                     *p = *it;
 1306|  3.40k|                     if (*it == '"') {
  ------------------
  |  Branch (1306:26): [True: 1.35k, False: 2.04k]
  ------------------
 1307|  1.35k|                        if (validate_utf8_span<Opts>(ctx, utf8_start, it)) [[unlikely]] {
  ------------------
  |  Branch (1307:29): [True: 97, False: 1.26k]
  ------------------
 1308|     97|                           return;
 1309|     97|                        }
 1310|  1.26k|                        const size_t n = size_t(p - buffer.data());
 1311|  1.26k|#if __has_cpp_attribute(assume) >= 202207L
 1312|  1.26k|                        [[assume(n <= sizeof(buffer))]];
 1313|  1.26k|#endif
 1314|  1.26k|                        value.assign(buffer.data(), n);
 1315|  1.26k|                        ++it;
 1316|  1.26k|                        if constexpr (not Opts.null_terminated) {
 1317|  1.26k|                           if (it == end) {
  ------------------
  |  Branch (1317:32): [True: 117, False: 1.14k]
  ------------------
 1318|    117|                              ctx.error = error_code::end_reached;
 1319|    117|                              return;
 1320|    117|                           }
 1321|  1.26k|                        }
 1322|  1.14k|                        return;
 1323|  1.35k|                     }
 1324|  2.04k|                     else if (*it == '\\') {
  ------------------
  |  Branch (1324:31): [True: 162, False: 1.88k]
  ------------------
 1325|    162|                        ++it; // skip the escape
 1326|    162|                        if constexpr (not Opts.null_terminated) {
 1327|    162|                           if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1327:32): [True: 2, False: 160]
  ------------------
 1328|      2|                              ctx.error = error_code::unexpected_end;
 1329|      2|                              return;
 1330|      2|                           }
 1331|    162|                        }
 1332|    162|                        if (*it == 'u') {
  ------------------
  |  Branch (1332:29): [True: 100, False: 62]
  ------------------
 1333|    100|                           ++it;
 1334|    100|                           if constexpr (not Opts.null_terminated) {
 1335|    100|                              if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1335:35): [True: 1, False: 99]
  ------------------
 1336|      1|                                 ctx.error = error_code::unexpected_end;
 1337|      1|                                 return;
 1338|      1|                              }
 1339|    100|                           }
 1340|    100|                           if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1340:32): [True: 50, False: 50]
  ------------------
 1341|     50|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1342|     50|                              return;
 1343|     50|                           }
 1344|    100|                        }
 1345|     62|                        else {
 1346|     62|                           *p = char_unescape_table[uint8_t(*it)];
 1347|     62|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1347:32): [True: 16, False: 46]
  ------------------
 1348|     16|                              ctx.error = error_code::invalid_escape;
 1349|     16|                              return;
 1350|     16|                           }
 1351|     46|                           ++p;
 1352|     46|                           ++it;
 1353|     46|                        }
 1354|    162|                     }
 1355|  1.88k|                     else if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1355:31): [True: 38, False: 1.84k]
  ------------------
 1356|     38|                        ctx.error = error_code::syntax_error;
 1357|     38|                        return;
 1358|     38|                     }
 1359|  1.84k|                     else {
 1360|  1.84k|                        ++it;
 1361|  1.84k|                        ++p;
 1362|  1.84k|                     }
 1363|  3.40k|                  }
 1364|       |
 1365|    353|                  ctx.error = error_code::unexpected_end;
 1366|    353|               }
 1367|       |            }
 1368|       |            else {
 1369|       |               // raw_string
 1370|       |               auto start = it;
 1371|       |               skip_string_view(ctx, it, end);
 1372|       |               if (bool(ctx.error)) [[unlikely]]
 1373|       |                  return;
 1374|       |
 1375|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1376|       |                  return;
 1377|       |               }
 1378|       |
 1379|       |               value.assign(start, size_t(it - start));
 1380|       |               ++it;
 1381|       |            }
 1382|   937k|         }
 1383|   937k|      }
_ZN3glz14parse_ws_colonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT0_OT1_T2_:
  159|   935k|   {
  160|   935k|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (160:11): [True: 105, False: 935k]
  ------------------
  161|    105|         return true;
  162|    105|      }
  163|   935k|      if (match_invalid_end<':', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (163:11): [True: 1.31k, False: 934k]
  ------------------
  164|  1.31k|         return true;
  165|  1.31k|      }
  166|   934k|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (166:11): [True: 23, False: 934k]
  ------------------
  167|     23|         return true;
  168|     23|      }
  169|   934k|      return false;
  170|   934k|   }
_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_:
 3434|   934k|                  auto reading = [&](auto&& key) {
 3435|       |                     if constexpr (Opts.partial_read) {
 3436|       |                        if (auto element = value.find(key); element != value.end()) {
 3437|       |                           ++read_count;
 3438|       |                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3439|       |                        }
 3440|       |                        else {
 3441|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3442|       |                        }
 3443|       |                     }
 3444|   934k|                     else {
 3445|   934k|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3446|   934k|                     }
 3447|   934k|                  };
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  2.69M|      {
   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.69M|         else {
   60|  2.69M|            using V = std::remove_cvref_t<T>;
   61|  2.69M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  2.69M|                                             end);
   63|  2.69M|         }
   64|  2.69M|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  2.69M|      {
  151|  2.69M|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  2.69M|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  2.69M|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  2.69M|      }
_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_:
 4093|  2.69M|      {
 4094|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 4095|       |            read_adjacent<Options>(value, ctx, it, end);
 4096|       |         }
 4097|  2.69M|         else {
 4098|  2.69M|            read_deduced<Options>(value, ctx, it, end);
 4099|  2.69M|         }
 4100|  2.69M|      }
_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_:
 4104|  2.69M|      {
 4105|  2.69M|         constexpr auto Opts = ws_handled_off<Options>();
 4106|  2.69M|         if constexpr (variant_is_auto_deducible<T>()) {
 4107|       |            if constexpr (not check_ws_handled(Options)) {
 4108|       |               if (skip_ws<Opts>(ctx, it, end)) {
 4109|       |                  return;
 4110|       |               }
 4111|       |            }
 4112|       |
 4113|  2.69M|            switch (*it) {
 4114|     91|            case '\0':
  ------------------
  |  Branch (4114:13): [True: 91, False: 2.69M]
  ------------------
 4115|     91|               ctx.error = error_code::unexpected_end;
 4116|     91|               return;
 4117|  23.2k|            case '{': {
  ------------------
  |  Branch (4117:13): [True: 23.2k, False: 2.67M]
  ------------------
 4118|       |               // This branch consumes the brace itself and hands the object to a reader with
 4119|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 4120|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 4121|       |               // the reader below.
 4122|  23.2k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (4122:20): [True: 4, False: 23.2k]
  ------------------
 4123|      4|                  return;
 4124|      4|               }
 4125|       |
 4126|  23.2k|               ++it;
 4127|  23.2k|               if constexpr (not Opts.null_terminated) {
 4128|  23.2k|                  if (it == end) [[unlikely]] {
  ------------------
  |  Branch (4128:23): [True: 35, False: 23.2k]
  ------------------
 4129|     35|                     ctx.error = error_code::unexpected_end;
 4130|     35|                     return;
 4131|     35|                  }
 4132|  23.2k|               }
 4133|  23.2k|               using type_counts = variant_type_count<T>;
 4134|  23.2k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 4135|       |               if constexpr (n_object_candidates < 1) {
 4136|       |                  ctx.error = error_code::no_matching_variant_type;
 4137|       |                  return;
 4138|       |               }
 4139|  23.2k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 4140|  23.2k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 4141|  23.2k|                  using V = std::variant_alternative_t<first_idx, T>;
 4142|  23.2k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4142:23): [True: 22.8k, False: 407]
  ------------------
 4143|  23.2k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 4144|  23.2k|                  return;
 4145|       |               }
 4146|       |               else {
 4147|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 4148|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 4149|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 4150|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 4151|       |
 4152|       |                  // Track if we've encountered a tag and what value it had
 4153|       |                  std::optional<size_t> tag_specified_index{};
 4154|       |
 4155|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 4156|       |                     return;
 4157|       |                  }
 4158|       |                  auto start = it;
 4159|       |                  bool first_key = true;
 4160|       |                  // Parse bifurcation for tagged variants:
 4161|       |                  //
 4162|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 4163|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 4164|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 4165|       |                  //
 4166|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 4167|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 4168|       |                  // it advances past the trailing comma so the object parser picks up at the
 4169|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 4170|       |                  //
 4171|       |                  // One exception: if the tag name is also a field on the resolved struct
 4172|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 4173|       |                  // the struct field. This override is applied inside each std::visit lambda.
 4174|       |                  auto position_after_tag = [&] {
 4175|       |                     if (first_key) {
 4176|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 4177|       |                     }
 4178|       |                     else {
 4179|       |                        it = start; // tag was not the first key, re-parse from the beginning
 4180|       |                     }
 4181|       |                  };
 4182|       |                  while (*it != '}') {
 4183|       |                     if (it != start) {
 4184|       |                        first_key = false;
 4185|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 4186|       |                           return;
 4187|       |                        }
 4188|       |                     }
 4189|       |
 4190|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4191|       |                        return;
 4192|       |                     }
 4193|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4194|       |                        return;
 4195|       |                     }
 4196|       |
 4197|       |                     auto* key_start = it;
 4198|       |                     skip_string_view(ctx, it, end);
 4199|       |                     if (bool(ctx.error)) [[unlikely]]
 4200|       |                        return;
 4201|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 4202|       |                        return;
 4203|       |                     const sv key = {key_start, size_t(it - key_start)};
 4204|       |
 4205|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4206|       |                        return;
 4207|       |                     }
 4208|       |
 4209|       |                     if constexpr (deduction_key_count > 0) {
 4210|       |                        // We first check if a tag is defined and see if the key matches the tag
 4211|       |                        if constexpr (not tag_v<T>.empty()) {
 4212|       |                           if (key == tag_v<T>) {
 4213|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 4214|       |                                 return;
 4215|       |                              }
 4216|       |
 4217|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 4218|       |
 4219|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 4220|       |                              if constexpr (std::integral<id_type>) {
 4221|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4222|       |                              }
 4223|       |                              else {
 4224|       |                                 from<JSON, sv>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4225|       |                              }
 4226|       |                              if (bool(ctx.error)) [[unlikely]]
 4227|       |                                 return;
 4228|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4229|       |                                 return;
 4230|       |                              }
 4231|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4232|       |                                 ctx.error = error_code::syntax_error;
 4233|       |                                 return;
 4234|       |                              }
 4235|       |
 4236|       |                              size_t type_index;
 4237|       |                              if constexpr (std::integral<id_type>) {
 4238|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4239|       |                              }
 4240|       |                              else {
 4241|       |                                 type_index = variant_id_to_index<T>::op(
 4242|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4243|       |                              }
 4244|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4245|       |                                 // Check if the deduced types include the tag-specified type
 4246|       |                                 // If not, the tag doesn't match the fields
 4247|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4248|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4249|       |                                 // Check if the tag-specified type is still possible
 4250|       |                                 const bool type_is_possible = possible_types[type_index];
 4251|       |                                 if (!type_is_possible) {
 4252|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4253|       |                                    ctx.error = error_code::no_matching_variant_type;
 4254|       |                                    return;
 4255|       |                                 }
 4256|       |
 4257|       |                                 position_after_tag();
 4258|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4259|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4260|       |                                 std::visit(
 4261|       |                                    [&](auto&& v) {
 4262|       |                                       using V = std::decay_t<decltype(v)>;
 4263|       |                                       constexpr bool is_object =
 4264|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4265|       |                                       if constexpr (variant_unit_alternative<V>) {
 4266|       |                                          // A unit alternative carries no data; its object holds only the
 4267|       |                                          // discriminator. Consume that body through an empty reflected object so
 4268|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4269|       |                                          detail::variant_unit_body unit_body{};
 4270|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4271|       |                                                                                             tag_literal>(unit_body,
 4272|       |                                                                                                          ctx, it, end);
 4273|       |                                       }
 4274|       |                                       else if constexpr (is_object) {
 4275|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4276|       |                                             it = start; // tag is a struct field, must re-parse
 4277|       |                                          }
 4278|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4279|       |                                                                                                           end);
 4280|       |                                       }
 4281|       |                                       else if constexpr (is_memory_object<V>) {
 4282|       |                                          if (!v) {
 4283|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4284|       |                                                if constexpr (requires { v.emplace(); }) {
 4285|       |                                                   v.emplace();
 4286|       |                                                }
 4287|       |                                                else {
 4288|       |                                                   v = typename V::value_type{};
 4289|       |                                                }
 4290|       |                                             }
 4291|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4292|       |                                                v = std::make_unique<typename V::element_type>();
 4293|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4294|       |                                                v = std::make_shared<typename V::element_type>();
 4295|       |                                             else if constexpr (constructible<V>) {
 4296|       |                                                v = meta_construct_v<V>();
 4297|       |                                             }
 4298|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4299|       |                                                                can_allocate_raw_pointer<Opts,
 4300|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4301|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4302|       |                                                   return;
 4303|       |                                                }
 4304|       |                                             }
 4305|       |                                             else {
 4306|       |                                                ctx.error = error_code::invalid_nullable_read;
 4307|       |                                                return;
 4308|       |                                                // Cannot read into unset nullable that is not std::optional,
 4309|       |                                                // std::unique_ptr, or std::shared_ptr
 4310|       |                                             }
 4311|       |                                          }
 4312|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4313|       |                                             it = start; // tag is a struct field, must re-parse
 4314|       |                                          }
 4315|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4316|       |                                             *v, ctx, it, end);
 4317|       |                                       }
 4318|       |                                       else if constexpr (custom_read<V>) {
 4319|       |                                          // Custom handlers parse the remaining body themselves and do not
 4320|       |                                          // accept the tag template parameter; the tag was already consumed.
 4321|       |                                          // This only works when the tag was the first key. If it came later,
 4322|       |                                          // we were reset to the object start and the custom handler would
 4323|       |                                          // absorb the tag, so error rather than corrupt the value.
 4324|       |                                          if (it == start) {
 4325|       |                                             ctx.error = error_code::feature_not_supported;
 4326|       |                                             ctx.custom_error_message =
 4327|       |                                                "the tag must be the first key for a custom variant alternative";
 4328|       |                                             return;
 4329|       |                                          }
 4330|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4331|       |                                       }
 4332|       |                                    },
 4333|       |                                    value);
 4334|       |
 4335|       |                                 return; // we've decoded our target type
 4336|       |                              }
 4337|       |                              else [[unlikely]] {
 4338|       |                                 // Check if we have a default type (ids array shorter than variant)
 4339|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4340|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4341|       |                                 if constexpr (ids_size < variant_size) {
 4342|       |                                    // Use the first unlabeled type as the default
 4343|       |                                    const auto default_type_index = ids_size;
 4344|       |
 4345|       |                                    position_after_tag();
 4346|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4347|       |                                    if (value.index() != default_type_index)
 4348|       |                                       emplace_runtime_variant(value, default_type_index);
 4349|       |                                    std::visit(
 4350|       |                                       [&](auto&& v) {
 4351|       |                                          using V = std::decay_t<decltype(v)>;
 4352|       |                                          constexpr bool is_object =
 4353|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4354|       |                                          if constexpr (variant_unit_alternative<V>) {
 4355|       |                                             // A unit alternative carries no data; its object holds only the
 4356|       |                                             // discriminator. Consume that body through an empty reflected object so
 4357|       |                                             // unknown-key policy and terminator handling match every other
 4358|       |                                             // alternative.
 4359|       |                                             detail::variant_unit_body unit_body{};
 4360|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4361|       |                                                                                                tag_literal>(
 4362|       |                                                unit_body, ctx, it, end);
 4363|       |                                          }
 4364|       |                                          else if constexpr (is_object) {
 4365|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4366|       |                                                it = start; // tag is a struct field, must re-parse
 4367|       |                                             }
 4368|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4369|       |                                          }
 4370|       |                                          else if constexpr (is_memory_object<V>) {
 4371|       |                                             if (!v) {
 4372|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4373|       |                                                   if constexpr (requires { v.emplace(); }) {
 4374|       |                                                      v.emplace();
 4375|       |                                                   }
 4376|       |                                                   else {
 4377|       |                                                      v = typename V::value_type{};
 4378|       |                                                   }
 4379|       |                                                }
 4380|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4381|       |                                                   v = std::make_unique<typename V::element_type>();
 4382|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4383|       |                                                   v = std::make_shared<typename V::element_type>();
 4384|       |                                                else if constexpr (constructible<V>) {
 4385|       |                                                   v = meta_construct_v<V>();
 4386|       |                                                }
 4387|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4388|       |                                                                   can_allocate_raw_pointer<
 4389|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4390|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4391|       |                                                      return;
 4392|       |                                                   }
 4393|       |                                                }
 4394|       |                                                else {
 4395|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4396|       |                                                   return;
 4397|       |                                                }
 4398|       |                                             }
 4399|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4400|       |                                                it = start; // tag is a struct field, must re-parse
 4401|       |                                             }
 4402|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4403|       |                                                                                                              it, end);
 4404|       |                                          }
 4405|       |                                          else if constexpr (custom_read<V>) {
 4406|       |                                             // Custom handlers parse the remaining body themselves; this only
 4407|       |                                             // works when the tag was the first key (see above). If it came
 4408|       |                                             // later we were reset to the object start, so error rather than
 4409|       |                                             // let the custom handler absorb the tag.
 4410|       |                                             if (it == start) {
 4411|       |                                                ctx.error = error_code::feature_not_supported;
 4412|       |                                                ctx.custom_error_message =
 4413|       |                                                   "the tag must be the first key for a custom variant alternative";
 4414|       |                                                return;
 4415|       |                                             }
 4416|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4417|       |                                          }
 4418|       |                                       },
 4419|       |                                       value);
 4420|       |
 4421|       |                                    return;
 4422|       |                                 }
 4423|       |                                 else {
 4424|       |                                    ctx.error = error_code::no_matching_variant_type;
 4425|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4426|       |                                    return;
 4427|       |                                 }
 4428|       |                              }
 4429|       |                           }
 4430|       |                        }
 4431|       |
 4432|       |                        // Inline decode_hash lookup for variant deduction
 4433|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4434|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4435|       |                        const auto deduction_index =
 4436|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4437|       |                              key.data(), key.data() + key.size(), key.size());
 4438|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4439|       |                           [[likely]] {
 4440|       |                           possible_types &= deduction_bits[deduction_index];
 4441|       |                        }
 4442|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4443|       |                           ctx.error = error_code::unknown_key;
 4444|       |                           return;
 4445|       |                        }
 4446|       |                     }
 4447|       |                     else if constexpr (not tag_v<T>.empty()) {
 4448|       |                        // empty object case for variant, if there are no normal elements
 4449|       |                        if (key == tag_v<T>) {
 4450|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4451|       |                              return;
 4452|       |                           }
 4453|       |
 4454|       |                           std::string_view type_id{};
 4455|       |                           parse<JSON>::op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4456|       |                           if (bool(ctx.error)) [[unlikely]]
 4457|       |                              return;
 4458|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4459|       |                              return;
 4460|       |                           }
 4461|       |
 4462|       |                           const auto type_index = variant_id_to_index<T>::op(
 4463|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4464|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4465|       |                              position_after_tag();
 4466|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4467|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4468|       |                           }
 4469|       |                           else {
 4470|       |                              // Check if we have a default type (ids array shorter than variant)
 4471|       |                              constexpr auto ids_size = ids_v<T>.size();
 4472|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4473|       |                              if constexpr (ids_size < variant_size) {
 4474|       |                                 // Use the first unlabeled type as the default
 4475|       |                                 position_after_tag();
 4476|       |                                 const auto default_index = ids_size;
 4477|       |                                 tag_specified_index = default_index; // Store the default type index
 4478|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4479|       |                              }
 4480|       |                              else {
 4481|       |                                 ctx.error = error_code::no_matching_variant_type;
 4482|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4483|       |                                 return;
 4484|       |                              }
 4485|       |                           }
 4486|       |                           // Parse the type (handles tag skipping and unknown keys)
 4487|       |                           std::visit(
 4488|       |                              [&](auto&& v) {
 4489|       |                                 using V = std::decay_t<decltype(v)>;
 4490|       |                                 if constexpr (custom_read<V>) {
 4491|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4492|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4493|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4494|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4495|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4496|       |                                    // into its value, so error here rather than corrupt the result.
 4497|       |                                    if (it == start) {
 4498|       |                                       ctx.error = error_code::feature_not_supported;
 4499|       |                                       ctx.custom_error_message =
 4500|       |                                          "the tag must be the first key for a custom variant alternative";
 4501|       |                                       return;
 4502|       |                                    }
 4503|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4504|       |                                 }
 4505|       |                                 else {
 4506|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4507|       |                                       it = start; // tag is a struct field, must re-parse
 4508|       |                                    }
 4509|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4510|       |                                 }
 4511|       |                              },
 4512|       |                              value);
 4513|       |                           return;
 4514|       |                        }
 4515|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4516|       |                           ctx.error = error_code::unknown_key;
 4517|       |                           return;
 4518|       |                        }
 4519|       |                        else {
 4520|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4521|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4522|       |                              return;
 4523|       |                           }
 4524|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4525|       |                           if (bool(ctx.error)) [[unlikely]]
 4526|       |                              return;
 4527|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4528|       |                              return;
 4529|       |                           }
 4530|       |                           continue; // Continue loop to find the tag
 4531|       |                        }
 4532|       |                     }
 4533|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4534|       |                        ctx.error = error_code::unknown_key;
 4535|       |                        return;
 4536|       |                     }
 4537|       |
 4538|       |                     auto matching_types = possible_types.popcount();
 4539|       |                     if (matching_types == 0) {
 4540|       |                        ctx.error = error_code::no_matching_variant_type;
 4541|       |                        return;
 4542|       |                     }
 4543|       |                     // Only short-circuit for variants without tags
 4544|       |                     else if constexpr (tag_v<T>.empty()) {
 4545|       |                        if (matching_types == 1) {
 4546|       |                           it = start;
 4547|       |                           const auto type_index = possible_types.countr_zero();
 4548|       |
 4549|       |                           if (value.index() != static_cast<size_t>(type_index))
 4550|       |                              emplace_runtime_variant(value, type_index);
 4551|       |                           std::visit(
 4552|       |                              [&](auto&& v) {
 4553|       |                                 using V = std::decay_t<decltype(v)>;
 4554|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4555|       |                                 if constexpr (variant_unit_alternative<V>) {
 4556|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4557|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4558|       |                                    // terminator handling match every other alternative.
 4559|       |                                    detail::variant_unit_body unit_body{};
 4560|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4561|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4562|       |                                                                                                    end);
 4563|       |                                 }
 4564|       |                                 else if constexpr (is_object) {
 4565|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4566|       |                                 }
 4567|       |                                 else if constexpr (is_memory_object<V>) {
 4568|       |                                    if (!v) {
 4569|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4570|       |                                          if constexpr (requires { v.emplace(); }) {
 4571|       |                                             v.emplace();
 4572|       |                                          }
 4573|       |                                          else {
 4574|       |                                             v = typename V::value_type{};
 4575|       |                                          }
 4576|       |                                       }
 4577|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4578|       |                                          v = std::make_unique<typename V::element_type>();
 4579|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4580|       |                                          v = std::make_shared<typename V::element_type>();
 4581|       |                                       else if constexpr (constructible<V>) {
 4582|       |                                          v = meta_construct_v<V>();
 4583|       |                                       }
 4584|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4585|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4586|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4587|       |                                             return;
 4588|       |                                          }
 4589|       |                                       }
 4590|       |                                       else {
 4591|       |                                          ctx.error = error_code::invalid_nullable_read;
 4592|       |                                          return;
 4593|       |                                          // Cannot read into unset nullable that is not std::optional,
 4594|       |                                          // std::unique_ptr, or std::shared_ptr
 4595|       |                                       }
 4596|       |                                    }
 4597|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4598|       |                                       *v, ctx, it, end);
 4599|       |                                 }
 4600|       |                                 else if constexpr (custom_read<V>) {
 4601|       |                                    // Custom handlers parse the remaining body themselves.
 4602|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4603|       |                                 }
 4604|       |                              },
 4605|       |                              value);
 4606|       |
 4607|       |                           return; // we've decoded our target type
 4608|       |                        }
 4609|       |                     }
 4610|       |                     // For tagged variants, continue processing to validate tags
 4611|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4612|       |                        return;
 4613|       |                     }
 4614|       |
 4615|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4616|       |                     if (bool(ctx.error)) [[unlikely]]
 4617|       |                        return;
 4618|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4619|       |                        return;
 4620|       |                     }
 4621|       |                  }
 4622|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4623|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4624|       |                     // After parsing all keys, check if we have multiple matching types
 4625|       |                     // If so, choose the one with the fewest fields
 4626|       |                     auto final_matching = possible_types.popcount();
 4627|       |                     if (final_matching == 0) {
 4628|       |                        ctx.error = error_code::no_matching_variant_type;
 4629|       |                     }
 4630|       |                     else if (final_matching == 1) {
 4631|       |                        // Single type remains after field deduction
 4632|       |                        const auto type_index = possible_types.countr_zero();
 4633|       |
 4634|       |                        // Validate against tag if one was specified
 4635|       |                        if (tag_specified_index.has_value() &&
 4636|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4637|       |                           ctx.error = error_code::no_matching_variant_type;
 4638|       |                           return;
 4639|       |                        }
 4640|       |
 4641|       |                        it = start;
 4642|       |                        if (value.index() != static_cast<size_t>(type_index))
 4643|       |                           emplace_runtime_variant(value, type_index);
 4644|       |                        std::visit(
 4645|       |                           [&](auto&& v) {
 4646|       |                              using V = std::decay_t<decltype(v)>;
 4647|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4648|       |                              if constexpr (variant_unit_alternative<V>) {
 4649|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4650|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4651|       |                                 // terminator handling match every other alternative.
 4652|       |                                 detail::variant_unit_body unit_body{};
 4653|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4654|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4655|       |                                                                                                 end);
 4656|       |                              }
 4657|       |                              else if constexpr (is_object) {
 4658|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4659|       |                              }
 4660|       |                              else if constexpr (is_memory_object<V>) {
 4661|       |                                 if (!v) {
 4662|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4663|       |                                       if constexpr (requires { v.emplace(); }) {
 4664|       |                                          v.emplace();
 4665|       |                                       }
 4666|       |                                       else {
 4667|       |                                          v = typename V::value_type{};
 4668|       |                                       }
 4669|       |                                    }
 4670|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4671|       |                                       v = std::make_unique<typename V::element_type>();
 4672|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4673|       |                                       v = std::make_shared<typename V::element_type>();
 4674|       |                                    else if constexpr (constructible<V>) {
 4675|       |                                       v = meta_construct_v<V>();
 4676|       |                                    }
 4677|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4678|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4679|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4680|       |                                          return;
 4681|       |                                       }
 4682|       |                                    }
 4683|       |                                    else {
 4684|       |                                       ctx.error = error_code::invalid_nullable_read;
 4685|       |                                       return;
 4686|       |                                    }
 4687|       |                                 }
 4688|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4689|       |                                                                                                               it, end);
 4690|       |                              }
 4691|       |                              else if constexpr (custom_read<V>) {
 4692|       |                                 // Custom handlers parse the remaining body themselves.
 4693|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4694|       |                              }
 4695|       |                           },
 4696|       |                           value);
 4697|       |                     }
 4698|       |                     else if (final_matching > 1) {
 4699|       |                        constexpr auto N = std::variant_size_v<T>;
 4700|       |
 4701|       |                        // Compile-time array of field counts for each variant type
 4702|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4703|       |                           return std::array<size_t, N> {
 4704|       |                              ([]<size_t J = I>() -> size_t {
 4705|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4706|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4707|       |                                    return reflect<V>::size;
 4708|       |                                 }
 4709|       |                                 else if constexpr (is_memory_object<V>) {
 4710|       |                                    using X = memory_type<V>;
 4711|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4712|       |                                       return reflect<X>::size;
 4713|       |                                    }
 4714|       |                                    else {
 4715|       |                                       return (std::numeric_limits<size_t>::max)();
 4716|       |                                    }
 4717|       |                                 }
 4718|       |                                 else {
 4719|       |                                    return (std::numeric_limits<size_t>::max)();
 4720|       |                                 }
 4721|       |                              }.template operator()<I>())...
 4722|       |                           };
 4723|       |                        }(std::make_index_sequence<N>{});
 4724|       |
 4725|       |                        // Find the type with minimum field count among the possible types
 4726|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4727|       |                        size_t chosen_index = N; // Invalid index initially
 4728|       |
 4729|       |                        for (size_t i = 0; i < N; ++i) {
 4730|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4731|       |                              min_fields = field_counts[i];
 4732|       |                              chosen_index = i;
 4733|       |                           }
 4734|       |                        }
 4735|       |
 4736|       |                        if (chosen_index < N) {
 4737|       |                           // Validate against tag if one was specified
 4738|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4739|       |                              ctx.error = error_code::no_matching_variant_type;
 4740|       |                              return;
 4741|       |                           }
 4742|       |
 4743|       |                           it = start;
 4744|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4745|       |                           std::visit(
 4746|       |                              [&](auto&& v) {
 4747|       |                                 using V = std::decay_t<decltype(v)>;
 4748|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4749|       |                                 if constexpr (variant_unit_alternative<V>) {
 4750|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4751|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4752|       |                                    // terminator handling match every other alternative.
 4753|       |                                    detail::variant_unit_body unit_body{};
 4754|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4755|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4756|       |                                                                                                    end);
 4757|       |                                 }
 4758|       |                                 else if constexpr (is_object) {
 4759|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4760|       |                                 }
 4761|       |                                 else if constexpr (is_memory_object<V>) {
 4762|       |                                    if (!v) {
 4763|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4764|       |                                          if constexpr (requires { v.emplace(); }) {
 4765|       |                                             v.emplace();
 4766|       |                                          }
 4767|       |                                          else {
 4768|       |                                             v = typename V::value_type{};
 4769|       |                                          }
 4770|       |                                       }
 4771|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4772|       |                                          v = std::make_unique<typename V::element_type>();
 4773|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4774|       |                                          v = std::make_shared<typename V::element_type>();
 4775|       |                                       else if constexpr (constructible<V>) {
 4776|       |                                          v = meta_construct_v<V>();
 4777|       |                                       }
 4778|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4779|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4780|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4781|       |                                             return;
 4782|       |                                          }
 4783|       |                                       }
 4784|       |                                       else {
 4785|       |                                          ctx.error = error_code::invalid_nullable_read;
 4786|       |                                          return;
 4787|       |                                       }
 4788|       |                                    }
 4789|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4790|       |                                       *v, ctx, it, end);
 4791|       |                                 }
 4792|       |                                 else if constexpr (custom_read<V>) {
 4793|       |                                    // Custom handlers parse the remaining body themselves.
 4794|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4795|       |                                 }
 4796|       |                              },
 4797|       |                              value);
 4798|       |                        }
 4799|       |                        else {
 4800|       |                           ctx.error = error_code::no_matching_variant_type;
 4801|       |                        }
 4802|       |                     }
 4803|       |                  }
 4804|       |                  else {
 4805|       |                     // For variants with 0 or 1 object types, use the original error handling
 4806|       |                     ctx.error = error_code::no_matching_variant_type;
 4807|       |                  }
 4808|       |               }
 4809|      0|               break;
 4810|  23.2k|            }
 4811|   643k|            case '[':
  ------------------
  |  Branch (4811:13): [True: 643k, False: 2.05M]
  ------------------
 4812|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4813|   643k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4814|   643k|               break;
 4815|  5.83k|            case '"': {
  ------------------
  |  Branch (4815:13): [True: 5.83k, False: 2.69M]
  ------------------
 4816|  5.83k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4817|  5.83k|               break;
 4818|  23.2k|            }
 4819|    873|            case 't':
  ------------------
  |  Branch (4819:13): [True: 873, False: 2.69M]
  ------------------
 4820|  1.16k|            case 'f': {
  ------------------
  |  Branch (4820:13): [True: 287, False: 2.69M]
  ------------------
 4821|  1.16k|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4822|  1.16k|               break;
 4823|    873|            }
 4824|    592|            case 'n':
  ------------------
  |  Branch (4824:13): [True: 592, False: 2.69M]
  ------------------
 4825|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4826|       |                  ctx.error = error_code::no_matching_variant_type;
 4827|       |               }
 4828|    592|               else {
 4829|    592|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4830|    592|                  using V = std::variant_alternative_t<first_idx, T>;
 4831|    592|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4831:23): [True: 202, False: 390]
  ------------------
 4832|    592|                  match<"null", Opts>(ctx, it, end);
 4833|    592|               }
 4834|    592|               break;
 4835|  2.02M|            default: {
  ------------------
  |  Branch (4835:13): [True: 2.02M, False: 673k]
  ------------------
 4836|       |               // Not bool, string, object, or array so must be number or null
 4837|  2.02M|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4838|  2.02M|            }
 4839|  2.69M|            }
 4840|       |         }
 4841|       |         else {
 4842|       |            // For non-auto-deducible variants, try each type until one succeeds
 4843|       |            constexpr auto N = std::variant_size_v<T>;
 4844|       |            bool parsed = false;
 4845|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4846|       |
 4847|       |            for_each<N>([&]<size_t I>() {
 4848|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4849|       |
 4850|       |               auto copy_it = it;
 4851|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4852|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4853|       |               const auto copy_depth = ctx.depth;
 4854|       |
 4855|       |               // Try parsing as this type
 4856|       |               if (value.index() != I) {
 4857|       |                  emplace_runtime_variant(value, I);
 4858|       |               }
 4859|       |
 4860|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4861|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4862|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4863|       |               }
 4864|       |
 4865|       |               if (!bool(ctx.error)) {
 4866|       |                  parsed = true;
 4867|       |               }
 4868|       |               else if constexpr (not Options.null_terminated) {
 4869|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4870|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4871|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4872|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4873|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4874|       |                     parsed = true;
 4875|       |                     ctx.error = error_code::none;
 4876|       |                  }
 4877|       |                  else {
 4878|       |                     // Reset for next attempt (unless this is the last type)
 4879|       |                     it = copy_it;
 4880|       |                     rewind_depth<Options>(ctx, copy_depth);
 4881|       |                     if constexpr (I + 1 < N) {
 4882|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4883|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4884|       |                        }
 4885|       |                     }
 4886|       |                  }
 4887|       |               }
 4888|       |               else {
 4889|       |                  // Reset for next attempt (unless this is the last type)
 4890|       |                  it = copy_it;
 4891|       |                  rewind_depth<Options>(ctx, copy_depth);
 4892|       |                  if constexpr (I + 1 < N) {
 4893|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4894|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4895|       |                     }
 4896|       |                  }
 4897|       |               }
 4898|       |            });
 4899|       |         }
 4900|  2.69M|      }
_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_:
 3765|   645k|      {
 3766|   645k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3767|       |
 3768|       |         if constexpr (category_count == 0) {
 3769|       |            ctx.error = error_code::no_matching_variant_type;
 3770|       |         }
 3771|   645k|         else {
 3772|   645k|            constexpr auto N = std::variant_size_v<Variant>;
 3773|   645k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3774|   645k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3775|       |
 3776|   645k|            bool found_match{};
 3777|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3778|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3779|       |            // so the budget stops it and the failure already in hand is reported.
 3780|   645k|            bool exhausted{};
 3781|       |
 3782|       |            // First pass: const glaze types in this category
 3783|       |            if constexpr (const_count > 0) {
 3784|       |               for_each<N>([&]<size_t I>() {
 3785|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3786|       |                     return;
 3787|       |                  }
 3788|       |                  using V = std::variant_alternative_t<I, Variant>;
 3789|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3790|       |                     // run time substitute to compare to const value
 3791|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3792|       |                     auto copy_it{it};
 3793|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3794|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3795|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3796|       |                     const auto copy_depth{ctx.depth};
 3797|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3798|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3799|       |                     if (substitute == const_value) {
 3800|       |                        found_match = true;
 3801|       |                        if (!std::holds_alternative<V>(value)) {
 3802|       |                           value = V{};
 3803|       |                        }
 3804|       |                     }
 3805|       |                     else {
 3806|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3807|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3808|       |                           exhausted = true;
 3809|       |                        }
 3810|       |                        if constexpr (not Options.null_terminated) {
 3811|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3812|       |                              ctx.error = error_code::none;
 3813|       |                           }
 3814|       |                        }
 3815|       |                        it = copy_it;
 3816|       |                        rewind_depth<Options>(ctx, copy_depth);
 3817|       |                     }
 3818|       |                  }
 3819|       |               });
 3820|       |               if (found_match) {
 3821|       |                  return;
 3822|       |               }
 3823|       |            }
 3824|       |
 3825|       |            // Second pass: non-const types in this category
 3826|   645k|            if constexpr (non_const_count > 0) {
 3827|       |               // Track position within matching types for "is last" check.
 3828|       |               // We iterate over all variant indices but only process matching types,
 3829|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3830|       |               // the loop index directly corresponded to position in filtered set).
 3831|       |               // This has negligible cost: one increment per matching type.
 3832|   645k|               size_t non_const_idx = 0;
 3833|       |
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3836|   645k|                     return;
 3837|   645k|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|   645k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|   645k|                     auto copy_it{it};
 3841|   645k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|   645k|                     if (!std::holds_alternative<V>(value)) {
 3843|   645k|                        value = V{};
 3844|   645k|                     }
 3845|   645k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|   645k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|   645k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|   645k|                     }
 3849|   645k|                     if (!bool(ctx.error)) {
 3850|   645k|                        found_match = true;
 3851|   645k|                     }
 3852|   645k|                     else if constexpr (not Options.null_terminated) {
 3853|   645k|                        constexpr bool is_complete_type =
 3854|   645k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|   645k|                        if constexpr (is_complete_type) {
 3857|   645k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|   645k|                              found_match = true;
 3859|   645k|                              ctx.error = error_code::none;
 3860|   645k|                           }
 3861|   645k|                           else {
 3862|   645k|                              it = copy_it;
 3863|   645k|                              rewind_depth<Options>(ctx, copy_depth);
 3864|   645k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|   645k|                                  not variant_alternative_exhausted(ctx)) {
 3866|   645k|                                 ctx.error = error_code::none;
 3867|   645k|                              }
 3868|   645k|                           }
 3869|   645k|                        }
 3870|   645k|                        else {
 3871|   645k|                           it = copy_it;
 3872|   645k|                           rewind_depth<Options>(ctx, copy_depth);
 3873|   645k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|   645k|                               not variant_alternative_exhausted(ctx)) {
 3875|   645k|                              ctx.error = error_code::none;
 3876|   645k|                           }
 3877|   645k|                        }
 3878|   645k|                     }
 3879|   645k|                     else {
 3880|   645k|                        it = copy_it;
 3881|   645k|                        rewind_depth<Options>(ctx, copy_depth);
 3882|   645k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|   645k|                            not variant_alternative_exhausted(ctx)) {
 3884|   645k|                           ctx.error = error_code::none;
 3885|   645k|                        }
 3886|   645k|                     }
 3887|   645k|                     ++non_const_idx;
 3888|   645k|                  }
 3889|   645k|               });
 3890|   645k|               if (!found_match) {
  ------------------
  |  Branch (3890:20): [True: 13.3k, False: 631k]
  ------------------
 3891|  13.3k|                  if constexpr (non_const_count == 1) {
 3892|       |                     // Keep the specific error from the single type we tried
 3893|       |                  }
 3894|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3895|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3896|       |                     ctx.error = error_code::no_matching_variant_type;
 3897|       |                  }
 3898|  13.3k|               }
 3899|       |            }
 3900|       |            else {
 3901|       |               ctx.error = error_code::no_matching_variant_type;
 3902|       |            }
 3903|   645k|         }
 3904|   645k|      }
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|   645k|               });
_ZN3glz29variant_alternative_exhaustedITkNS_10is_contextENS_7contextEEEbRT_:
 3754|  21.9M|   {
 3755|  21.9M|      return ctx.error == error_code::exceeded_max_recursive_depth;
 3756|  21.9M|   }
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|   645k|               });
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|   645k|               });
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|   645k|               });
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|   645k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|   645k|                     auto copy_it{it};
 3841|   645k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|   645k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3842:26): [True: 481k, False: 163k]
  ------------------
 3843|   481k|                        value = V{};
 3844|   481k|                     }
 3845|   645k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|   645k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3846:26): [True: 13.3k, False: 631k]
  |  Branch (3846:45): [True: 0, False: 13.3k]
  ------------------
 3847|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|      0|                     }
 3849|   645k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3849:26): [True: 631k, False: 13.3k]
  ------------------
 3850|   631k|                        found_match = true;
 3851|   631k|                     }
 3852|  13.3k|                     else if constexpr (not Options.null_terminated) {
 3853|  13.3k|                        constexpr bool is_complete_type =
 3854|  13.3k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
  ------------------
  |  Branch (3854:28): [Folded, False: 0]
  |  Branch (3854:40): [Folded, False: 0]
  |  Branch (3854:53): [Folded, False: 0]
  |  Branch (3854:68): [Folded, False: 0]
  |  Branch (3854:89): [Folded, False: 0]
  |  Branch (3854:103): [Folded, False: 0]
  ------------------
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|  13.3k|                        else {
 3871|  13.3k|                           it = copy_it;
 3872|  13.3k|                           rewind_depth<Options>(ctx, copy_depth);
 3873|  13.3k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3873:32): [True: 0, False: 13.3k]
  |  Branch (3873:71): [True: 0, False: 0]
  ------------------
 3874|      0|                               not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3874:32): [True: 0, False: 0]
  ------------------
 3875|      0|                              ctx.error = error_code::none;
 3876|      0|                           }
 3877|  13.3k|                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|   645k|                     ++non_const_idx;
 3888|   645k|                  }
 3889|   645k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS4_9allocatorIS9_EEEETkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
   49|   645k|      {
   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|   645k|         else {
   60|   645k|            using V = std::remove_cvref_t<T>;
   61|   645k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|   645k|                                             end);
   63|   645k|         }
   64|   645k|      }
_ZN3glz4fromILj10ENSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS1_9allocatorIS6_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERS9_TkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
 2349|   645k|      {
 2350|   645k|         constexpr auto Opts = ws_handled_off<Options>();
 2351|       |         if constexpr (!check_ws_handled(Options)) {
 2352|       |            if (skip_ws<Opts>(ctx, it, end)) {
 2353|       |               return;
 2354|       |            }
 2355|       |         }
 2356|       |
 2357|   645k|         if (match_invalid_end<'[', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2357:14): [True: 107, False: 644k]
  ------------------
 2358|    107|            return;
 2359|    107|         }
 2360|       |         // one nesting level (see enter_depth): counted in both modes so the limit binds,
 2361|       |         // released at each syntactic close below
 2362|   644k|         if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (2362:14): [True: 10, False: 644k]
  ------------------
 2363|     10|            return;
 2364|     10|         }
 2365|       |
 2366|   644k|         const auto ws_start = it;
 2367|   644k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2367:14): [True: 52, False: 644k]
  ------------------
 2368|     52|            return;
 2369|     52|         }
 2370|       |
 2371|   644k|         if (*it == ']') {
  ------------------
  |  Branch (2371:14): [True: 4.70k, False: 640k]
  ------------------
 2372|  4.70k|            --ctx.depth;
 2373|  4.70k|            ++it;
 2374|  4.70k|            if constexpr ((resizable<T> || is_inplace_vector<T>) && not check_append_arrays(Opts)) {
 2375|  4.70k|               value.clear();
 2376|       |
 2377|       |               if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2378|       |                  value.shrink_to_fit();
 2379|       |               }
 2380|  4.70k|            }
 2381|  4.70k|            return;
 2382|  4.70k|         }
 2383|       |
 2384|   640k|         const size_t ws_size = size_t(it - ws_start);
 2385|       |
 2386|   640k|         static constexpr bool should_append = (resizable<T> || is_inplace_vector<T>) && check_append_arrays(Opts);
  ------------------
  |  Branch (2386:49): [True: 640k, Folded]
  |  Branch (2386:65): [Folded, False: 0]
  |  Branch (2386:90): [Folded, False: 0]
  ------------------
 2387|   640k|         if constexpr (not should_append) {
 2388|   640k|            const auto n = value.size();
 2389|       |
 2390|   640k|            auto value_it = value.begin();
 2391|       |
 2392|   647k|            for (size_t i = 0; i < n; ++i) {
  ------------------
  |  Branch (2392:32): [True: 168k, False: 479k]
  ------------------
 2393|   168k|               parse<JSON>::op<ws_handled<Opts>()>(*value_it++, ctx, it, end);
 2394|   168k|               if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2394:20): [True: 801, False: 167k]
  ------------------
 2395|    801|                  return;
 2396|   167k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2396:20): [True: 46, False: 167k]
  ------------------
 2397|     46|                  return;
 2398|     46|               }
 2399|   167k|               if (*it == ',') {
  ------------------
  |  Branch (2399:20): [True: 7.93k, False: 159k]
  ------------------
 2400|  7.93k|                  ++it;
 2401|       |
 2402|  7.93k|                  if constexpr (!Opts.minified && !Opts.comments) {
 2403|  7.93k|                     if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2403:26): [True: 5.18k, False: 2.74k]
  |  Branch (2403:37): [True: 4.57k, False: 614]
  ------------------
 2404|  4.57k|                        skip_matching_ws(ws_start, it, ws_size);
 2405|  4.57k|                     }
 2406|  7.93k|                  }
 2407|       |
 2408|  7.93k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2408:23): [True: 100, False: 7.83k]
  ------------------
 2409|    100|                     return;
 2410|    100|                  }
 2411|  7.93k|               }
 2412|   159k|               else if (*it == ']') {
  ------------------
  |  Branch (2412:25): [True: 159k, False: 47]
  ------------------
 2413|   159k|                  --ctx.depth;
 2414|   159k|                  ++it;
 2415|   159k|                  if constexpr (erasable<T>) {
 2416|   159k|                     value.erase(value_it,
 2417|   159k|                                 value.end()); // use erase rather than resize for non-default constructible elements
 2418|       |
 2419|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2420|       |                        value.shrink_to_fit();
 2421|       |                     }
 2422|   159k|                  }
 2423|   159k|                  return;
 2424|   159k|               }
 2425|     47|               else [[unlikely]] {
 2426|     47|                  ctx.error = error_code::expected_bracket;
 2427|     47|                  return;
 2428|     47|               }
 2429|   167k|            }
 2430|   640k|         }
 2431|       |
 2432|       |         if constexpr (Opts.partial_read) {
 2433|       |            // partial_read stops early on a success path, so give the level back like the
 2434|       |            // syntactic-close paths do; otherwise it accumulates across reads sharing a context.
 2435|       |            --ctx.depth;
 2436|       |            return;
 2437|       |         }
 2438|   640k|         else {
 2439|       |            // growing
 2440|   640k|            if constexpr (emplace_backable<T> || has_try_emplace_back<T>) {
 2441|  1.75M|               while (it < end) {
  ------------------
  |  Branch (2441:23): [True: 1.59M, False: 160k]
  ------------------
 2442|       |                  // Streaming refill point: at start of each iteration, ensure buffer has data
 2443|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2444|       |                     if (ctx.stream.enabled()) {
 2445|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2446|       |                        const size_t remaining = ctx.stream.size() - consumed;
 2447|       |                        // Refill when less than half of buffer remains to ensure space for next element
 2448|       |                        if (remaining <= ctx.stream.size() / 2 || it >= end) {
 2449|       |                           const char* new_it;
 2450|       |                           const char* new_end;
 2451|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2452|       |                           it = new_it;
 2453|       |                           end = new_end;
 2454|       |                           if (it >= end && ctx.stream.at_eof()) {
 2455|       |                              break; // No more data, exit loop normally
 2456|       |                           }
 2457|       |                        }
 2458|       |                     }
 2459|       |                  }
 2460|       |
 2461|       |                  if constexpr (has_try_emplace_back<T>) {
 2462|       |                     if (value.try_emplace_back())
 2463|       |                        parse<JSON>::op<ws_handled<Opts>()>(value.back(), ctx, it, end);
 2464|       |                     else
 2465|       |                        ctx.error = error_code::exceeded_static_array_size;
 2466|       |                  }
 2467|  1.59M|                  else {
 2468|  1.59M|                     parse<JSON>::op<ws_handled<Opts>()>(value.emplace_back(), ctx, it, end);
 2469|  1.59M|                  }
 2470|       |
 2471|  1.59M|                  if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2471:23): [True: 11.0k, False: 1.58M]
  ------------------
 2472|  11.0k|                     return;
 2473|       |
 2474|       |                  // Streaming refill point: after parsing each element, refill if buffer is low
 2475|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2476|       |                     if (ctx.stream.enabled()) {
 2477|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2478|       |                        // Refill when less than 25% of buffer remains to ensure enough space for next element
 2479|       |                        if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 2480|       |                           const char* new_it;
 2481|       |                           const char* new_end;
 2482|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2483|       |                           it = new_it;
 2484|       |                           end = new_end;
 2485|       |                           if (it >= end && ctx.stream.at_eof()) {
 2486|       |                              ctx.error = error_code::unexpected_end;
 2487|       |                              return;
 2488|       |                           }
 2489|       |                        }
 2490|       |                     }
 2491|       |                  }
 2492|       |
 2493|  1.58M|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2493:23): [True: 614, False: 1.58M]
  ------------------
 2494|    614|                     return;
 2495|    614|                  }
 2496|  1.58M|                  if (*it == ',') [[likely]] {
  ------------------
  |  Branch (2496:23): [True: 1.11M, False: 467k]
  ------------------
 2497|  1.11M|                     ++it;
 2498|       |
 2499|  1.11M|                     if constexpr (!Opts.minified && !Opts.comments) {
 2500|  1.11M|                        if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2500:29): [True: 27.4k, False: 1.09M]
  |  Branch (2500:40): [True: 26.7k, False: 713]
  ------------------
 2501|  26.7k|                           skip_matching_ws(ws_start, it, ws_size);
 2502|  26.7k|                        }
 2503|  1.11M|                     }
 2504|       |
 2505|  1.11M|                     if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2505:26): [True: 216, False: 1.11M]
  ------------------
 2506|    216|                        return;
 2507|    216|                     }
 2508|  1.11M|                  }
 2509|   467k|                  else if (*it == ']') {
  ------------------
  |  Branch (2509:28): [True: 467k, False: 395]
  ------------------
 2510|   467k|                     --ctx.depth;
 2511|   467k|                     ++it;
 2512|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2513|       |                        value.shrink_to_fit();
 2514|       |                     }
 2515|   467k|                     return;
 2516|   467k|                  }
 2517|    395|                  else [[unlikely]] {
 2518|    395|                     ctx.error = error_code::expected_bracket;
 2519|    395|                     return;
 2520|    395|                  }
 2521|  1.58M|               }
 2522|       |
 2523|       |               // A valid array always returns from inside the loop upon reaching ']'.
 2524|       |               // For a null-terminated buffer the loop can only exit here by falling
 2525|       |               // through when `it` reaches the terminator without a closing bracket,
 2526|       |               // which means the input was truncated (e.g. "[", "[1," or "[1,2,").
 2527|       |               // Non-null-terminated buffers surface this through skip_ws/depth
 2528|       |               // tracking (or the streaming refill break), so this guard is limited
 2529|       |               // to the null-terminated case.
 2530|       |               if constexpr (Opts.null_terminated) {
 2531|       |                  ctx.error = error_code::unexpected_end;
 2532|       |               }
 2533|       |            }
 2534|       |            else {
 2535|       |               ctx.error = error_code::exceeded_static_array_size;
 2536|       |            }
 2537|   640k|         }
 2538|   640k|      }
_ZN3glz12rewind_depthITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextENS_7contextEEEvRT0_j:
 3737|  15.8k|   {
 3738|  15.8k|      if (ctx.error == error_code::exceeded_max_recursive_depth) [[unlikely]] {
  ------------------
  |  Branch (3738:11): [True: 1.10k, False: 14.6k]
  ------------------
 3739|  1.10k|         return;
 3740|  1.10k|      }
 3741|       |      if constexpr (Opts.null_terminated) {
 3742|       |         ctx.depth = depth;
 3743|       |      }
 3744|  14.6k|      else {
 3745|  14.6k|         if (ctx.error != error_code::end_reached && ctx.error != error_code::unexpected_end) {
  ------------------
  |  Branch (3745:14): [True: 12.1k, False: 2.53k]
  |  Branch (3745:54): [True: 6.70k, False: 5.46k]
  ------------------
 3746|  6.70k|            ctx.depth = depth;
 3747|  6.70k|         }
 3748|  14.6k|      }
 3749|  14.6k|   }
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 631k, False: 13.3k]
  |  Branch (3835:38): [True: 0, False: 13.3k]
  |  Branch (3835:51): [True: 1.10k, False: 12.2k]
  ------------------
 3836|   632k|                     return;
 3837|   632k|                  }
 3838|  12.2k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  12.2k|               });
_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_:
 3765|  6.89k|      {
 3766|  6.89k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3767|       |
 3768|       |         if constexpr (category_count == 0) {
 3769|       |            ctx.error = error_code::no_matching_variant_type;
 3770|       |         }
 3771|  6.89k|         else {
 3772|  6.89k|            constexpr auto N = std::variant_size_v<Variant>;
 3773|  6.89k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3774|  6.89k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3775|       |
 3776|  6.89k|            bool found_match{};
 3777|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3778|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3779|       |            // so the budget stops it and the failure already in hand is reported.
 3780|  6.89k|            bool exhausted{};
 3781|       |
 3782|       |            // First pass: const glaze types in this category
 3783|       |            if constexpr (const_count > 0) {
 3784|       |               for_each<N>([&]<size_t I>() {
 3785|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3786|       |                     return;
 3787|       |                  }
 3788|       |                  using V = std::variant_alternative_t<I, Variant>;
 3789|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3790|       |                     // run time substitute to compare to const value
 3791|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3792|       |                     auto copy_it{it};
 3793|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3794|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3795|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3796|       |                     const auto copy_depth{ctx.depth};
 3797|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3798|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3799|       |                     if (substitute == const_value) {
 3800|       |                        found_match = true;
 3801|       |                        if (!std::holds_alternative<V>(value)) {
 3802|       |                           value = V{};
 3803|       |                        }
 3804|       |                     }
 3805|       |                     else {
 3806|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3807|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3808|       |                           exhausted = true;
 3809|       |                        }
 3810|       |                        if constexpr (not Options.null_terminated) {
 3811|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3812|       |                              ctx.error = error_code::none;
 3813|       |                           }
 3814|       |                        }
 3815|       |                        it = copy_it;
 3816|       |                        rewind_depth<Options>(ctx, copy_depth);
 3817|       |                     }
 3818|       |                  }
 3819|       |               });
 3820|       |               if (found_match) {
 3821|       |                  return;
 3822|       |               }
 3823|       |            }
 3824|       |
 3825|       |            // Second pass: non-const types in this category
 3826|  6.89k|            if constexpr (non_const_count > 0) {
 3827|       |               // Track position within matching types for "is last" check.
 3828|       |               // We iterate over all variant indices but only process matching types,
 3829|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3830|       |               // the loop index directly corresponded to position in filtered set).
 3831|       |               // This has negligible cost: one increment per matching type.
 3832|  6.89k|               size_t non_const_idx = 0;
 3833|       |
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3836|  6.89k|                     return;
 3837|  6.89k|                  }
 3838|  6.89k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  6.89k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  6.89k|                     auto copy_it{it};
 3841|  6.89k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  6.89k|                     if (!std::holds_alternative<V>(value)) {
 3843|  6.89k|                        value = V{};
 3844|  6.89k|                     }
 3845|  6.89k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  6.89k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|  6.89k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|  6.89k|                     }
 3849|  6.89k|                     if (!bool(ctx.error)) {
 3850|  6.89k|                        found_match = true;
 3851|  6.89k|                     }
 3852|  6.89k|                     else if constexpr (not Options.null_terminated) {
 3853|  6.89k|                        constexpr bool is_complete_type =
 3854|  6.89k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|  6.89k|                        if constexpr (is_complete_type) {
 3857|  6.89k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|  6.89k|                              found_match = true;
 3859|  6.89k|                              ctx.error = error_code::none;
 3860|  6.89k|                           }
 3861|  6.89k|                           else {
 3862|  6.89k|                              it = copy_it;
 3863|  6.89k|                              rewind_depth<Options>(ctx, copy_depth);
 3864|  6.89k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|  6.89k|                                  not variant_alternative_exhausted(ctx)) {
 3866|  6.89k|                                 ctx.error = error_code::none;
 3867|  6.89k|                              }
 3868|  6.89k|                           }
 3869|  6.89k|                        }
 3870|  6.89k|                        else {
 3871|  6.89k|                           it = copy_it;
 3872|  6.89k|                           rewind_depth<Options>(ctx, copy_depth);
 3873|  6.89k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|  6.89k|                               not variant_alternative_exhausted(ctx)) {
 3875|  6.89k|                              ctx.error = error_code::none;
 3876|  6.89k|                           }
 3877|  6.89k|                        }
 3878|  6.89k|                     }
 3879|  6.89k|                     else {
 3880|  6.89k|                        it = copy_it;
 3881|  6.89k|                        rewind_depth<Options>(ctx, copy_depth);
 3882|  6.89k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|  6.89k|                            not variant_alternative_exhausted(ctx)) {
 3884|  6.89k|                           ctx.error = error_code::none;
 3885|  6.89k|                        }
 3886|  6.89k|                     }
 3887|  6.89k|                     ++non_const_idx;
 3888|  6.89k|                  }
 3889|  6.89k|               });
 3890|  6.89k|               if (!found_match) {
  ------------------
  |  Branch (3890:20): [True: 824, False: 6.07k]
  ------------------
 3891|    824|                  if constexpr (non_const_count == 1) {
 3892|       |                     // Keep the specific error from the single type we tried
 3893|       |                  }
 3894|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3895|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3896|       |                     ctx.error = error_code::no_matching_variant_type;
 3897|       |                  }
 3898|    824|               }
 3899|       |            }
 3900|       |            else {
 3901|       |               ctx.error = error_code::no_matching_variant_type;
 3902|       |            }
 3903|  6.89k|         }
 3904|  6.89k|      }
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 6.89k]
  |  Branch (3835:38): [True: 0, False: 6.89k]
  |  Branch (3835:51): [True: 0, False: 6.89k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  6.89k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  6.89k|               });
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 6.89k]
  |  Branch (3835:38): [True: 0, False: 6.89k]
  |  Branch (3835:51): [True: 0, False: 6.89k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  6.89k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  6.89k|               });
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 6.89k]
  |  Branch (3835:38): [True: 0, False: 6.89k]
  |  Branch (3835:51): [True: 0, False: 6.89k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  6.89k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  6.89k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  6.89k|                     auto copy_it{it};
 3841|  6.89k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  6.89k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3842:26): [True: 5.49k, False: 1.40k]
  ------------------
 3843|  5.49k|                        value = V{};
 3844|  5.49k|                     }
 3845|  6.89k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  6.89k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3846:26): [True: 927, False: 5.97k]
  |  Branch (3846:45): [True: 0, False: 927]
  ------------------
 3847|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|      0|                     }
 3849|  6.89k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3849:26): [True: 5.97k, False: 927]
  ------------------
 3850|  5.97k|                        found_match = true;
 3851|  5.97k|                     }
 3852|    927|                     else if constexpr (not Options.null_terminated) {
 3853|    927|                        constexpr bool is_complete_type =
 3854|    927|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
  ------------------
  |  Branch (3854:28): [Folded, False: 0]
  |  Branch (3854:40): [Folded, False: 0]
  |  Branch (3854:53): [True: 0, Folded]
  |  Branch (3854:68): [Folded, False: 0]
  |  Branch (3854:89): [Folded, False: 0]
  |  Branch (3854:103): [Folded, False: 0]
  ------------------
 3855|       |
 3856|    927|                        if constexpr (is_complete_type) {
 3857|    927|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
  ------------------
  |  Branch (3857:32): [True: 103, False: 824]
  |  Branch (3857:72): [True: 103, False: 0]
  |  Branch (3857:88): [True: 103, False: 0]
  ------------------
 3858|    103|                              found_match = true;
 3859|    103|                              ctx.error = error_code::none;
 3860|    103|                           }
 3861|    824|                           else {
 3862|    824|                              it = copy_it;
 3863|    824|                              rewind_depth<Options>(ctx, copy_depth);
 3864|    824|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3864:35): [True: 0, False: 824]
  |  Branch (3864:74): [True: 0, False: 0]
  ------------------
 3865|      0|                                  not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3865:35): [True: 0, False: 0]
  ------------------
 3866|      0|                                 ctx.error = error_code::none;
 3867|      0|                              }
 3868|    824|                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|  6.89k|                     ++non_const_idx;
 3888|  6.89k|                  }
 3889|  6.89k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|  6.89k|      {
   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.89k|         else {
   60|  6.89k|            using V = std::remove_cvref_t<T>;
   61|  6.89k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  6.89k|                                             end);
   63|  6.89k|         }
   64|  6.89k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEQntcl15check_is_paddedTL0__EEEvRT2_OT3_OT0_T1_:
 1084|  6.89k|      {
 1085|       |         if constexpr (check_string_as_number(Opts)) {
 1086|       |            auto start = it;
 1087|       |            skip_number<Opts>(ctx, it, end);
 1088|       |            if (bool(ctx.error)) [[unlikely]] {
 1089|       |               return;
 1090|       |            }
 1091|       |            if (start == it) [[unlikely]] {
 1092|       |               ctx.error = error_code::parse_number_failure;
 1093|       |               return;
 1094|       |            }
 1095|       |            value.append(start, size_t(it - start));
 1096|       |         }
 1097|  6.89k|         else {
 1098|  6.89k|            if constexpr (!check_opening_handled(Opts)) {
 1099|       |               if constexpr (!check_ws_handled(Opts)) {
 1100|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 1101|       |                     return;
 1102|       |                  }
 1103|       |               }
 1104|       |
 1105|  6.89k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (1105:20): [True: 51, False: 6.84k]
  ------------------
 1106|     51|                  return;
 1107|     51|               }
 1108|  6.89k|            }
 1109|       |
 1110|  6.89k|            if constexpr (not check_raw_string(Opts)) {
 1111|  6.89k|               static constexpr auto string_padding_bytes = 8;
 1112|       |
 1113|  6.89k|               if (size_t(end - it) >= 8) {
  ------------------
  |  Branch (1113:20): [True: 6.30k, False: 593]
  ------------------
 1114|  6.30k|                  auto start = it;
 1115|  6.30k|                  uint64_t ascii_acc{};
 1116|  6.30k|                  const auto end8 = end - 8;
 1117|  1.61M|                  while (true) {
  ------------------
  |  Branch (1117:26): [True: 1.61M, Folded]
  ------------------
 1118|  1.61M|                     if (it >= end8) [[unlikely]] {
  ------------------
  |  Branch (1118:26): [True: 513, False: 1.61M]
  ------------------
 1119|    513|                        break;
 1120|    513|                     }
 1121|       |
 1122|  1.61M|                     uint64_t chunk;
 1123|  1.61M|                     std::memcpy(&chunk, it, 8);
 1124|       |                     if constexpr (std::endian::native == std::endian::big) {
 1125|       |                        chunk = std::byteswap(chunk);
 1126|       |                     }
 1127|  1.61M|                     ascii_acc |= chunk;
 1128|  1.61M|                     const uint64_t test_chars = has_quote(chunk);
 1129|  1.61M|                     if (test_chars) {
  ------------------
  |  Branch (1129:26): [True: 7.75k, False: 1.60M]
  ------------------
 1130|  7.75k|                        it += (countr_zero(test_chars) >> 3);
 1131|       |
 1132|  7.75k|                        auto* prev = it - 1;
 1133|  9.96k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1133:32): [True: 2.21k, False: 7.75k]
  ------------------
 1134|  2.21k|                           --prev;
 1135|  2.21k|                        }
 1136|  7.75k|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1136:29): [True: 5.79k, False: 1.96k]
  ------------------
 1137|  5.79k|                           goto continue_decode;
 1138|  5.79k|                        }
 1139|  1.96k|                        ++it; // skip the escaped quote
 1140|  1.96k|                     }
 1141|  1.60M|                     else {
 1142|  1.60M|                        it += 8;
 1143|  1.60M|                     }
 1144|  1.61M|                  }
 1145|       |
 1146|  2.37k|                  while (it[-1] == '\\') [[unlikely]] {
  ------------------
  |  Branch (1146:26): [True: 1.85k, False: 513]
  ------------------
 1147|       |                     // if we ended on an escape character then we need to rewind
 1148|       |                     // because we lost our context
 1149|  1.85k|                     --it;
 1150|  1.85k|                  }
 1151|       |
 1152|       |                  // The byte-wise tail keeps feeding the accumulator: it has to cover every byte of
 1153|       |                  // the string, or a non-ASCII byte reached here would be waved through unvalidated.
 1154|  4.23k|                  for (; it < end; ++it) {
  ------------------
  |  Branch (1154:26): [True: 4.15k, False: 86]
  ------------------
 1155|  4.15k|                     ascii_acc |= uint8_t(*it);
 1156|  4.15k|                     if (*it == '"') {
  ------------------
  |  Branch (1156:26): [True: 518, False: 3.63k]
  ------------------
 1157|    518|                        auto* prev = it - 1;
 1158|  1.86k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1158:32): [True: 1.34k, False: 518]
  ------------------
 1159|  1.34k|                           --prev;
 1160|  1.34k|                        }
 1161|    518|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1161:29): [True: 427, False: 91]
  ------------------
 1162|    427|                           goto continue_decode;
 1163|    427|                        }
 1164|    518|                     }
 1165|  4.15k|                  }
 1166|       |
 1167|     86|                  ctx.error = error_code::unexpected_end;
 1168|     86|                  return;
 1169|       |
 1170|  6.21k|               continue_decode:
 1171|       |
 1172|  6.21k|                  if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (1172:23): [True: 131, False: 6.08k]
  ------------------
 1173|    131|                     return;
 1174|    131|                  }
 1175|       |
 1176|  6.08k|                  const auto available_padding = size_t(end - it);
 1177|  6.08k|                  auto n = size_t(it - start);
 1178|  6.08k|                  if (available_padding >= 8) [[likely]] {
  ------------------
  |  Branch (1178:23): [True: 5.73k, False: 352]
  ------------------
 1179|  5.73k|                     value.resize(n + string_padding_bytes);
 1180|       |
 1181|  5.73k|                     auto* p = value.data();
 1182|       |
 1183|  26.9k|                     while (true) {
  ------------------
  |  Branch (1183:29): [True: 26.9k, Folded]
  ------------------
 1184|  26.9k|                        if (start >= it) {
  ------------------
  |  Branch (1184:29): [True: 5.26k, False: 21.6k]
  ------------------
 1185|  5.26k|                           break;
 1186|  5.26k|                        }
 1187|       |
 1188|  21.6k|                        std::memcpy(p, start, 8);
 1189|  21.6k|                        uint64_t swar;
 1190|  21.6k|                        std::memcpy(&swar, p, 8);
 1191|       |                        if constexpr (std::endian::native == std::endian::big) {
 1192|       |                           swar = std::byteswap(swar);
 1193|       |                        }
 1194|       |
 1195|  21.6k|                        constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1196|  21.6k|                        const uint64_t lo7 = swar & lo7_mask;
 1197|  21.6k|                        const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1198|  21.6k|                        const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1199|  21.6k|                        uint64_t next = ~((backslash & less_32) | swar);
 1200|       |
 1201|  21.6k|                        next &= repeat_byte8(0b10000000);
 1202|  21.6k|                        if (next == 0) {
  ------------------
  |  Branch (1202:29): [True: 19.6k, False: 2.07k]
  ------------------
 1203|  19.6k|                           start += 8;
 1204|  19.6k|                           p += 8;
 1205|  19.6k|                           continue;
 1206|  19.6k|                        }
 1207|       |
 1208|  2.07k|                        next = countr_zero(next) >> 3;
 1209|  2.07k|                        start += next;
 1210|  2.07k|                        if (start >= it) {
  ------------------
  |  Branch (1210:29): [True: 366, False: 1.70k]
  ------------------
 1211|    366|                           break;
 1212|    366|                        }
 1213|       |
 1214|  1.70k|                        if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1214:29): [True: 32, False: 1.67k]
  ------------------
 1215|     32|                           ctx.error = error_code::syntax_error;
 1216|     32|                           return;
 1217|     32|                        }
 1218|  1.67k|                        ++start; // skip the escape
 1219|  1.67k|                        if (*start == 'u') {
  ------------------
  |  Branch (1219:29): [True: 1.23k, False: 443]
  ------------------
 1220|  1.23k|                           ++start;
 1221|  1.23k|                           p += next;
 1222|  1.23k|                           const auto mark = start;
 1223|  1.23k|                           const auto offset = handle_unicode_code_point(start, p, end);
 1224|  1.23k|                           if (offset == 0) [[unlikely]] {
  ------------------
  |  Branch (1224:32): [True: 63, False: 1.17k]
  ------------------
 1225|     63|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1226|     63|                              return;
 1227|     63|                           }
 1228|  1.17k|                           n += offset;
 1229|       |                           // escape + u + unicode code points
 1230|  1.17k|                           n -= 2 + uint32_t(start - mark);
 1231|  1.17k|                        }
 1232|    443|                        else {
 1233|    443|                           p += next;
 1234|    443|                           *p = char_unescape_table[uint8_t(*start)];
 1235|    443|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1235:32): [True: 8, False: 435]
  ------------------
 1236|      8|                              ctx.error = error_code::invalid_escape;
 1237|      8|                              return;
 1238|      8|                           }
 1239|    435|                           ++p;
 1240|    435|                           ++start;
 1241|    435|                           --n;
 1242|    435|                        }
 1243|  1.67k|                     }
 1244|       |
 1245|  5.63k|                     value.resize(n);
 1246|  5.63k|                     ++it;
 1247|  5.63k|                  }
 1248|    352|                  else {
 1249|       |                     // For large inputs this case of running out of buffer is very rare
 1250|    352|                     value.resize(n);
 1251|    352|                     auto* p = value.data();
 1252|       |
 1253|    352|                     it = start;
 1254|   833k|                     while (it < end) [[likely]] {
  ------------------
  |  Branch (1254:29): [True: 833k, False: 0]
  ------------------
 1255|   833k|                        if (*it == '"') {
  ------------------
  |  Branch (1255:29): [True: 200, False: 833k]
  ------------------
 1256|    200|                           value.resize(size_t(p - value.data()));
 1257|    200|                           ++it;
 1258|    200|                           return;
 1259|    200|                        }
 1260|       |
 1261|   833k|                        if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1261:29): [True: 44, False: 833k]
  ------------------
 1262|     44|                           ctx.error = error_code::syntax_error;
 1263|     44|                           return;
 1264|     44|                        }
 1265|       |
 1266|   833k|                        *p = *it;
 1267|       |
 1268|   833k|                        if (*it == '\\') {
  ------------------
  |  Branch (1268:29): [True: 2.11k, False: 831k]
  ------------------
 1269|  2.11k|                           ++it; // skip the escape
 1270|  2.11k|                           if (*it == 'u') {
  ------------------
  |  Branch (1270:32): [True: 1.14k, False: 975]
  ------------------
 1271|  1.14k|                              ++it;
 1272|  1.14k|                              if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1272:35): [True: 86, False: 1.05k]
  ------------------
 1273|     86|                                 ctx.error = error_code::unicode_escape_conversion_failure;
 1274|     86|                                 return;
 1275|     86|                              }
 1276|  1.14k|                           }
 1277|    975|                           else {
 1278|    975|                              *p = char_unescape_table[uint8_t(*it)];
 1279|    975|                              if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1279:35): [True: 22, False: 953]
  ------------------
 1280|     22|                                 ctx.error = error_code::invalid_escape;
 1281|     22|                                 return;
 1282|     22|                              }
 1283|    953|                              ++p;
 1284|    953|                              ++it;
 1285|    953|                           }
 1286|  2.11k|                        }
 1287|   831k|                        else {
 1288|   831k|                           ++it;
 1289|   831k|                           ++p;
 1290|   831k|                        }
 1291|   833k|                     }
 1292|       |
 1293|      0|                     ctx.error = error_code::unexpected_end;
 1294|      0|                  }
 1295|  6.08k|               }
 1296|    593|               else {
 1297|       |                  // For short strings
 1298|       |
 1299|    593|                  std::array<char, 8> buffer{};
 1300|       |
 1301|    593|                  auto* p = buffer.data();
 1302|    593|                  const auto* const utf8_start = it;
 1303|       |
 1304|  1.41k|                  while (it < end) [[likely]] {
  ------------------
  |  Branch (1304:26): [True: 1.29k, False: 123]
  ------------------
 1305|  1.29k|                     *p = *it;
 1306|  1.29k|                     if (*it == '"') {
  ------------------
  |  Branch (1306:26): [True: 327, False: 968]
  ------------------
 1307|    327|                        if (validate_utf8_span<Opts>(ctx, utf8_start, it)) [[unlikely]] {
  ------------------
  |  Branch (1307:29): [True: 86, False: 241]
  ------------------
 1308|     86|                           return;
 1309|     86|                        }
 1310|    241|                        const size_t n = size_t(p - buffer.data());
 1311|    241|#if __has_cpp_attribute(assume) >= 202207L
 1312|    241|                        [[assume(n <= sizeof(buffer))]];
 1313|    241|#endif
 1314|    241|                        value.assign(buffer.data(), n);
 1315|    241|                        ++it;
 1316|    241|                        if constexpr (not Opts.null_terminated) {
 1317|    241|                           if (it == end) {
  ------------------
  |  Branch (1317:32): [True: 103, False: 138]
  ------------------
 1318|    103|                              ctx.error = error_code::end_reached;
 1319|    103|                              return;
 1320|    103|                           }
 1321|    241|                        }
 1322|    138|                        return;
 1323|    327|                     }
 1324|    968|                     else if (*it == '\\') {
  ------------------
  |  Branch (1324:31): [True: 179, False: 789]
  ------------------
 1325|    179|                        ++it; // skip the escape
 1326|    179|                        if constexpr (not Opts.null_terminated) {
 1327|    179|                           if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1327:32): [True: 2, False: 177]
  ------------------
 1328|      2|                              ctx.error = error_code::unexpected_end;
 1329|      2|                              return;
 1330|      2|                           }
 1331|    179|                        }
 1332|    179|                        if (*it == 'u') {
  ------------------
  |  Branch (1332:29): [True: 113, False: 66]
  ------------------
 1333|    113|                           ++it;
 1334|    113|                           if constexpr (not Opts.null_terminated) {
 1335|    113|                              if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1335:35): [True: 3, False: 110]
  ------------------
 1336|      3|                                 ctx.error = error_code::unexpected_end;
 1337|      3|                                 return;
 1338|      3|                              }
 1339|    113|                           }
 1340|    113|                           if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1340:32): [True: 62, False: 51]
  ------------------
 1341|     62|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1342|     62|                              return;
 1343|     62|                           }
 1344|    113|                        }
 1345|     66|                        else {
 1346|     66|                           *p = char_unescape_table[uint8_t(*it)];
 1347|     66|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1347:32): [True: 18, False: 48]
  ------------------
 1348|     18|                              ctx.error = error_code::invalid_escape;
 1349|     18|                              return;
 1350|     18|                           }
 1351|     48|                           ++p;
 1352|     48|                           ++it;
 1353|     48|                        }
 1354|    179|                     }
 1355|    789|                     else if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1355:31): [True: 63, False: 726]
  ------------------
 1356|     63|                        ctx.error = error_code::syntax_error;
 1357|     63|                        return;
 1358|     63|                     }
 1359|    726|                     else {
 1360|    726|                        ++it;
 1361|    726|                        ++p;
 1362|    726|                     }
 1363|  1.29k|                  }
 1364|       |
 1365|    123|                  ctx.error = error_code::unexpected_end;
 1366|    123|               }
 1367|       |            }
 1368|       |            else {
 1369|       |               // raw_string
 1370|       |               auto start = it;
 1371|       |               skip_string_view(ctx, it, end);
 1372|       |               if (bool(ctx.error)) [[unlikely]]
 1373|       |                  return;
 1374|       |
 1375|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1376|       |                  return;
 1377|       |               }
 1378|       |
 1379|       |               value.assign(start, size_t(it - start));
 1380|       |               ++it;
 1381|       |            }
 1382|  6.89k|         }
 1383|  6.89k|      }
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 6.07k, False: 824]
  |  Branch (3835:38): [True: 0, False: 824]
  |  Branch (3835:51): [True: 0, False: 824]
  ------------------
 3836|  6.07k|                     return;
 3837|  6.07k|                  }
 3838|    824|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    824|               });
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 6.07k, False: 824]
  |  Branch (3835:38): [True: 0, False: 824]
  |  Branch (3835:51): [True: 0, False: 824]
  ------------------
 3836|  6.07k|                     return;
 3837|  6.07k|                  }
 3838|    824|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    824|               });
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 6.07k, False: 824]
  |  Branch (3835:38): [True: 0, False: 824]
  |  Branch (3835:51): [True: 0, False: 824]
  ------------------
 3836|  6.07k|                     return;
 3837|  6.07k|                  }
 3838|    824|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    824|               });
_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_:
 3765|  1.34k|      {
 3766|  1.34k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3767|       |
 3768|       |         if constexpr (category_count == 0) {
 3769|       |            ctx.error = error_code::no_matching_variant_type;
 3770|       |         }
 3771|  1.34k|         else {
 3772|  1.34k|            constexpr auto N = std::variant_size_v<Variant>;
 3773|  1.34k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3774|  1.34k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3775|       |
 3776|  1.34k|            bool found_match{};
 3777|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3778|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3779|       |            // so the budget stops it and the failure already in hand is reported.
 3780|  1.34k|            bool exhausted{};
 3781|       |
 3782|       |            // First pass: const glaze types in this category
 3783|       |            if constexpr (const_count > 0) {
 3784|       |               for_each<N>([&]<size_t I>() {
 3785|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3786|       |                     return;
 3787|       |                  }
 3788|       |                  using V = std::variant_alternative_t<I, Variant>;
 3789|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3790|       |                     // run time substitute to compare to const value
 3791|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3792|       |                     auto copy_it{it};
 3793|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3794|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3795|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3796|       |                     const auto copy_depth{ctx.depth};
 3797|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3798|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3799|       |                     if (substitute == const_value) {
 3800|       |                        found_match = true;
 3801|       |                        if (!std::holds_alternative<V>(value)) {
 3802|       |                           value = V{};
 3803|       |                        }
 3804|       |                     }
 3805|       |                     else {
 3806|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3807|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3808|       |                           exhausted = true;
 3809|       |                        }
 3810|       |                        if constexpr (not Options.null_terminated) {
 3811|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3812|       |                              ctx.error = error_code::none;
 3813|       |                           }
 3814|       |                        }
 3815|       |                        it = copy_it;
 3816|       |                        rewind_depth<Options>(ctx, copy_depth);
 3817|       |                     }
 3818|       |                  }
 3819|       |               });
 3820|       |               if (found_match) {
 3821|       |                  return;
 3822|       |               }
 3823|       |            }
 3824|       |
 3825|       |            // Second pass: non-const types in this category
 3826|  1.34k|            if constexpr (non_const_count > 0) {
 3827|       |               // Track position within matching types for "is last" check.
 3828|       |               // We iterate over all variant indices but only process matching types,
 3829|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3830|       |               // the loop index directly corresponded to position in filtered set).
 3831|       |               // This has negligible cost: one increment per matching type.
 3832|  1.34k|               size_t non_const_idx = 0;
 3833|       |
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3836|  1.34k|                     return;
 3837|  1.34k|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  1.34k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  1.34k|                     auto copy_it{it};
 3841|  1.34k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  1.34k|                     if (!std::holds_alternative<V>(value)) {
 3843|  1.34k|                        value = V{};
 3844|  1.34k|                     }
 3845|  1.34k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  1.34k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|  1.34k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|  1.34k|                     }
 3849|  1.34k|                     if (!bool(ctx.error)) {
 3850|  1.34k|                        found_match = true;
 3851|  1.34k|                     }
 3852|  1.34k|                     else if constexpr (not Options.null_terminated) {
 3853|  1.34k|                        constexpr bool is_complete_type =
 3854|  1.34k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|  1.34k|                        if constexpr (is_complete_type) {
 3857|  1.34k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|  1.34k|                              found_match = true;
 3859|  1.34k|                              ctx.error = error_code::none;
 3860|  1.34k|                           }
 3861|  1.34k|                           else {
 3862|  1.34k|                              it = copy_it;
 3863|  1.34k|                              rewind_depth<Options>(ctx, copy_depth);
 3864|  1.34k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|  1.34k|                                  not variant_alternative_exhausted(ctx)) {
 3866|  1.34k|                                 ctx.error = error_code::none;
 3867|  1.34k|                              }
 3868|  1.34k|                           }
 3869|  1.34k|                        }
 3870|  1.34k|                        else {
 3871|  1.34k|                           it = copy_it;
 3872|  1.34k|                           rewind_depth<Options>(ctx, copy_depth);
 3873|  1.34k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|  1.34k|                               not variant_alternative_exhausted(ctx)) {
 3875|  1.34k|                              ctx.error = error_code::none;
 3876|  1.34k|                           }
 3877|  1.34k|                        }
 3878|  1.34k|                     }
 3879|  1.34k|                     else {
 3880|  1.34k|                        it = copy_it;
 3881|  1.34k|                        rewind_depth<Options>(ctx, copy_depth);
 3882|  1.34k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|  1.34k|                            not variant_alternative_exhausted(ctx)) {
 3884|  1.34k|                           ctx.error = error_code::none;
 3885|  1.34k|                        }
 3886|  1.34k|                     }
 3887|  1.34k|                     ++non_const_idx;
 3888|  1.34k|                  }
 3889|  1.34k|               });
 3890|  1.34k|               if (!found_match) {
  ------------------
  |  Branch (3890:20): [True: 235, False: 1.10k]
  ------------------
 3891|    235|                  if constexpr (non_const_count == 1) {
 3892|       |                     // Keep the specific error from the single type we tried
 3893|       |                  }
 3894|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3895|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3896|       |                     ctx.error = error_code::no_matching_variant_type;
 3897|       |                  }
 3898|    235|               }
 3899|       |            }
 3900|       |            else {
 3901|       |               ctx.error = error_code::no_matching_variant_type;
 3902|       |            }
 3903|  1.34k|         }
 3904|  1.34k|      }
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  1.34k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  1.34k|                     auto copy_it{it};
 3841|  1.34k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  1.34k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3842:26): [True: 1.13k, False: 209]
  ------------------
 3843|  1.13k|                        value = V{};
 3844|  1.13k|                     }
 3845|  1.34k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  1.34k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3846:26): [True: 251, False: 1.08k]
  |  Branch (3846:45): [True: 0, False: 251]
  ------------------
 3847|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|      0|                     }
 3849|  1.34k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3849:26): [True: 1.08k, False: 251]
  ------------------
 3850|  1.08k|                        found_match = true;
 3851|  1.08k|                     }
 3852|    251|                     else if constexpr (not Options.null_terminated) {
 3853|    251|                        constexpr bool is_complete_type =
 3854|    251|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
  ------------------
  |  Branch (3854:28): [Folded, False: 0]
  |  Branch (3854:40): [True: 0, Folded]
  |  Branch (3854:53): [Folded, False: 0]
  |  Branch (3854:68): [Folded, False: 0]
  |  Branch (3854:89): [Folded, False: 0]
  |  Branch (3854:103): [Folded, False: 0]
  ------------------
 3855|       |
 3856|    251|                        if constexpr (is_complete_type) {
 3857|    251|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
  ------------------
  |  Branch (3857:32): [True: 16, False: 235]
  |  Branch (3857:72): [True: 16, False: 0]
  |  Branch (3857:88): [True: 16, False: 0]
  ------------------
 3858|     16|                              found_match = true;
 3859|     16|                              ctx.error = error_code::none;
 3860|     16|                           }
 3861|    235|                           else {
 3862|    235|                              it = copy_it;
 3863|    235|                              rewind_depth<Options>(ctx, copy_depth);
 3864|    235|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3864:35): [True: 0, False: 235]
  |  Branch (3864:74): [True: 0, False: 0]
  ------------------
 3865|      0|                                  not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3865:35): [True: 0, False: 0]
  ------------------
 3866|      0|                                 ctx.error = error_code::none;
 3867|      0|                              }
 3868|    235|                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|  1.34k|                     ++non_const_idx;
 3888|  1.34k|                  }
 3889|  1.34k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  1.34k|      {
   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.34k|         else {
   60|  1.34k|            using V = std::remove_cvref_t<T>;
   61|  1.34k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  1.34k|                                             end);
   63|  1.34k|         }
   64|  1.34k|      }
_ZN3glz4fromILj10EbE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEETkNS_6bool_tERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
  710|  1.34k|      {
  711|       |         if constexpr (check_quoted_num(Opts)) {
  712|       |            if (skip_ws<Opts>(ctx, it, end)) {
  713|       |               return;
  714|       |            }
  715|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  716|       |               return;
  717|       |            }
  718|       |         }
  719|       |
  720|       |         if constexpr (!check_ws_handled(Opts)) {
  721|       |            if (skip_ws<Opts>(ctx, it, end)) {
  722|       |               return;
  723|       |            }
  724|       |         }
  725|       |
  726|       |         if constexpr (check_bools_as_numbers(Opts)) {
  727|       |            if (*it == '1') {
  728|       |               value = true;
  729|       |               ++it;
  730|       |            }
  731|       |            else if (*it == '0') {
  732|       |               value = false;
  733|       |               ++it;
  734|       |            }
  735|       |            else {
  736|       |               ctx.error = error_code::syntax_error;
  737|       |               return;
  738|       |            }
  739|       |         }
  740|  1.34k|         else {
  741|  1.34k|            if constexpr (not check_is_padded(Opts)) {
  742|  1.34k|               if (size_t(end - it) < 4) [[unlikely]] {
  ------------------
  |  Branch (742:20): [True: 71, False: 1.26k]
  ------------------
  743|     71|                  ctx.error = error_code::expected_true_or_false;
  744|     71|                  return;
  745|     71|               }
  746|  1.34k|            }
  747|       |
  748|  1.26k|            uint32_t c;
  749|  1.34k|            static constexpr uint32_t u_true = 0b01100101'01110101'01110010'01110100;
  750|  1.34k|            static constexpr uint32_t u_fals = 0b01110011'01101100'01100001'01100110;
  751|  1.34k|            std::memcpy(&c, it, 4);
  752|       |            if constexpr (std::endian::native == std::endian::big) {
  753|       |               c = std::byteswap(c);
  754|       |            }
  755|  1.34k|            it += 4;
  756|  1.34k|            if (c == u_true) {
  ------------------
  |  Branch (756:17): [True: 847, False: 493]
  ------------------
  757|    847|               value = true;
  758|    847|            }
  759|    493|            else if (it == end) [[unlikely]] {
  ------------------
  |  Branch (759:22): [True: 60, False: 433]
  ------------------
  760|     60|               ctx.error = error_code::unexpected_end;
  761|     60|               return;
  762|     60|            }
  763|    433|            else {
  764|    433|               if (c == u_fals && (*it == 'e')) [[likely]] {
  ------------------
  |  Branch (764:20): [True: 274, False: 159]
  |  Branch (764:35): [True: 258, False: 16]
  ------------------
  765|    258|                  value = false;
  766|    258|                  ++it;
  767|    258|               }
  768|    175|               else [[unlikely]] {
  769|    175|                  ctx.error = error_code::expected_true_or_false;
  770|    175|                  return;
  771|    175|               }
  772|    433|            }
  773|  1.34k|         }
  774|       |
  775|       |         if constexpr (check_quoted_num(Opts)) {
  776|       |            if constexpr (not Opts.null_terminated) {
  777|       |               if (it == end) [[unlikely]] {
  778|       |                  ctx.error = error_code::unexpected_end;
  779|       |                  return;
  780|       |               }
  781|       |            }
  782|       |            if (match<'"'>(ctx, it)) {
  783|       |               return;
  784|       |            }
  785|       |            if constexpr (not Opts.null_terminated) {
  786|       |               if (it == end) {
  787|       |                  ctx.error = error_code::end_reached;
  788|       |                  return;
  789|       |               }
  790|       |            }
  791|       |         }
  792|  1.34k|         else {
  793|  1.34k|            if constexpr (not Opts.null_terminated) {
  794|  1.34k|               if (it == end) {
  ------------------
  |  Branch (794:20): [True: 16, False: 1.32k]
  ------------------
  795|     16|                  ctx.error = error_code::end_reached;
  796|     16|                  return;
  797|     16|               }
  798|  1.34k|            }
  799|  1.34k|         }
  800|  1.34k|      }
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 1.10k, False: 235]
  |  Branch (3835:38): [True: 0, False: 235]
  |  Branch (3835:51): [True: 0, False: 235]
  ------------------
 3836|  1.10k|                     return;
 3837|  1.10k|                  }
 3838|    235|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    235|               });
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 1.10k, False: 235]
  |  Branch (3835:38): [True: 0, False: 235]
  |  Branch (3835:51): [True: 0, False: 235]
  ------------------
 3836|  1.10k|                     return;
 3837|  1.10k|                  }
 3838|    235|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    235|               });
_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_:
 3765|  2.02M|      {
 3766|  2.02M|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3767|       |
 3768|       |         if constexpr (category_count == 0) {
 3769|       |            ctx.error = error_code::no_matching_variant_type;
 3770|       |         }
 3771|  2.02M|         else {
 3772|  2.02M|            constexpr auto N = std::variant_size_v<Variant>;
 3773|  2.02M|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3774|  2.02M|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3775|       |
 3776|  2.02M|            bool found_match{};
 3777|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3778|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3779|       |            // so the budget stops it and the failure already in hand is reported.
 3780|  2.02M|            bool exhausted{};
 3781|       |
 3782|       |            // First pass: const glaze types in this category
 3783|       |            if constexpr (const_count > 0) {
 3784|       |               for_each<N>([&]<size_t I>() {
 3785|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3786|       |                     return;
 3787|       |                  }
 3788|       |                  using V = std::variant_alternative_t<I, Variant>;
 3789|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3790|       |                     // run time substitute to compare to const value
 3791|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3792|       |                     auto copy_it{it};
 3793|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3794|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3795|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3796|       |                     const auto copy_depth{ctx.depth};
 3797|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3798|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3799|       |                     if (substitute == const_value) {
 3800|       |                        found_match = true;
 3801|       |                        if (!std::holds_alternative<V>(value)) {
 3802|       |                           value = V{};
 3803|       |                        }
 3804|       |                     }
 3805|       |                     else {
 3806|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3807|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3808|       |                           exhausted = true;
 3809|       |                        }
 3810|       |                        if constexpr (not Options.null_terminated) {
 3811|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3812|       |                              ctx.error = error_code::none;
 3813|       |                           }
 3814|       |                        }
 3815|       |                        it = copy_it;
 3816|       |                        rewind_depth<Options>(ctx, copy_depth);
 3817|       |                     }
 3818|       |                  }
 3819|       |               });
 3820|       |               if (found_match) {
 3821|       |                  return;
 3822|       |               }
 3823|       |            }
 3824|       |
 3825|       |            // Second pass: non-const types in this category
 3826|  2.02M|            if constexpr (non_const_count > 0) {
 3827|       |               // Track position within matching types for "is last" check.
 3828|       |               // We iterate over all variant indices but only process matching types,
 3829|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3830|       |               // the loop index directly corresponded to position in filtered set).
 3831|       |               // This has negligible cost: one increment per matching type.
 3832|  2.02M|               size_t non_const_idx = 0;
 3833|       |
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  2.02M|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  2.02M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  2.02M|                     auto copy_it{it};
 3841|  2.02M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  2.02M|                     if (!std::holds_alternative<V>(value)) {
 3843|  2.02M|                        value = V{};
 3844|  2.02M|                     }
 3845|  2.02M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  2.02M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|  2.02M|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|  2.02M|                     }
 3849|  2.02M|                     if (!bool(ctx.error)) {
 3850|  2.02M|                        found_match = true;
 3851|  2.02M|                     }
 3852|  2.02M|                     else if constexpr (not Options.null_terminated) {
 3853|  2.02M|                        constexpr bool is_complete_type =
 3854|  2.02M|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|  2.02M|                        if constexpr (is_complete_type) {
 3857|  2.02M|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|  2.02M|                              found_match = true;
 3859|  2.02M|                              ctx.error = error_code::none;
 3860|  2.02M|                           }
 3861|  2.02M|                           else {
 3862|  2.02M|                              it = copy_it;
 3863|  2.02M|                              rewind_depth<Options>(ctx, copy_depth);
 3864|  2.02M|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|  2.02M|                                  not variant_alternative_exhausted(ctx)) {
 3866|  2.02M|                                 ctx.error = error_code::none;
 3867|  2.02M|                              }
 3868|  2.02M|                           }
 3869|  2.02M|                        }
 3870|  2.02M|                        else {
 3871|  2.02M|                           it = copy_it;
 3872|  2.02M|                           rewind_depth<Options>(ctx, copy_depth);
 3873|  2.02M|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|  2.02M|                               not variant_alternative_exhausted(ctx)) {
 3875|  2.02M|                              ctx.error = error_code::none;
 3876|  2.02M|                           }
 3877|  2.02M|                        }
 3878|  2.02M|                     }
 3879|  2.02M|                     else {
 3880|  2.02M|                        it = copy_it;
 3881|  2.02M|                        rewind_depth<Options>(ctx, copy_depth);
 3882|  2.02M|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|  2.02M|                            not variant_alternative_exhausted(ctx)) {
 3884|  2.02M|                           ctx.error = error_code::none;
 3885|  2.02M|                        }
 3886|  2.02M|                     }
 3887|  2.02M|                     ++non_const_idx;
 3888|  2.02M|                  }
 3889|  2.02M|               });
 3890|  2.02M|               if (!found_match) {
  ------------------
  |  Branch (3890:20): [True: 1.34k, False: 2.02M]
  ------------------
 3891|  1.34k|                  if constexpr (non_const_count == 1) {
 3892|       |                     // Keep the specific error from the single type we tried
 3893|       |                  }
 3894|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3895|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3896|       |                     ctx.error = error_code::no_matching_variant_type;
 3897|       |                  }
 3898|  1.34k|               }
 3899|       |            }
 3900|       |            else {
 3901|       |               ctx.error = error_code::no_matching_variant_type;
 3902|       |            }
 3903|  2.02M|         }
 3904|  2.02M|      }
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 2.02M]
  |  Branch (3835:38): [True: 0, False: 2.02M]
  |  Branch (3835:51): [True: 0, False: 2.02M]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  2.02M|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  2.02M|               });
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 2.02M]
  |  Branch (3835:38): [True: 0, False: 2.02M]
  |  Branch (3835:51): [True: 0, False: 2.02M]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  2.02M|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  2.02M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  2.02M|                     auto copy_it{it};
 3841|  2.02M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  2.02M|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3842:26): [True: 1.78M, False: 242k]
  ------------------
 3843|  1.78M|                        value = V{};
 3844|  1.78M|                     }
 3845|  2.02M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  2.02M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3846:26): [True: 4.08k, False: 2.02M]
  |  Branch (3846:45): [True: 0, False: 4.08k]
  ------------------
 3847|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|      0|                     }
 3849|  2.02M|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3849:26): [True: 2.02M, False: 4.08k]
  ------------------
 3850|  2.02M|                        found_match = true;
 3851|  2.02M|                     }
 3852|  4.08k|                     else if constexpr (not Options.null_terminated) {
 3853|  4.08k|                        constexpr bool is_complete_type =
 3854|  4.08k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
  ------------------
  |  Branch (3854:28): [True: 4.08k, Folded]
  |  Branch (3854:40): [Folded, False: 0]
  |  Branch (3854:53): [Folded, False: 0]
  |  Branch (3854:68): [Folded, False: 0]
  |  Branch (3854:89): [Folded, False: 0]
  |  Branch (3854:103): [Folded, False: 0]
  ------------------
 3855|       |
 3856|  4.08k|                        if constexpr (is_complete_type) {
 3857|  4.08k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
  ------------------
  |  Branch (3857:32): [True: 2.73k, False: 1.34k]
  |  Branch (3857:72): [True: 2.73k, False: 0]
  |  Branch (3857:88): [True: 2.73k, False: 0]
  ------------------
 3858|  2.73k|                              found_match = true;
 3859|  2.73k|                              ctx.error = error_code::none;
 3860|  2.73k|                           }
 3861|  1.34k|                           else {
 3862|  1.34k|                              it = copy_it;
 3863|  1.34k|                              rewind_depth<Options>(ctx, copy_depth);
 3864|  1.34k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3864:35): [True: 0, False: 1.34k]
  |  Branch (3864:74): [True: 0, False: 0]
  ------------------
 3865|      0|                                  not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3865:35): [True: 0, False: 0]
  ------------------
 3866|      0|                                 ctx.error = error_code::none;
 3867|      0|                              }
 3868|  1.34k|                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|  2.02M|                     ++non_const_idx;
 3888|  2.02M|                  }
 3889|  2.02M|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERdTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  2.02M|      {
   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.02M|         else {
   60|  2.02M|            using V = std::remove_cvref_t<T>;
   61|  2.02M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  2.02M|                                             end);
   63|  2.02M|         }
   64|  2.02M|      }
_ZN3glz4fromILj10EdE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERPKcRdTkNS_10is_contextERNS_7contextES5_EEvOT1_OT2_OT0_T3_:
  808|  2.02M|      {
  809|       |         if constexpr (check_quoted_num(Opts)) {
  810|       |            if (skip_ws<Opts>(ctx, it, end)) {
  811|       |               return;
  812|       |            }
  813|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  814|       |               return;
  815|       |            }
  816|       |         }
  817|       |
  818|       |         if constexpr (!check_ws_handled(Opts)) {
  819|       |            if (skip_ws<Opts>(ctx, it, end)) {
  820|       |               return;
  821|       |            }
  822|       |         }
  823|       |
  824|  2.02M|         using V = std::decay_t<decltype(value)>;
  825|       |         if constexpr (int_t<V>) {
  826|       |            static_assert(sizeof(*it) == sizeof(char));
  827|       |
  828|       |            if constexpr (Opts.null_terminated) {
  829|       |               if (not glz::atoi(value, it)) [[unlikely]] {
  830|       |                  ctx.error = error_code::parse_number_failure;
  831|       |                  return;
  832|       |               }
  833|       |            }
  834|       |            else {
  835|       |               if (not glz::atoi(value, it, end)) [[unlikely]] {
  836|       |                  ctx.error = error_code::parse_number_failure;
  837|       |                  return;
  838|       |               }
  839|       |            }
  840|       |         }
  841|  2.02M|         else {
  842|       |// float128_t requires std::from_chars for floating-point, unavailable on older Apple platforms (iOS < 16.3)
  843|  2.02M|#if !defined(_LIBCPP_VERSION) || defined(_LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT)
  844|       |            if constexpr (is_float128<V>) {
  845|       |               auto [ptr, ec] = std::from_chars(it, end, value);
  846|       |               if (ec != std::errc()) {
  847|       |                  ctx.error = error_code::parse_number_failure;
  848|       |                  return;
  849|       |               }
  850|       |               it = ptr;
  851|       |            }
  852|       |            else
  853|       |#endif
  854|  2.02M|            {
  855|       |               if constexpr (std::is_volatile_v<std::remove_reference_t<decltype(value)>>) {
  856|       |                  // Hardware may interact with value changes, so we parse into a temporary and assign in one
  857|       |                  // place
  858|       |                  V temp;
  859|       |                  if constexpr (is_size_optimized(Opts)) {
  860|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, temp);
  861|       |                     if (ec != std::errc{}) [[unlikely]] {
  862|       |                        ctx.error = error_code::parse_number_failure;
  863|       |                        return;
  864|       |                     }
  865|       |                     it = ptr;
  866|       |                  }
  867|       |                  else {
  868|       |                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, temp);
  869|       |                     if (ec != std::errc()) [[unlikely]] {
  870|       |                        ctx.error = error_code::parse_number_failure;
  871|       |                        return;
  872|       |                     }
  873|       |                     it = ptr;
  874|       |                  }
  875|       |                  value = temp;
  876|       |               }
  877|  2.02M|               else {
  878|       |                  if constexpr (is_size_optimized(Opts)) {
  879|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, value);
  880|       |                     if (ec != std::errc{}) [[unlikely]] {
  881|       |                        ctx.error = error_code::parse_number_failure;
  882|       |                        return;
  883|       |                     }
  884|       |                     it = ptr;
  885|       |                  }
  886|  2.02M|                  else {
  887|  2.02M|                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, value);
  888|  2.02M|                     if (ec != std::errc()) [[unlikely]] {
  ------------------
  |  Branch (888:26): [True: 1.34k, False: 2.02M]
  ------------------
  889|  1.34k|                        ctx.error = error_code::parse_number_failure;
  890|  1.34k|                        return;
  891|  1.34k|                     }
  892|  2.02M|                     it = ptr;
  893|  2.02M|                  }
  894|  2.02M|               }
  895|  2.02M|            }
  896|  2.02M|         }
  897|       |
  898|       |         if constexpr (check_quoted_num(Opts)) {
  899|       |            if constexpr (not Opts.null_terminated) {
  900|       |               if (it == end) [[unlikely]] {
  901|       |                  ctx.error = error_code::unexpected_end;
  902|       |                  return;
  903|       |               }
  904|       |            }
  905|       |            if (match<'"'>(ctx, it)) {
  906|       |               return;
  907|       |            }
  908|       |            if constexpr (not Opts.null_terminated) {
  909|       |               if (it == end) {
  910|       |                  ctx.error = error_code::end_reached;
  911|       |                  return;
  912|       |               }
  913|       |            }
  914|       |         }
  915|  2.02M|         else {
  916|  2.02M|            if constexpr (not Opts.null_terminated) {
  917|  2.02M|               if (it == end) {
  ------------------
  |  Branch (917:20): [True: 2.73k, False: 2.02M]
  ------------------
  918|  2.73k|                  ctx.error = error_code::end_reached;
  919|  2.73k|                  return;
  920|  2.73k|               }
  921|  2.02M|            }
  922|  2.02M|         }
  923|  2.02M|      }
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 2.02M, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 2.02M, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 2.02M, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 2.02M, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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_:
 5276|  10.5k|   {
 5277|  10.5k|      context ctx{};
 5278|  10.5k|      return read<opts{}>(value, std::forward<Buffer>(buffer), ctx);
 5279|  10.5k|   }
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  10.5k|      {
   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|  10.5k|         else {
   60|  10.5k|            using V = std::remove_cvref_t<T>;
   61|  10.5k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  10.5k|                                             end);
   63|  10.5k|         }
   64|  10.5k|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  10.5k|      {
  151|  10.5k|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  10.5k|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  10.5k|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  10.5k|      }
_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_:
 4093|  10.5k|      {
 4094|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 4095|       |            read_adjacent<Options>(value, ctx, it, end);
 4096|       |         }
 4097|  10.5k|         else {
 4098|  10.5k|            read_deduced<Options>(value, ctx, it, end);
 4099|  10.5k|         }
 4100|  10.5k|      }
_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_:
 4104|  10.5k|      {
 4105|  10.5k|         constexpr auto Opts = ws_handled_off<Options>();
 4106|  10.5k|         if constexpr (variant_is_auto_deducible<T>()) {
 4107|  10.5k|            if constexpr (not check_ws_handled(Options)) {
 4108|  10.5k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (4108:20): [True: 0, False: 10.5k]
  ------------------
 4109|      0|                  return;
 4110|      0|               }
 4111|  10.5k|            }
 4112|       |
 4113|  10.5k|            switch (*it) {
 4114|     16|            case '\0':
  ------------------
  |  Branch (4114:13): [True: 16, False: 10.5k]
  ------------------
 4115|     16|               ctx.error = error_code::unexpected_end;
 4116|     16|               return;
 4117|  4.67k|            case '{': {
  ------------------
  |  Branch (4117:13): [True: 4.67k, False: 5.86k]
  ------------------
 4118|       |               // This branch consumes the brace itself and hands the object to a reader with
 4119|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 4120|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 4121|       |               // the reader below.
 4122|  4.67k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (4122:20): [True: 0, False: 4.67k]
  ------------------
 4123|      0|                  return;
 4124|      0|               }
 4125|       |
 4126|  4.67k|               ++it;
 4127|       |               if constexpr (not Opts.null_terminated) {
 4128|       |                  if (it == end) [[unlikely]] {
 4129|       |                     ctx.error = error_code::unexpected_end;
 4130|       |                     return;
 4131|       |                  }
 4132|       |               }
 4133|  4.67k|               using type_counts = variant_type_count<T>;
 4134|  4.67k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 4135|       |               if constexpr (n_object_candidates < 1) {
 4136|       |                  ctx.error = error_code::no_matching_variant_type;
 4137|       |                  return;
 4138|       |               }
 4139|  4.67k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 4140|  4.67k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 4141|  4.67k|                  using V = std::variant_alternative_t<first_idx, T>;
 4142|  4.67k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4142:23): [True: 4.67k, False: 0]
  ------------------
 4143|  4.67k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 4144|  4.67k|                  return;
 4145|       |               }
 4146|       |               else {
 4147|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 4148|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 4149|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 4150|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 4151|       |
 4152|       |                  // Track if we've encountered a tag and what value it had
 4153|       |                  std::optional<size_t> tag_specified_index{};
 4154|       |
 4155|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 4156|       |                     return;
 4157|       |                  }
 4158|       |                  auto start = it;
 4159|       |                  bool first_key = true;
 4160|       |                  // Parse bifurcation for tagged variants:
 4161|       |                  //
 4162|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 4163|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 4164|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 4165|       |                  //
 4166|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 4167|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 4168|       |                  // it advances past the trailing comma so the object parser picks up at the
 4169|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 4170|       |                  //
 4171|       |                  // One exception: if the tag name is also a field on the resolved struct
 4172|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 4173|       |                  // the struct field. This override is applied inside each std::visit lambda.
 4174|       |                  auto position_after_tag = [&] {
 4175|       |                     if (first_key) {
 4176|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 4177|       |                     }
 4178|       |                     else {
 4179|       |                        it = start; // tag was not the first key, re-parse from the beginning
 4180|       |                     }
 4181|       |                  };
 4182|       |                  while (*it != '}') {
 4183|       |                     if (it != start) {
 4184|       |                        first_key = false;
 4185|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 4186|       |                           return;
 4187|       |                        }
 4188|       |                     }
 4189|       |
 4190|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4191|       |                        return;
 4192|       |                     }
 4193|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4194|       |                        return;
 4195|       |                     }
 4196|       |
 4197|       |                     auto* key_start = it;
 4198|       |                     skip_string_view(ctx, it, end);
 4199|       |                     if (bool(ctx.error)) [[unlikely]]
 4200|       |                        return;
 4201|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 4202|       |                        return;
 4203|       |                     const sv key = {key_start, size_t(it - key_start)};
 4204|       |
 4205|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4206|       |                        return;
 4207|       |                     }
 4208|       |
 4209|       |                     if constexpr (deduction_key_count > 0) {
 4210|       |                        // We first check if a tag is defined and see if the key matches the tag
 4211|       |                        if constexpr (not tag_v<T>.empty()) {
 4212|       |                           if (key == tag_v<T>) {
 4213|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 4214|       |                                 return;
 4215|       |                              }
 4216|       |
 4217|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 4218|       |
 4219|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 4220|       |                              if constexpr (std::integral<id_type>) {
 4221|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4222|       |                              }
 4223|       |                              else {
 4224|       |                                 from<JSON, sv>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4225|       |                              }
 4226|       |                              if (bool(ctx.error)) [[unlikely]]
 4227|       |                                 return;
 4228|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4229|       |                                 return;
 4230|       |                              }
 4231|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4232|       |                                 ctx.error = error_code::syntax_error;
 4233|       |                                 return;
 4234|       |                              }
 4235|       |
 4236|       |                              size_t type_index;
 4237|       |                              if constexpr (std::integral<id_type>) {
 4238|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4239|       |                              }
 4240|       |                              else {
 4241|       |                                 type_index = variant_id_to_index<T>::op(
 4242|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4243|       |                              }
 4244|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4245|       |                                 // Check if the deduced types include the tag-specified type
 4246|       |                                 // If not, the tag doesn't match the fields
 4247|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4248|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4249|       |                                 // Check if the tag-specified type is still possible
 4250|       |                                 const bool type_is_possible = possible_types[type_index];
 4251|       |                                 if (!type_is_possible) {
 4252|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4253|       |                                    ctx.error = error_code::no_matching_variant_type;
 4254|       |                                    return;
 4255|       |                                 }
 4256|       |
 4257|       |                                 position_after_tag();
 4258|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4259|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4260|       |                                 std::visit(
 4261|       |                                    [&](auto&& v) {
 4262|       |                                       using V = std::decay_t<decltype(v)>;
 4263|       |                                       constexpr bool is_object =
 4264|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4265|       |                                       if constexpr (variant_unit_alternative<V>) {
 4266|       |                                          // A unit alternative carries no data; its object holds only the
 4267|       |                                          // discriminator. Consume that body through an empty reflected object so
 4268|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4269|       |                                          detail::variant_unit_body unit_body{};
 4270|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4271|       |                                                                                             tag_literal>(unit_body,
 4272|       |                                                                                                          ctx, it, end);
 4273|       |                                       }
 4274|       |                                       else if constexpr (is_object) {
 4275|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4276|       |                                             it = start; // tag is a struct field, must re-parse
 4277|       |                                          }
 4278|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4279|       |                                                                                                           end);
 4280|       |                                       }
 4281|       |                                       else if constexpr (is_memory_object<V>) {
 4282|       |                                          if (!v) {
 4283|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4284|       |                                                if constexpr (requires { v.emplace(); }) {
 4285|       |                                                   v.emplace();
 4286|       |                                                }
 4287|       |                                                else {
 4288|       |                                                   v = typename V::value_type{};
 4289|       |                                                }
 4290|       |                                             }
 4291|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4292|       |                                                v = std::make_unique<typename V::element_type>();
 4293|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4294|       |                                                v = std::make_shared<typename V::element_type>();
 4295|       |                                             else if constexpr (constructible<V>) {
 4296|       |                                                v = meta_construct_v<V>();
 4297|       |                                             }
 4298|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4299|       |                                                                can_allocate_raw_pointer<Opts,
 4300|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4301|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4302|       |                                                   return;
 4303|       |                                                }
 4304|       |                                             }
 4305|       |                                             else {
 4306|       |                                                ctx.error = error_code::invalid_nullable_read;
 4307|       |                                                return;
 4308|       |                                                // Cannot read into unset nullable that is not std::optional,
 4309|       |                                                // std::unique_ptr, or std::shared_ptr
 4310|       |                                             }
 4311|       |                                          }
 4312|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4313|       |                                             it = start; // tag is a struct field, must re-parse
 4314|       |                                          }
 4315|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4316|       |                                             *v, ctx, it, end);
 4317|       |                                       }
 4318|       |                                       else if constexpr (custom_read<V>) {
 4319|       |                                          // Custom handlers parse the remaining body themselves and do not
 4320|       |                                          // accept the tag template parameter; the tag was already consumed.
 4321|       |                                          // This only works when the tag was the first key. If it came later,
 4322|       |                                          // we were reset to the object start and the custom handler would
 4323|       |                                          // absorb the tag, so error rather than corrupt the value.
 4324|       |                                          if (it == start) {
 4325|       |                                             ctx.error = error_code::feature_not_supported;
 4326|       |                                             ctx.custom_error_message =
 4327|       |                                                "the tag must be the first key for a custom variant alternative";
 4328|       |                                             return;
 4329|       |                                          }
 4330|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4331|       |                                       }
 4332|       |                                    },
 4333|       |                                    value);
 4334|       |
 4335|       |                                 return; // we've decoded our target type
 4336|       |                              }
 4337|       |                              else [[unlikely]] {
 4338|       |                                 // Check if we have a default type (ids array shorter than variant)
 4339|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4340|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4341|       |                                 if constexpr (ids_size < variant_size) {
 4342|       |                                    // Use the first unlabeled type as the default
 4343|       |                                    const auto default_type_index = ids_size;
 4344|       |
 4345|       |                                    position_after_tag();
 4346|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4347|       |                                    if (value.index() != default_type_index)
 4348|       |                                       emplace_runtime_variant(value, default_type_index);
 4349|       |                                    std::visit(
 4350|       |                                       [&](auto&& v) {
 4351|       |                                          using V = std::decay_t<decltype(v)>;
 4352|       |                                          constexpr bool is_object =
 4353|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4354|       |                                          if constexpr (variant_unit_alternative<V>) {
 4355|       |                                             // A unit alternative carries no data; its object holds only the
 4356|       |                                             // discriminator. Consume that body through an empty reflected object so
 4357|       |                                             // unknown-key policy and terminator handling match every other
 4358|       |                                             // alternative.
 4359|       |                                             detail::variant_unit_body unit_body{};
 4360|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4361|       |                                                                                                tag_literal>(
 4362|       |                                                unit_body, ctx, it, end);
 4363|       |                                          }
 4364|       |                                          else if constexpr (is_object) {
 4365|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4366|       |                                                it = start; // tag is a struct field, must re-parse
 4367|       |                                             }
 4368|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4369|       |                                          }
 4370|       |                                          else if constexpr (is_memory_object<V>) {
 4371|       |                                             if (!v) {
 4372|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4373|       |                                                   if constexpr (requires { v.emplace(); }) {
 4374|       |                                                      v.emplace();
 4375|       |                                                   }
 4376|       |                                                   else {
 4377|       |                                                      v = typename V::value_type{};
 4378|       |                                                   }
 4379|       |                                                }
 4380|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4381|       |                                                   v = std::make_unique<typename V::element_type>();
 4382|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4383|       |                                                   v = std::make_shared<typename V::element_type>();
 4384|       |                                                else if constexpr (constructible<V>) {
 4385|       |                                                   v = meta_construct_v<V>();
 4386|       |                                                }
 4387|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4388|       |                                                                   can_allocate_raw_pointer<
 4389|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4390|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4391|       |                                                      return;
 4392|       |                                                   }
 4393|       |                                                }
 4394|       |                                                else {
 4395|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4396|       |                                                   return;
 4397|       |                                                }
 4398|       |                                             }
 4399|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4400|       |                                                it = start; // tag is a struct field, must re-parse
 4401|       |                                             }
 4402|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4403|       |                                                                                                              it, end);
 4404|       |                                          }
 4405|       |                                          else if constexpr (custom_read<V>) {
 4406|       |                                             // Custom handlers parse the remaining body themselves; this only
 4407|       |                                             // works when the tag was the first key (see above). If it came
 4408|       |                                             // later we were reset to the object start, so error rather than
 4409|       |                                             // let the custom handler absorb the tag.
 4410|       |                                             if (it == start) {
 4411|       |                                                ctx.error = error_code::feature_not_supported;
 4412|       |                                                ctx.custom_error_message =
 4413|       |                                                   "the tag must be the first key for a custom variant alternative";
 4414|       |                                                return;
 4415|       |                                             }
 4416|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4417|       |                                          }
 4418|       |                                       },
 4419|       |                                       value);
 4420|       |
 4421|       |                                    return;
 4422|       |                                 }
 4423|       |                                 else {
 4424|       |                                    ctx.error = error_code::no_matching_variant_type;
 4425|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4426|       |                                    return;
 4427|       |                                 }
 4428|       |                              }
 4429|       |                           }
 4430|       |                        }
 4431|       |
 4432|       |                        // Inline decode_hash lookup for variant deduction
 4433|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4434|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4435|       |                        const auto deduction_index =
 4436|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4437|       |                              key.data(), key.data() + key.size(), key.size());
 4438|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4439|       |                           [[likely]] {
 4440|       |                           possible_types &= deduction_bits[deduction_index];
 4441|       |                        }
 4442|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4443|       |                           ctx.error = error_code::unknown_key;
 4444|       |                           return;
 4445|       |                        }
 4446|       |                     }
 4447|       |                     else if constexpr (not tag_v<T>.empty()) {
 4448|       |                        // empty object case for variant, if there are no normal elements
 4449|       |                        if (key == tag_v<T>) {
 4450|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4451|       |                              return;
 4452|       |                           }
 4453|       |
 4454|       |                           std::string_view type_id{};
 4455|       |                           parse<JSON>::op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4456|       |                           if (bool(ctx.error)) [[unlikely]]
 4457|       |                              return;
 4458|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4459|       |                              return;
 4460|       |                           }
 4461|       |
 4462|       |                           const auto type_index = variant_id_to_index<T>::op(
 4463|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4464|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4465|       |                              position_after_tag();
 4466|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4467|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4468|       |                           }
 4469|       |                           else {
 4470|       |                              // Check if we have a default type (ids array shorter than variant)
 4471|       |                              constexpr auto ids_size = ids_v<T>.size();
 4472|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4473|       |                              if constexpr (ids_size < variant_size) {
 4474|       |                                 // Use the first unlabeled type as the default
 4475|       |                                 position_after_tag();
 4476|       |                                 const auto default_index = ids_size;
 4477|       |                                 tag_specified_index = default_index; // Store the default type index
 4478|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4479|       |                              }
 4480|       |                              else {
 4481|       |                                 ctx.error = error_code::no_matching_variant_type;
 4482|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4483|       |                                 return;
 4484|       |                              }
 4485|       |                           }
 4486|       |                           // Parse the type (handles tag skipping and unknown keys)
 4487|       |                           std::visit(
 4488|       |                              [&](auto&& v) {
 4489|       |                                 using V = std::decay_t<decltype(v)>;
 4490|       |                                 if constexpr (custom_read<V>) {
 4491|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4492|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4493|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4494|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4495|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4496|       |                                    // into its value, so error here rather than corrupt the result.
 4497|       |                                    if (it == start) {
 4498|       |                                       ctx.error = error_code::feature_not_supported;
 4499|       |                                       ctx.custom_error_message =
 4500|       |                                          "the tag must be the first key for a custom variant alternative";
 4501|       |                                       return;
 4502|       |                                    }
 4503|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4504|       |                                 }
 4505|       |                                 else {
 4506|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4507|       |                                       it = start; // tag is a struct field, must re-parse
 4508|       |                                    }
 4509|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4510|       |                                 }
 4511|       |                              },
 4512|       |                              value);
 4513|       |                           return;
 4514|       |                        }
 4515|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4516|       |                           ctx.error = error_code::unknown_key;
 4517|       |                           return;
 4518|       |                        }
 4519|       |                        else {
 4520|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4521|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4522|       |                              return;
 4523|       |                           }
 4524|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4525|       |                           if (bool(ctx.error)) [[unlikely]]
 4526|       |                              return;
 4527|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4528|       |                              return;
 4529|       |                           }
 4530|       |                           continue; // Continue loop to find the tag
 4531|       |                        }
 4532|       |                     }
 4533|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4534|       |                        ctx.error = error_code::unknown_key;
 4535|       |                        return;
 4536|       |                     }
 4537|       |
 4538|       |                     auto matching_types = possible_types.popcount();
 4539|       |                     if (matching_types == 0) {
 4540|       |                        ctx.error = error_code::no_matching_variant_type;
 4541|       |                        return;
 4542|       |                     }
 4543|       |                     // Only short-circuit for variants without tags
 4544|       |                     else if constexpr (tag_v<T>.empty()) {
 4545|       |                        if (matching_types == 1) {
 4546|       |                           it = start;
 4547|       |                           const auto type_index = possible_types.countr_zero();
 4548|       |
 4549|       |                           if (value.index() != static_cast<size_t>(type_index))
 4550|       |                              emplace_runtime_variant(value, type_index);
 4551|       |                           std::visit(
 4552|       |                              [&](auto&& v) {
 4553|       |                                 using V = std::decay_t<decltype(v)>;
 4554|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4555|       |                                 if constexpr (variant_unit_alternative<V>) {
 4556|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4557|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4558|       |                                    // terminator handling match every other alternative.
 4559|       |                                    detail::variant_unit_body unit_body{};
 4560|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4561|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4562|       |                                                                                                    end);
 4563|       |                                 }
 4564|       |                                 else if constexpr (is_object) {
 4565|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4566|       |                                 }
 4567|       |                                 else if constexpr (is_memory_object<V>) {
 4568|       |                                    if (!v) {
 4569|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4570|       |                                          if constexpr (requires { v.emplace(); }) {
 4571|       |                                             v.emplace();
 4572|       |                                          }
 4573|       |                                          else {
 4574|       |                                             v = typename V::value_type{};
 4575|       |                                          }
 4576|       |                                       }
 4577|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4578|       |                                          v = std::make_unique<typename V::element_type>();
 4579|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4580|       |                                          v = std::make_shared<typename V::element_type>();
 4581|       |                                       else if constexpr (constructible<V>) {
 4582|       |                                          v = meta_construct_v<V>();
 4583|       |                                       }
 4584|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4585|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4586|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4587|       |                                             return;
 4588|       |                                          }
 4589|       |                                       }
 4590|       |                                       else {
 4591|       |                                          ctx.error = error_code::invalid_nullable_read;
 4592|       |                                          return;
 4593|       |                                          // Cannot read into unset nullable that is not std::optional,
 4594|       |                                          // std::unique_ptr, or std::shared_ptr
 4595|       |                                       }
 4596|       |                                    }
 4597|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4598|       |                                       *v, ctx, it, end);
 4599|       |                                 }
 4600|       |                                 else if constexpr (custom_read<V>) {
 4601|       |                                    // Custom handlers parse the remaining body themselves.
 4602|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4603|       |                                 }
 4604|       |                              },
 4605|       |                              value);
 4606|       |
 4607|       |                           return; // we've decoded our target type
 4608|       |                        }
 4609|       |                     }
 4610|       |                     // For tagged variants, continue processing to validate tags
 4611|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4612|       |                        return;
 4613|       |                     }
 4614|       |
 4615|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4616|       |                     if (bool(ctx.error)) [[unlikely]]
 4617|       |                        return;
 4618|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4619|       |                        return;
 4620|       |                     }
 4621|       |                  }
 4622|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4623|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4624|       |                     // After parsing all keys, check if we have multiple matching types
 4625|       |                     // If so, choose the one with the fewest fields
 4626|       |                     auto final_matching = possible_types.popcount();
 4627|       |                     if (final_matching == 0) {
 4628|       |                        ctx.error = error_code::no_matching_variant_type;
 4629|       |                     }
 4630|       |                     else if (final_matching == 1) {
 4631|       |                        // Single type remains after field deduction
 4632|       |                        const auto type_index = possible_types.countr_zero();
 4633|       |
 4634|       |                        // Validate against tag if one was specified
 4635|       |                        if (tag_specified_index.has_value() &&
 4636|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4637|       |                           ctx.error = error_code::no_matching_variant_type;
 4638|       |                           return;
 4639|       |                        }
 4640|       |
 4641|       |                        it = start;
 4642|       |                        if (value.index() != static_cast<size_t>(type_index))
 4643|       |                           emplace_runtime_variant(value, type_index);
 4644|       |                        std::visit(
 4645|       |                           [&](auto&& v) {
 4646|       |                              using V = std::decay_t<decltype(v)>;
 4647|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4648|       |                              if constexpr (variant_unit_alternative<V>) {
 4649|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4650|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4651|       |                                 // terminator handling match every other alternative.
 4652|       |                                 detail::variant_unit_body unit_body{};
 4653|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4654|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4655|       |                                                                                                 end);
 4656|       |                              }
 4657|       |                              else if constexpr (is_object) {
 4658|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4659|       |                              }
 4660|       |                              else if constexpr (is_memory_object<V>) {
 4661|       |                                 if (!v) {
 4662|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4663|       |                                       if constexpr (requires { v.emplace(); }) {
 4664|       |                                          v.emplace();
 4665|       |                                       }
 4666|       |                                       else {
 4667|       |                                          v = typename V::value_type{};
 4668|       |                                       }
 4669|       |                                    }
 4670|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4671|       |                                       v = std::make_unique<typename V::element_type>();
 4672|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4673|       |                                       v = std::make_shared<typename V::element_type>();
 4674|       |                                    else if constexpr (constructible<V>) {
 4675|       |                                       v = meta_construct_v<V>();
 4676|       |                                    }
 4677|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4678|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4679|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4680|       |                                          return;
 4681|       |                                       }
 4682|       |                                    }
 4683|       |                                    else {
 4684|       |                                       ctx.error = error_code::invalid_nullable_read;
 4685|       |                                       return;
 4686|       |                                    }
 4687|       |                                 }
 4688|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4689|       |                                                                                                               it, end);
 4690|       |                              }
 4691|       |                              else if constexpr (custom_read<V>) {
 4692|       |                                 // Custom handlers parse the remaining body themselves.
 4693|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4694|       |                              }
 4695|       |                           },
 4696|       |                           value);
 4697|       |                     }
 4698|       |                     else if (final_matching > 1) {
 4699|       |                        constexpr auto N = std::variant_size_v<T>;
 4700|       |
 4701|       |                        // Compile-time array of field counts for each variant type
 4702|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4703|       |                           return std::array<size_t, N> {
 4704|       |                              ([]<size_t J = I>() -> size_t {
 4705|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4706|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4707|       |                                    return reflect<V>::size;
 4708|       |                                 }
 4709|       |                                 else if constexpr (is_memory_object<V>) {
 4710|       |                                    using X = memory_type<V>;
 4711|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4712|       |                                       return reflect<X>::size;
 4713|       |                                    }
 4714|       |                                    else {
 4715|       |                                       return (std::numeric_limits<size_t>::max)();
 4716|       |                                    }
 4717|       |                                 }
 4718|       |                                 else {
 4719|       |                                    return (std::numeric_limits<size_t>::max)();
 4720|       |                                 }
 4721|       |                              }.template operator()<I>())...
 4722|       |                           };
 4723|       |                        }(std::make_index_sequence<N>{});
 4724|       |
 4725|       |                        // Find the type with minimum field count among the possible types
 4726|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4727|       |                        size_t chosen_index = N; // Invalid index initially
 4728|       |
 4729|       |                        for (size_t i = 0; i < N; ++i) {
 4730|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4731|       |                              min_fields = field_counts[i];
 4732|       |                              chosen_index = i;
 4733|       |                           }
 4734|       |                        }
 4735|       |
 4736|       |                        if (chosen_index < N) {
 4737|       |                           // Validate against tag if one was specified
 4738|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4739|       |                              ctx.error = error_code::no_matching_variant_type;
 4740|       |                              return;
 4741|       |                           }
 4742|       |
 4743|       |                           it = start;
 4744|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4745|       |                           std::visit(
 4746|       |                              [&](auto&& v) {
 4747|       |                                 using V = std::decay_t<decltype(v)>;
 4748|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4749|       |                                 if constexpr (variant_unit_alternative<V>) {
 4750|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4751|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4752|       |                                    // terminator handling match every other alternative.
 4753|       |                                    detail::variant_unit_body unit_body{};
 4754|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4755|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4756|       |                                                                                                    end);
 4757|       |                                 }
 4758|       |                                 else if constexpr (is_object) {
 4759|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4760|       |                                 }
 4761|       |                                 else if constexpr (is_memory_object<V>) {
 4762|       |                                    if (!v) {
 4763|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4764|       |                                          if constexpr (requires { v.emplace(); }) {
 4765|       |                                             v.emplace();
 4766|       |                                          }
 4767|       |                                          else {
 4768|       |                                             v = typename V::value_type{};
 4769|       |                                          }
 4770|       |                                       }
 4771|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4772|       |                                          v = std::make_unique<typename V::element_type>();
 4773|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4774|       |                                          v = std::make_shared<typename V::element_type>();
 4775|       |                                       else if constexpr (constructible<V>) {
 4776|       |                                          v = meta_construct_v<V>();
 4777|       |                                       }
 4778|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4779|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4780|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4781|       |                                             return;
 4782|       |                                          }
 4783|       |                                       }
 4784|       |                                       else {
 4785|       |                                          ctx.error = error_code::invalid_nullable_read;
 4786|       |                                          return;
 4787|       |                                       }
 4788|       |                                    }
 4789|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4790|       |                                       *v, ctx, it, end);
 4791|       |                                 }
 4792|       |                                 else if constexpr (custom_read<V>) {
 4793|       |                                    // Custom handlers parse the remaining body themselves.
 4794|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4795|       |                                 }
 4796|       |                              },
 4797|       |                              value);
 4798|       |                        }
 4799|       |                        else {
 4800|       |                           ctx.error = error_code::no_matching_variant_type;
 4801|       |                        }
 4802|       |                     }
 4803|       |                  }
 4804|       |                  else {
 4805|       |                     // For variants with 0 or 1 object types, use the original error handling
 4806|       |                     ctx.error = error_code::no_matching_variant_type;
 4807|       |                  }
 4808|       |               }
 4809|      0|               break;
 4810|  4.67k|            }
 4811|  2.00k|            case '[':
  ------------------
  |  Branch (4811:13): [True: 2.00k, False: 8.53k]
  ------------------
 4812|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4813|  2.00k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4814|  2.00k|               break;
 4815|  1.06k|            case '"': {
  ------------------
  |  Branch (4815:13): [True: 1.06k, False: 9.47k]
  ------------------
 4816|  1.06k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4817|  1.06k|               break;
 4818|  4.67k|            }
 4819|     65|            case 't':
  ------------------
  |  Branch (4819:13): [True: 65, False: 10.4k]
  ------------------
 4820|    180|            case 'f': {
  ------------------
  |  Branch (4820:13): [True: 115, False: 10.4k]
  ------------------
 4821|    180|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4822|    180|               break;
 4823|     65|            }
 4824|     73|            case 'n':
  ------------------
  |  Branch (4824:13): [True: 73, False: 10.4k]
  ------------------
 4825|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4826|       |                  ctx.error = error_code::no_matching_variant_type;
 4827|       |               }
 4828|     73|               else {
 4829|     73|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4830|     73|                  using V = std::variant_alternative_t<first_idx, T>;
 4831|     73|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4831:23): [True: 0, False: 73]
  ------------------
 4832|     73|                  match<"null", Opts>(ctx, it, end);
 4833|     73|               }
 4834|     73|               break;
 4835|  2.52k|            default: {
  ------------------
  |  Branch (4835:13): [True: 2.52k, False: 8.01k]
  ------------------
 4836|       |               // Not bool, string, object, or array so must be number or null
 4837|  2.52k|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4838|  2.52k|            }
 4839|  10.5k|            }
 4840|       |         }
 4841|       |         else {
 4842|       |            // For non-auto-deducible variants, try each type until one succeeds
 4843|       |            constexpr auto N = std::variant_size_v<T>;
 4844|       |            bool parsed = false;
 4845|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4846|       |
 4847|       |            for_each<N>([&]<size_t I>() {
 4848|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4849|       |
 4850|       |               auto copy_it = it;
 4851|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4852|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4853|       |               const auto copy_depth = ctx.depth;
 4854|       |
 4855|       |               // Try parsing as this type
 4856|       |               if (value.index() != I) {
 4857|       |                  emplace_runtime_variant(value, I);
 4858|       |               }
 4859|       |
 4860|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4861|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4862|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4863|       |               }
 4864|       |
 4865|       |               if (!bool(ctx.error)) {
 4866|       |                  parsed = true;
 4867|       |               }
 4868|       |               else if constexpr (not Options.null_terminated) {
 4869|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4870|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4871|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4872|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4873|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4874|       |                     parsed = true;
 4875|       |                     ctx.error = error_code::none;
 4876|       |                  }
 4877|       |                  else {
 4878|       |                     // Reset for next attempt (unless this is the last type)
 4879|       |                     it = copy_it;
 4880|       |                     rewind_depth<Options>(ctx, copy_depth);
 4881|       |                     if constexpr (I + 1 < N) {
 4882|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4883|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4884|       |                        }
 4885|       |                     }
 4886|       |                  }
 4887|       |               }
 4888|       |               else {
 4889|       |                  // Reset for next attempt (unless this is the last type)
 4890|       |                  it = copy_it;
 4891|       |                  rewind_depth<Options>(ctx, copy_depth);
 4892|       |                  if constexpr (I + 1 < N) {
 4893|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4894|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4895|       |                     }
 4896|       |                  }
 4897|       |               }
 4898|       |            });
 4899|       |         }
 4900|  10.5k|      }
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEERNS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES4_EEEETkNS_10is_contextERNS_7contextERPKcSD_EEvOT0_OT1_OT2_T3_:
   49|  27.9k|      {
   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|  27.9k|         else {
   60|  27.9k|            using V = std::remove_cvref_t<T>;
   61|  27.9k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  27.9k|                                             end);
   63|  27.9k|         }
   64|  27.9k|      }
_ZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_:
 3085|  27.9k|      {
 3086|  27.9k|         static constexpr auto num_members = reflect<T>::size;
 3087|       |
 3088|  27.9k|         static constexpr auto Opts = opening_handled_off<ws_handled_off<Options>()>();
 3089|       |         if constexpr (!check_opening_handled(Options)) {
 3090|       |            if constexpr (!check_ws_handled(Options)) {
 3091|       |               if (skip_ws<Opts>(ctx, it, end)) {
 3092|       |                  return;
 3093|       |               }
 3094|       |            }
 3095|       |            if (match_invalid_end<'{', Opts>(ctx, it, end)) {
 3096|       |               return;
 3097|       |            }
 3098|       |            if constexpr (not Opts.null_terminated) {
 3099|       |               if (it == end) [[unlikely]] {
 3100|       |                  ctx.error = error_code::unexpected_end;
 3101|       |                  return;
 3102|       |               }
 3103|       |            }
 3104|       |            // one nesting level (see enter_depth): counted in both modes so the limit binds,
 3105|       |            // released at each syntactic close below
 3106|       |            if (enter_depth(ctx)) [[unlikely]] {
 3107|       |               return;
 3108|       |            }
 3109|       |         }
 3110|  27.9k|         const auto ws_start = it;
 3111|  27.9k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3111:14): [True: 0, False: 27.9k]
  ------------------
 3112|      0|            return;
 3113|      0|         }
 3114|  27.9k|         const size_t ws_size = size_t(it - ws_start);
 3115|       |
 3116|       |         if constexpr ((glaze_object_t<T> || reflectable<T>) && num_members == 0 && Opts.error_on_unknown_keys) {
 3117|       |            if constexpr (not tag.sv().empty()) {
 3118|       |               if (*it == '"') {
 3119|       |                  ++it;
 3120|       |                  if constexpr (not Opts.null_terminated) {
 3121|       |                     if (it == end) [[unlikely]] {
 3122|       |                        ctx.error = error_code::unexpected_end;
 3123|       |                        return;
 3124|       |                     }
 3125|       |                  }
 3126|       |
 3127|       |                  const auto start = it;
 3128|       |                  skip_string_view(ctx, it, end);
 3129|       |                  if (bool(ctx.error)) [[unlikely]]
 3130|       |                     return;
 3131|       |                  if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3132|       |                     return;
 3133|       |                  const sv key{start, size_t(it - start)};
 3134|       |                  ++it;
 3135|       |                  if constexpr (not Opts.null_terminated) {
 3136|       |                     if (it == end) [[unlikely]] {
 3137|       |                        ctx.error = error_code::unexpected_end;
 3138|       |                        return;
 3139|       |                     }
 3140|       |                  }
 3141|       |
 3142|       |                  if (key == tag.sv()) {
 3143|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3144|       |                        return;
 3145|       |                     }
 3146|       |
 3147|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3148|       |                     if (bool(ctx.error)) [[unlikely]]
 3149|       |                        return;
 3150|       |
 3151|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3152|       |                        return;
 3153|       |                     }
 3154|       |                  }
 3155|       |                  else {
 3156|       |                     ctx.error = error_code::unknown_key;
 3157|       |                     return;
 3158|       |                  }
 3159|       |               }
 3160|       |            }
 3161|       |
 3162|       |            if (*it == '}') [[likely]] {
 3163|       |               --ctx.depth;
 3164|       |               if constexpr (glaze_object_t<T> || reflectable<T>) {
 3165|       |                  if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 3166|       |                     auto wrapper = self_constraint_v<T>(value);
 3167|       |                     from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 3168|       |                     if (bool(ctx.error)) {
 3169|       |                        return;
 3170|       |                     }
 3171|       |                  }
 3172|       |               }
 3173|       |               ++it;
 3174|       |               if constexpr (not Opts.null_terminated) {
 3175|       |                  if (it == end) {
 3176|       |                     ctx.error = error_code::end_reached;
 3177|       |                     return;
 3178|       |                  }
 3179|       |               }
 3180|       |               if constexpr (Opts.partial_read) {
 3181|       |                  ctx.error = error_code::partial_read_complete;
 3182|       |               }
 3183|       |               return;
 3184|       |            }
 3185|       |            ctx.error = error_code::unknown_key;
 3186|       |            return;
 3187|       |         }
 3188|  27.9k|         else {
 3189|  27.9k|            decltype(auto) fields = [&]() -> decltype(auto) {
 3190|  27.9k|               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 3191|  27.9k|                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 3192|  27.9k|                  return bit_array<num_members>{};
 3193|  27.9k|               }
 3194|  27.9k|               else {
 3195|  27.9k|                  return nullptr;
 3196|  27.9k|               }
 3197|  27.9k|            }();
 3198|       |
 3199|  27.9k|            size_t read_count{}; // for partial_read
 3200|       |
 3201|  27.9k|            bool first = true;
 3202|   965k|            while (true) {
  ------------------
  |  Branch (3202:20): [True: 940k, Folded]
  ------------------
 3203|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.partial_read) {
 3204|       |                  static constexpr bit_array<num_members> all_fields = [] {
 3205|       |                     bit_array<num_members> arr{};
 3206|       |                     for (size_t i = 0; i < num_members; ++i) {
 3207|       |                        arr[i] = true;
 3208|       |                     }
 3209|       |                     return arr;
 3210|       |                  }();
 3211|       |
 3212|       |                  if ((all_fields & fields) == all_fields) {
 3213|       |                     ctx.error = error_code::partial_read_complete;
 3214|       |                     --ctx.depth; // as above: an early success still closes this level
 3215|       |                     return;
 3216|       |                  }
 3217|       |               }
 3218|       |
 3219|       |               // Streaming refill point: at start of each iteration, ensure buffer has data
 3220|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 3221|       |                  if (ctx.stream.enabled()) {
 3222|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 3223|       |                     const size_t remaining = ctx.stream.size() - consumed;
 3224|       |                     // Refill when less than half of buffer remains to ensure space for next key-value pair
 3225|       |                     if (remaining <= ctx.stream.size() / 2 || it >= end) {
 3226|       |                        const char* new_it;
 3227|       |                        const char* new_end;
 3228|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 3229|       |                        it = new_it;
 3230|       |                        end = new_end;
 3231|       |                        if (it >= end && ctx.stream.at_eof()) {
 3232|       |                           ctx.error = error_code::unexpected_end;
 3233|       |                           return;
 3234|       |                        }
 3235|       |                     }
 3236|       |                  }
 3237|       |               }
 3238|       |
 3239|   940k|               if (*it == '}') {
  ------------------
  |  Branch (3239:20): [True: 2.74k, False: 937k]
  ------------------
 3240|  2.74k|                  --ctx.depth;
 3241|       |                  if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.error_on_missing_keys) {
 3242|       |                     constexpr auto req_fields = required_fields<T, Opts>();
 3243|       |                     if ((req_fields & fields) != req_fields) {
 3244|       |                        for (size_t i = 0; i < num_members; ++i) {
 3245|       |                           if (not fields[i] && req_fields[i]) {
 3246|       |                              ctx.custom_error_message = reflect<T>::keys[i];
 3247|       |                              // We just return the first missing key in order to avoid heap allocations
 3248|       |                              break;
 3249|       |                           }
 3250|       |                        }
 3251|       |
 3252|       |                        ctx.error = error_code::missing_key;
 3253|       |                        return;
 3254|       |                     }
 3255|       |                  }
 3256|       |                  if constexpr (glaze_object_t<T> || reflectable<T>) {
 3257|       |                     if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 3258|       |                        auto wrapper = self_constraint_v<T>(value);
 3259|       |                        from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 3260|       |                        if (bool(ctx.error)) {
 3261|       |                           return;
 3262|       |                        }
 3263|       |                     }
 3264|       |                  }
 3265|  2.74k|                  ++it; // Increment after checking for missing keys so errors are within buffer bounds
 3266|       |                  if constexpr (not Opts.null_terminated) {
 3267|       |                     if (it == end) {
 3268|       |                        ctx.error = error_code::end_reached;
 3269|       |                        return;
 3270|       |                     }
 3271|       |                  }
 3272|  2.74k|                  return;
 3273|  2.74k|               }
 3274|   937k|               else if (first) {
  ------------------
  |  Branch (3274:25): [True: 26.1k, False: 911k]
  ------------------
 3275|  26.1k|                  first = false;
 3276|  26.1k|               }
 3277|   911k|               else {
 3278|   911k|                  if (match_invalid_end<',', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3278:23): [True: 440, False: 911k]
  ------------------
 3279|    440|                     return;
 3280|    440|                  }
 3281|       |                  if constexpr (not Opts.null_terminated) {
 3282|       |                     if (it == end) [[unlikely]] {
 3283|       |                        ctx.error = error_code::unexpected_end;
 3284|       |                        return;
 3285|       |                     }
 3286|       |                  }
 3287|       |
 3288|       |                  if constexpr ((not Opts.minified) && (num_members > 1 || not Opts.error_on_unknown_keys) &&
 3289|       |                                (!Opts.comments)) {
 3290|       |                     if (ws_size && ws_size < size_t(end - it)) {
 3291|       |                        skip_matching_ws(ws_start, it, ws_size);
 3292|       |                     }
 3293|       |                  }
 3294|       |
 3295|   911k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3295:23): [True: 0, False: 911k]
  ------------------
 3296|      0|                     return;
 3297|      0|                  }
 3298|   911k|               }
 3299|       |
 3300|   937k|               constexpr auto reflection_type = glaze_object_t<T> || reflectable<T>;
  ------------------
  |  Branch (3300:49): [Folded, False: 0]
  |  Branch (3300:70): [Folded, False: 0]
  ------------------
 3301|       |
 3302|       |               if constexpr (reflection_type && (num_members == 0)) {
 3303|       |                  if constexpr (Opts.error_on_unknown_keys) {
 3304|       |                     static_assert(false_v<T>, "This should be unreachable");
 3305|       |                  }
 3306|       |                  else {
 3307|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 3308|       |                        return;
 3309|       |                     }
 3310|       |
 3311|       |                     // parsing to an empty object, but at this point the JSON presents keys
 3312|       |
 3313|       |                     // Unknown key handler does not unescape keys. Unknown escaped keys are
 3314|       |                     // handled by the user.
 3315|       |
 3316|       |                     const auto start = it;
 3317|       |                     skip_string_view(ctx, it, end);
 3318|       |                     if (bool(ctx.error)) [[unlikely]]
 3319|       |                        return;
 3320|       |                     if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3321|       |                        return;
 3322|       |                     const sv key{start, size_t(it - start)};
 3323|       |                     ++it;
 3324|       |                     if constexpr (not Opts.null_terminated) {
 3325|       |                        if (it == end) [[unlikely]] {
 3326|       |                           ctx.error = error_code::unexpected_end;
 3327|       |                           return;
 3328|       |                        }
 3329|       |                     }
 3330|       |
 3331|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3332|       |                        return;
 3333|       |                     }
 3334|       |
 3335|       |                     // Check if this key is the variant tag that should be skipped
 3336|       |                     if constexpr (not tag.sv().empty()) {
 3337|       |                        if (key == tag.sv()) {
 3338|       |                           // Skip the tag value
 3339|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3340|       |                           if (bool(ctx.error)) [[unlikely]]
 3341|       |                              return;
 3342|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 3343|       |                              return;
 3344|       |                           }
 3345|       |                           continue;
 3346|       |                        }
 3347|       |                     }
 3348|       |
 3349|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3350|       |                     if (bool(ctx.error)) [[unlikely]]
 3351|       |                        return;
 3352|       |                     if constexpr (not Opts.null_terminated) {
 3353|       |                        if (it == end) [[unlikely]] {
 3354|       |                           ctx.error = error_code::unexpected_end;
 3355|       |                           return;
 3356|       |                        }
 3357|       |                     }
 3358|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3359|       |                        return;
 3360|       |                     }
 3361|       |                  }
 3362|       |               }
 3363|       |               else if constexpr (reflection_type) {
 3364|       |                  static_assert(bool(hash_info<T>.type));
 3365|       |
 3366|       |                  if (*it != '"') [[unlikely]] {
 3367|       |                     ctx.error = error_code::expected_quote;
 3368|       |                     return;
 3369|       |                  }
 3370|       |                  ++it;
 3371|       |                  if constexpr (not Opts.null_terminated) {
 3372|       |                     if (it == end) [[unlikely]] {
 3373|       |                        ctx.error = error_code::unexpected_end;
 3374|       |                        return;
 3375|       |                     }
 3376|       |                  }
 3377|       |
 3378|       |                  if constexpr (not tag.sv().empty() && not contains_tag<T, tag>()) {
 3379|       |                     // For tagged variants we first check to see if the key matches the tag
 3380|       |                     // We only need to do this if the tag is not part of the keys
 3381|       |
 3382|       |                     const auto start = it;
 3383|       |                     skip_string_view(ctx, it, end);
 3384|       |                     if (bool(ctx.error)) [[unlikely]]
 3385|       |                        return;
 3386|       |                     if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3387|       |                        return;
 3388|       |                     const sv key{start, size_t(it - start)};
 3389|       |                     ++it;
 3390|       |                     if constexpr (not Opts.null_terminated) {
 3391|       |                        if (it == end) [[unlikely]] {
 3392|       |                           ctx.error = error_code::unexpected_end;
 3393|       |                           return;
 3394|       |                        }
 3395|       |                     }
 3396|       |
 3397|       |                     if (key == tag.sv()) {
 3398|       |                        if (parse_ws_colon<Opts>(ctx, it, end)) {
 3399|       |                           return;
 3400|       |                        }
 3401|       |
 3402|       |                        parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3403|       |                        if (bool(ctx.error)) [[unlikely]]
 3404|       |                           return;
 3405|       |
 3406|       |                        if (skip_ws<Opts>(ctx, it, end)) {
 3407|       |                           return;
 3408|       |                        }
 3409|       |                        continue;
 3410|       |                     }
 3411|       |                     else {
 3412|       |                        it = start; // reset the iterator
 3413|       |                     }
 3414|       |                  }
 3415|       |
 3416|       |                  if constexpr (Opts.error_on_missing_keys || Opts.partial_read) {
 3417|       |                     size_t index = num_members;
 3418|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end, index);
 3419|       |                     if (bool(ctx.error)) [[unlikely]]
 3420|       |                        return;
 3421|       |                     if (index < num_members) {
 3422|       |                        fields[index] = true;
 3423|       |                     }
 3424|       |                  }
 3425|       |                  else {
 3426|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end);
 3427|       |                     if (bool(ctx.error)) [[unlikely]]
 3428|       |                        return;
 3429|       |                  }
 3430|       |               }
 3431|   937k|               else {
 3432|       |                  // For types like std::map, std::unordered_map
 3433|       |
 3434|   937k|                  auto reading = [&](auto&& key) {
 3435|   937k|                     if constexpr (Opts.partial_read) {
 3436|   937k|                        if (auto element = value.find(key); element != value.end()) {
 3437|   937k|                           ++read_count;
 3438|   937k|                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3439|   937k|                        }
 3440|   937k|                        else {
 3441|   937k|                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3442|   937k|                        }
 3443|   937k|                     }
 3444|   937k|                     else {
 3445|   937k|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3446|   937k|                     }
 3447|   937k|                  };
 3448|       |
 3449|       |                  // using Key = std::conditional_t<heterogeneous_map<T>, sv, typename T::key_type>;
 3450|   937k|                  using Key = typename T::key_type;
 3451|   937k|                  if constexpr (std::is_same_v<Key, std::string>) {
 3452|   937k|                     ctx.scratch.clear();
 3453|   937k|                     parse<JSON>::op<Opts>(ctx.scratch, ctx, it, end);
 3454|   937k|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3454:26): [True: 1.57k, False: 935k]
  ------------------
 3455|  1.57k|                        return;
 3456|       |
 3457|   935k|                     if (parse_ws_colon<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3457:26): [True: 835, False: 934k]
  ------------------
 3458|    835|                        return;
 3459|    835|                     }
 3460|       |
 3461|   934k|                     reading(ctx.scratch);
 3462|       |                     if constexpr (Opts.partial_read) {
 3463|       |                        if (read_count == value.size()) {
 3464|       |                           return;
 3465|       |                        }
 3466|       |                     }
 3467|   934k|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3467:26): [True: 22.3k, False: 912k]
  ------------------
 3468|  22.3k|                        return;
 3469|       |                  }
 3470|       |                  else if constexpr (str_t<Key>) {
 3471|       |                     Key key;
 3472|       |                     parse<JSON>::op<Opts>(key, ctx, it, end);
 3473|       |                     if (bool(ctx.error)) [[unlikely]]
 3474|       |                        return;
 3475|       |
 3476|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3477|       |                        return;
 3478|       |                     }
 3479|       |
 3480|       |                     reading(key);
 3481|       |                     if constexpr (Opts.partial_read) {
 3482|       |                        if (read_count == value.size()) {
 3483|       |                           return;
 3484|       |                        }
 3485|       |                     }
 3486|       |                     if (bool(ctx.error)) [[unlikely]]
 3487|       |                        return;
 3488|       |                  }
 3489|       |                  else {
 3490|       |                     Key key_value{};
 3491|       |                     if constexpr (is_named_enum<Key> || mimics_str_t<Key>) {
 3492|       |                        parse<JSON>::op<Opts>(key_value, ctx, it, end);
 3493|       |                     }
 3494|       |                     else if constexpr (std::is_arithmetic_v<Key>) {
 3495|       |                        // prefer over quoted_t below to avoid double parsing of quoted_t
 3496|       |                        parse<JSON>::op<opt_true<Opts, quoted_num_opt_tag{}>>(key_value, ctx, it, end);
 3497|       |                     }
 3498|       |                     else {
 3499|       |                        parse<JSON>::op<opt_false<Opts, raw_string_opt_tag{}>>(quoted_t<Key>{key_value}, ctx, it, end);
 3500|       |                     }
 3501|       |                     if (bool(ctx.error)) [[unlikely]]
 3502|       |                        return;
 3503|       |
 3504|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3505|       |                        return;
 3506|       |                     }
 3507|       |
 3508|       |                     reading(key_value);
 3509|       |                     if constexpr (Opts.partial_read) {
 3510|       |                        if (read_count == value.size()) {
 3511|       |                           return;
 3512|       |                        }
 3513|       |                     }
 3514|       |                     if (bool(ctx.error)) [[unlikely]]
 3515|       |                        return;
 3516|       |                  }
 3517|   937k|               }
 3518|       |
 3519|       |               // Streaming refill point: after parsing each key-value pair, refill if buffer is low
 3520|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 3521|       |                  if (ctx.stream.enabled()) {
 3522|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 3523|       |                     // Refill when less than 25% of buffer remains to ensure enough space for next element
 3524|       |                     if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 3525|       |                        const char* new_it;
 3526|       |                        const char* new_end;
 3527|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 3528|       |                        it = new_it;
 3529|       |                        end = new_end;
 3530|       |                        if (it >= end && ctx.stream.at_eof()) {
 3531|       |                           ctx.error = error_code::unexpected_end;
 3532|       |                           return;
 3533|       |                        }
 3534|       |                     }
 3535|       |                  }
 3536|       |               }
 3537|       |
 3538|   937k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3538:20): [True: 0, False: 937k]
  ------------------
 3539|      0|                  return;
 3540|      0|               }
 3541|   937k|            }
 3542|  27.9k|         }
 3543|  27.9k|      }
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlvE_clEv:
 3189|  27.9k|            decltype(auto) fields = [&]() -> decltype(auto) {
 3190|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 3191|       |                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 3192|       |                  return bit_array<num_members>{};
 3193|       |               }
 3194|  27.9k|               else {
 3195|  27.9k|                  return nullptr;
 3196|  27.9k|               }
 3197|  27.9k|            }();
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|   937k|      {
   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|   937k|         else {
   60|   937k|            using V = std::remove_cvref_t<T>;
   61|   937k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|   937k|                                             end);
   63|   937k|         }
   64|   937k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEQntcl15check_is_paddedTL0__EEEvRT2_OT3_OT0_T1_:
 1084|   937k|      {
 1085|       |         if constexpr (check_string_as_number(Opts)) {
 1086|       |            auto start = it;
 1087|       |            skip_number<Opts>(ctx, it, end);
 1088|       |            if (bool(ctx.error)) [[unlikely]] {
 1089|       |               return;
 1090|       |            }
 1091|       |            if (start == it) [[unlikely]] {
 1092|       |               ctx.error = error_code::parse_number_failure;
 1093|       |               return;
 1094|       |            }
 1095|       |            value.append(start, size_t(it - start));
 1096|       |         }
 1097|   937k|         else {
 1098|   937k|            if constexpr (!check_opening_handled(Opts)) {
 1099|   937k|               if constexpr (!check_ws_handled(Opts)) {
 1100|   937k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (1100:23): [True: 0, False: 937k]
  ------------------
 1101|      0|                     return;
 1102|      0|                  }
 1103|   937k|               }
 1104|       |
 1105|   937k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (1105:20): [True: 320, False: 936k]
  ------------------
 1106|    320|                  return;
 1107|    320|               }
 1108|   937k|            }
 1109|       |
 1110|   937k|            if constexpr (not check_raw_string(Opts)) {
 1111|   937k|               static constexpr auto string_padding_bytes = 8;
 1112|       |
 1113|   937k|               if (size_t(end - it) >= 8) {
  ------------------
  |  Branch (1113:20): [True: 935k, False: 1.66k]
  ------------------
 1114|   935k|                  auto start = it;
 1115|   935k|                  uint64_t ascii_acc{};
 1116|   935k|                  const auto end8 = end - 8;
 1117|  5.29M|                  while (true) {
  ------------------
  |  Branch (1117:26): [True: 5.29M, Folded]
  ------------------
 1118|  5.29M|                     if (it >= end8) [[unlikely]] {
  ------------------
  |  Branch (1118:26): [True: 906, False: 5.29M]
  ------------------
 1119|    906|                        break;
 1120|    906|                     }
 1121|       |
 1122|  5.29M|                     uint64_t chunk;
 1123|  5.29M|                     std::memcpy(&chunk, it, 8);
 1124|       |                     if constexpr (std::endian::native == std::endian::big) {
 1125|       |                        chunk = std::byteswap(chunk);
 1126|       |                     }
 1127|  5.29M|                     ascii_acc |= chunk;
 1128|  5.29M|                     const uint64_t test_chars = has_quote(chunk);
 1129|  5.29M|                     if (test_chars) {
  ------------------
  |  Branch (1129:26): [True: 936k, False: 4.35M]
  ------------------
 1130|   936k|                        it += (countr_zero(test_chars) >> 3);
 1131|       |
 1132|   936k|                        auto* prev = it - 1;
 1133|   938k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1133:32): [True: 2.48k, False: 936k]
  ------------------
 1134|  2.48k|                           --prev;
 1135|  2.48k|                        }
 1136|   936k|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1136:29): [True: 934k, False: 1.39k]
  ------------------
 1137|   934k|                           goto continue_decode;
 1138|   934k|                        }
 1139|  1.39k|                        ++it; // skip the escaped quote
 1140|  1.39k|                     }
 1141|  4.35M|                     else {
 1142|  4.35M|                        it += 8;
 1143|  4.35M|                     }
 1144|  5.29M|                  }
 1145|       |
 1146|  2.31k|                  while (it[-1] == '\\') [[unlikely]] {
  ------------------
  |  Branch (1146:26): [True: 1.40k, False: 906]
  ------------------
 1147|       |                     // if we ended on an escape character then we need to rewind
 1148|       |                     // because we lost our context
 1149|  1.40k|                     --it;
 1150|  1.40k|                  }
 1151|       |
 1152|       |                  // The byte-wise tail keeps feeding the accumulator: it has to cover every byte of
 1153|       |                  // the string, or a non-ASCII byte reached here would be waved through unvalidated.
 1154|  5.08k|                  for (; it < end; ++it) {
  ------------------
  |  Branch (1154:26): [True: 4.73k, False: 351]
  ------------------
 1155|  4.73k|                     ascii_acc |= uint8_t(*it);
 1156|  4.73k|                     if (*it == '"') {
  ------------------
  |  Branch (1156:26): [True: 613, False: 4.12k]
  ------------------
 1157|    613|                        auto* prev = it - 1;
 1158|  1.12k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1158:32): [True: 514, False: 613]
  ------------------
 1159|    514|                           --prev;
 1160|    514|                        }
 1161|    613|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1161:29): [True: 555, False: 58]
  ------------------
 1162|    555|                           goto continue_decode;
 1163|    555|                        }
 1164|    613|                     }
 1165|  4.73k|                  }
 1166|       |
 1167|    351|                  ctx.error = error_code::unexpected_end;
 1168|    351|                  return;
 1169|       |
 1170|   935k|               continue_decode:
 1171|       |
 1172|   935k|                  if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (1172:23): [True: 309, False: 934k]
  ------------------
 1173|    309|                     return;
 1174|    309|                  }
 1175|       |
 1176|   934k|                  const auto available_padding = size_t(end - it);
 1177|   934k|                  auto n = size_t(it - start);
 1178|   934k|                  if (available_padding >= 8) [[likely]] {
  ------------------
  |  Branch (1178:23): [True: 934k, False: 598]
  ------------------
 1179|   934k|                     value.resize(n + string_padding_bytes);
 1180|       |
 1181|   934k|                     auto* p = value.data();
 1182|       |
 1183|  5.63M|                     while (true) {
  ------------------
  |  Branch (1183:29): [True: 5.63M, Folded]
  ------------------
 1184|  5.63M|                        if (start >= it) {
  ------------------
  |  Branch (1184:29): [True: 933k, False: 4.70M]
  ------------------
 1185|   933k|                           break;
 1186|   933k|                        }
 1187|       |
 1188|  4.70M|                        std::memcpy(p, start, 8);
 1189|  4.70M|                        uint64_t swar;
 1190|  4.70M|                        std::memcpy(&swar, p, 8);
 1191|       |                        if constexpr (std::endian::native == std::endian::big) {
 1192|       |                           swar = std::byteswap(swar);
 1193|       |                        }
 1194|       |
 1195|  4.70M|                        constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1196|  4.70M|                        const uint64_t lo7 = swar & lo7_mask;
 1197|  4.70M|                        const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1198|  4.70M|                        const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1199|  4.70M|                        uint64_t next = ~((backslash & less_32) | swar);
 1200|       |
 1201|  4.70M|                        next &= repeat_byte8(0b10000000);
 1202|  4.70M|                        if (next == 0) {
  ------------------
  |  Branch (1202:29): [True: 4.67M, False: 26.8k]
  ------------------
 1203|  4.67M|                           start += 8;
 1204|  4.67M|                           p += 8;
 1205|  4.67M|                           continue;
 1206|  4.67M|                        }
 1207|       |
 1208|  26.8k|                        next = countr_zero(next) >> 3;
 1209|  26.8k|                        start += next;
 1210|  26.8k|                        if (start >= it) {
  ------------------
  |  Branch (1210:29): [True: 504, False: 26.3k]
  ------------------
 1211|    504|                           break;
 1212|    504|                        }
 1213|       |
 1214|  26.3k|                        if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1214:29): [True: 116, False: 26.2k]
  ------------------
 1215|    116|                           ctx.error = error_code::syntax_error;
 1216|    116|                           return;
 1217|    116|                        }
 1218|  26.2k|                        ++start; // skip the escape
 1219|  26.2k|                        if (*start == 'u') {
  ------------------
  |  Branch (1219:29): [True: 19.1k, False: 7.06k]
  ------------------
 1220|  19.1k|                           ++start;
 1221|  19.1k|                           p += next;
 1222|  19.1k|                           const auto mark = start;
 1223|  19.1k|                           const auto offset = handle_unicode_code_point(start, p, end);
 1224|  19.1k|                           if (offset == 0) [[unlikely]] {
  ------------------
  |  Branch (1224:32): [True: 64, False: 19.1k]
  ------------------
 1225|     64|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1226|     64|                              return;
 1227|     64|                           }
 1228|  19.1k|                           n += offset;
 1229|       |                           // escape + u + unicode code points
 1230|  19.1k|                           n -= 2 + uint32_t(start - mark);
 1231|  19.1k|                        }
 1232|  7.06k|                        else {
 1233|  7.06k|                           p += next;
 1234|  7.06k|                           *p = char_unescape_table[uint8_t(*start)];
 1235|  7.06k|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1235:32): [True: 14, False: 7.05k]
  ------------------
 1236|     14|                              ctx.error = error_code::invalid_escape;
 1237|     14|                              return;
 1238|     14|                           }
 1239|  7.05k|                           ++p;
 1240|  7.05k|                           ++start;
 1241|  7.05k|                           --n;
 1242|  7.05k|                        }
 1243|  26.2k|                     }
 1244|       |
 1245|   934k|                     value.resize(n);
 1246|   934k|                     ++it;
 1247|   934k|                  }
 1248|    598|                  else {
 1249|       |                     // For large inputs this case of running out of buffer is very rare
 1250|    598|                     value.resize(n);
 1251|    598|                     auto* p = value.data();
 1252|       |
 1253|    598|                     it = start;
 1254|  25.8k|                     while (it < end) [[likely]] {
  ------------------
  |  Branch (1254:29): [True: 25.8k, False: 0]
  ------------------
 1255|  25.8k|                        if (*it == '"') {
  ------------------
  |  Branch (1255:29): [True: 448, False: 25.3k]
  ------------------
 1256|    448|                           value.resize(size_t(p - value.data()));
 1257|    448|                           ++it;
 1258|    448|                           return;
 1259|    448|                        }
 1260|       |
 1261|  25.3k|                        if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1261:29): [True: 53, False: 25.3k]
  ------------------
 1262|     53|                           ctx.error = error_code::syntax_error;
 1263|     53|                           return;
 1264|     53|                        }
 1265|       |
 1266|  25.3k|                        *p = *it;
 1267|       |
 1268|  25.3k|                        if (*it == '\\') {
  ------------------
  |  Branch (1268:29): [True: 1.86k, False: 23.4k]
  ------------------
 1269|  1.86k|                           ++it; // skip the escape
 1270|  1.86k|                           if (*it == 'u') {
  ------------------
  |  Branch (1270:32): [True: 997, False: 870]
  ------------------
 1271|    997|                              ++it;
 1272|    997|                              if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1272:35): [True: 82, False: 915]
  ------------------
 1273|     82|                                 ctx.error = error_code::unicode_escape_conversion_failure;
 1274|     82|                                 return;
 1275|     82|                              }
 1276|    997|                           }
 1277|    870|                           else {
 1278|    870|                              *p = char_unescape_table[uint8_t(*it)];
 1279|    870|                              if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1279:35): [True: 15, False: 855]
  ------------------
 1280|     15|                                 ctx.error = error_code::invalid_escape;
 1281|     15|                                 return;
 1282|     15|                              }
 1283|    855|                              ++p;
 1284|    855|                              ++it;
 1285|    855|                           }
 1286|  1.86k|                        }
 1287|  23.4k|                        else {
 1288|  23.4k|                           ++it;
 1289|  23.4k|                           ++p;
 1290|  23.4k|                        }
 1291|  25.3k|                     }
 1292|       |
 1293|      0|                     ctx.error = error_code::unexpected_end;
 1294|      0|                  }
 1295|   934k|               }
 1296|  1.66k|               else {
 1297|       |                  // For short strings
 1298|       |
 1299|  1.66k|                  std::array<char, 8> buffer{};
 1300|       |
 1301|  1.66k|                  auto* p = buffer.data();
 1302|  1.66k|                  const auto* const utf8_start = it;
 1303|       |
 1304|  3.13k|                  while (it < end) [[likely]] {
  ------------------
  |  Branch (1304:26): [True: 2.81k, False: 320]
  ------------------
 1305|  2.81k|                     *p = *it;
 1306|  2.81k|                     if (*it == '"') {
  ------------------
  |  Branch (1306:26): [True: 1.16k, False: 1.64k]
  ------------------
 1307|  1.16k|                        if (validate_utf8_span<Opts>(ctx, utf8_start, it)) [[unlikely]] {
  ------------------
  |  Branch (1307:29): [True: 70, False: 1.09k]
  ------------------
 1308|     70|                           return;
 1309|     70|                        }
 1310|  1.09k|                        const size_t n = size_t(p - buffer.data());
 1311|  1.09k|#if __has_cpp_attribute(assume) >= 202207L
 1312|  1.09k|                        [[assume(n <= sizeof(buffer))]];
 1313|  1.09k|#endif
 1314|  1.09k|                        value.assign(buffer.data(), n);
 1315|  1.09k|                        ++it;
 1316|       |                        if constexpr (not Opts.null_terminated) {
 1317|       |                           if (it == end) {
 1318|       |                              ctx.error = error_code::end_reached;
 1319|       |                              return;
 1320|       |                           }
 1321|       |                        }
 1322|  1.09k|                        return;
 1323|  1.16k|                     }
 1324|  1.64k|                     else if (*it == '\\') {
  ------------------
  |  Branch (1324:31): [True: 83, False: 1.56k]
  ------------------
 1325|     83|                        ++it; // skip the escape
 1326|       |                        if constexpr (not Opts.null_terminated) {
 1327|       |                           if (it == end) [[unlikely]] {
 1328|       |                              ctx.error = error_code::unexpected_end;
 1329|       |                              return;
 1330|       |                           }
 1331|       |                        }
 1332|     83|                        if (*it == 'u') {
  ------------------
  |  Branch (1332:29): [True: 42, False: 41]
  ------------------
 1333|     42|                           ++it;
 1334|       |                           if constexpr (not Opts.null_terminated) {
 1335|       |                              if (it == end) [[unlikely]] {
 1336|       |                                 ctx.error = error_code::unexpected_end;
 1337|       |                                 return;
 1338|       |                              }
 1339|       |                           }
 1340|     42|                           if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1340:32): [True: 10, False: 32]
  ------------------
 1341|     10|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1342|     10|                              return;
 1343|     10|                           }
 1344|     42|                        }
 1345|     41|                        else {
 1346|     41|                           *p = char_unescape_table[uint8_t(*it)];
 1347|     41|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1347:32): [True: 13, False: 28]
  ------------------
 1348|     13|                              ctx.error = error_code::invalid_escape;
 1349|     13|                              return;
 1350|     13|                           }
 1351|     28|                           ++p;
 1352|     28|                           ++it;
 1353|     28|                        }
 1354|     83|                     }
 1355|  1.56k|                     else if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1355:31): [True: 155, False: 1.40k]
  ------------------
 1356|    155|                        ctx.error = error_code::syntax_error;
 1357|    155|                        return;
 1358|    155|                     }
 1359|  1.40k|                     else {
 1360|  1.40k|                        ++it;
 1361|  1.40k|                        ++p;
 1362|  1.40k|                     }
 1363|  2.81k|                  }
 1364|       |
 1365|    320|                  ctx.error = error_code::unexpected_end;
 1366|    320|               }
 1367|       |            }
 1368|       |            else {
 1369|       |               // raw_string
 1370|       |               auto start = it;
 1371|       |               skip_string_view(ctx, it, end);
 1372|       |               if (bool(ctx.error)) [[unlikely]]
 1373|       |                  return;
 1374|       |
 1375|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1376|       |                  return;
 1377|       |               }
 1378|       |
 1379|       |               value.assign(start, size_t(it - start));
 1380|       |               ++it;
 1381|       |            }
 1382|   937k|         }
 1383|   937k|      }
_ZN3glz14parse_ws_colonITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT0_OT1_T2_:
  159|   935k|   {
  160|   935k|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (160:11): [True: 0, False: 935k]
  ------------------
  161|      0|         return true;
  162|      0|      }
  163|   935k|      if (match_invalid_end<':', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (163:11): [True: 835, False: 934k]
  ------------------
  164|    835|         return true;
  165|    835|      }
  166|   934k|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (166:11): [True: 0, False: 934k]
  ------------------
  167|      0|         return true;
  168|      0|      }
  169|   934k|      return false;
  170|   934k|   }
_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_:
 3434|   934k|                  auto reading = [&](auto&& key) {
 3435|       |                     if constexpr (Opts.partial_read) {
 3436|       |                        if (auto element = value.find(key); element != value.end()) {
 3437|       |                           ++read_count;
 3438|       |                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3439|       |                        }
 3440|       |                        else {
 3441|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3442|       |                        }
 3443|       |                     }
 3444|   934k|                     else {
 3445|   934k|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3446|   934k|                     }
 3447|   934k|                  };
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  2.70M|      {
   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.70M|         else {
   60|  2.70M|            using V = std::remove_cvref_t<T>;
   61|  2.70M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  2.70M|                                             end);
   63|  2.70M|         }
   64|  2.70M|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  2.70M|      {
  151|  2.70M|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  2.70M|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  2.70M|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  2.70M|      }
_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_:
 4093|  2.70M|      {
 4094|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 4095|       |            read_adjacent<Options>(value, ctx, it, end);
 4096|       |         }
 4097|  2.70M|         else {
 4098|  2.70M|            read_deduced<Options>(value, ctx, it, end);
 4099|  2.70M|         }
 4100|  2.70M|      }
_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_:
 4104|  2.70M|      {
 4105|  2.70M|         constexpr auto Opts = ws_handled_off<Options>();
 4106|  2.70M|         if constexpr (variant_is_auto_deducible<T>()) {
 4107|       |            if constexpr (not check_ws_handled(Options)) {
 4108|       |               if (skip_ws<Opts>(ctx, it, end)) {
 4109|       |                  return;
 4110|       |               }
 4111|       |            }
 4112|       |
 4113|  2.70M|            switch (*it) {
 4114|  1.29k|            case '\0':
  ------------------
  |  Branch (4114:13): [True: 1.29k, False: 2.69M]
  ------------------
 4115|  1.29k|               ctx.error = error_code::unexpected_end;
 4116|  1.29k|               return;
 4117|  23.2k|            case '{': {
  ------------------
  |  Branch (4117:13): [True: 23.2k, False: 2.67M]
  ------------------
 4118|       |               // This branch consumes the brace itself and hands the object to a reader with
 4119|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 4120|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 4121|       |               // the reader below.
 4122|  23.2k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (4122:20): [True: 4, False: 23.2k]
  ------------------
 4123|      4|                  return;
 4124|      4|               }
 4125|       |
 4126|  23.2k|               ++it;
 4127|       |               if constexpr (not Opts.null_terminated) {
 4128|       |                  if (it == end) [[unlikely]] {
 4129|       |                     ctx.error = error_code::unexpected_end;
 4130|       |                     return;
 4131|       |                  }
 4132|       |               }
 4133|  23.2k|               using type_counts = variant_type_count<T>;
 4134|  23.2k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 4135|       |               if constexpr (n_object_candidates < 1) {
 4136|       |                  ctx.error = error_code::no_matching_variant_type;
 4137|       |                  return;
 4138|       |               }
 4139|  23.2k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 4140|  23.2k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 4141|  23.2k|                  using V = std::variant_alternative_t<first_idx, T>;
 4142|  23.2k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4142:23): [True: 22.8k, False: 379]
  ------------------
 4143|  23.2k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 4144|  23.2k|                  return;
 4145|       |               }
 4146|       |               else {
 4147|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 4148|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 4149|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 4150|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 4151|       |
 4152|       |                  // Track if we've encountered a tag and what value it had
 4153|       |                  std::optional<size_t> tag_specified_index{};
 4154|       |
 4155|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 4156|       |                     return;
 4157|       |                  }
 4158|       |                  auto start = it;
 4159|       |                  bool first_key = true;
 4160|       |                  // Parse bifurcation for tagged variants:
 4161|       |                  //
 4162|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 4163|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 4164|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 4165|       |                  //
 4166|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 4167|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 4168|       |                  // it advances past the trailing comma so the object parser picks up at the
 4169|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 4170|       |                  //
 4171|       |                  // One exception: if the tag name is also a field on the resolved struct
 4172|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 4173|       |                  // the struct field. This override is applied inside each std::visit lambda.
 4174|       |                  auto position_after_tag = [&] {
 4175|       |                     if (first_key) {
 4176|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 4177|       |                     }
 4178|       |                     else {
 4179|       |                        it = start; // tag was not the first key, re-parse from the beginning
 4180|       |                     }
 4181|       |                  };
 4182|       |                  while (*it != '}') {
 4183|       |                     if (it != start) {
 4184|       |                        first_key = false;
 4185|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 4186|       |                           return;
 4187|       |                        }
 4188|       |                     }
 4189|       |
 4190|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4191|       |                        return;
 4192|       |                     }
 4193|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4194|       |                        return;
 4195|       |                     }
 4196|       |
 4197|       |                     auto* key_start = it;
 4198|       |                     skip_string_view(ctx, it, end);
 4199|       |                     if (bool(ctx.error)) [[unlikely]]
 4200|       |                        return;
 4201|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 4202|       |                        return;
 4203|       |                     const sv key = {key_start, size_t(it - key_start)};
 4204|       |
 4205|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4206|       |                        return;
 4207|       |                     }
 4208|       |
 4209|       |                     if constexpr (deduction_key_count > 0) {
 4210|       |                        // We first check if a tag is defined and see if the key matches the tag
 4211|       |                        if constexpr (not tag_v<T>.empty()) {
 4212|       |                           if (key == tag_v<T>) {
 4213|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 4214|       |                                 return;
 4215|       |                              }
 4216|       |
 4217|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 4218|       |
 4219|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 4220|       |                              if constexpr (std::integral<id_type>) {
 4221|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4222|       |                              }
 4223|       |                              else {
 4224|       |                                 from<JSON, sv>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4225|       |                              }
 4226|       |                              if (bool(ctx.error)) [[unlikely]]
 4227|       |                                 return;
 4228|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4229|       |                                 return;
 4230|       |                              }
 4231|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4232|       |                                 ctx.error = error_code::syntax_error;
 4233|       |                                 return;
 4234|       |                              }
 4235|       |
 4236|       |                              size_t type_index;
 4237|       |                              if constexpr (std::integral<id_type>) {
 4238|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4239|       |                              }
 4240|       |                              else {
 4241|       |                                 type_index = variant_id_to_index<T>::op(
 4242|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4243|       |                              }
 4244|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4245|       |                                 // Check if the deduced types include the tag-specified type
 4246|       |                                 // If not, the tag doesn't match the fields
 4247|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4248|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4249|       |                                 // Check if the tag-specified type is still possible
 4250|       |                                 const bool type_is_possible = possible_types[type_index];
 4251|       |                                 if (!type_is_possible) {
 4252|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4253|       |                                    ctx.error = error_code::no_matching_variant_type;
 4254|       |                                    return;
 4255|       |                                 }
 4256|       |
 4257|       |                                 position_after_tag();
 4258|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4259|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4260|       |                                 std::visit(
 4261|       |                                    [&](auto&& v) {
 4262|       |                                       using V = std::decay_t<decltype(v)>;
 4263|       |                                       constexpr bool is_object =
 4264|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4265|       |                                       if constexpr (variant_unit_alternative<V>) {
 4266|       |                                          // A unit alternative carries no data; its object holds only the
 4267|       |                                          // discriminator. Consume that body through an empty reflected object so
 4268|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4269|       |                                          detail::variant_unit_body unit_body{};
 4270|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4271|       |                                                                                             tag_literal>(unit_body,
 4272|       |                                                                                                          ctx, it, end);
 4273|       |                                       }
 4274|       |                                       else if constexpr (is_object) {
 4275|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4276|       |                                             it = start; // tag is a struct field, must re-parse
 4277|       |                                          }
 4278|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4279|       |                                                                                                           end);
 4280|       |                                       }
 4281|       |                                       else if constexpr (is_memory_object<V>) {
 4282|       |                                          if (!v) {
 4283|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4284|       |                                                if constexpr (requires { v.emplace(); }) {
 4285|       |                                                   v.emplace();
 4286|       |                                                }
 4287|       |                                                else {
 4288|       |                                                   v = typename V::value_type{};
 4289|       |                                                }
 4290|       |                                             }
 4291|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4292|       |                                                v = std::make_unique<typename V::element_type>();
 4293|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4294|       |                                                v = std::make_shared<typename V::element_type>();
 4295|       |                                             else if constexpr (constructible<V>) {
 4296|       |                                                v = meta_construct_v<V>();
 4297|       |                                             }
 4298|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4299|       |                                                                can_allocate_raw_pointer<Opts,
 4300|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4301|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4302|       |                                                   return;
 4303|       |                                                }
 4304|       |                                             }
 4305|       |                                             else {
 4306|       |                                                ctx.error = error_code::invalid_nullable_read;
 4307|       |                                                return;
 4308|       |                                                // Cannot read into unset nullable that is not std::optional,
 4309|       |                                                // std::unique_ptr, or std::shared_ptr
 4310|       |                                             }
 4311|       |                                          }
 4312|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4313|       |                                             it = start; // tag is a struct field, must re-parse
 4314|       |                                          }
 4315|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4316|       |                                             *v, ctx, it, end);
 4317|       |                                       }
 4318|       |                                       else if constexpr (custom_read<V>) {
 4319|       |                                          // Custom handlers parse the remaining body themselves and do not
 4320|       |                                          // accept the tag template parameter; the tag was already consumed.
 4321|       |                                          // This only works when the tag was the first key. If it came later,
 4322|       |                                          // we were reset to the object start and the custom handler would
 4323|       |                                          // absorb the tag, so error rather than corrupt the value.
 4324|       |                                          if (it == start) {
 4325|       |                                             ctx.error = error_code::feature_not_supported;
 4326|       |                                             ctx.custom_error_message =
 4327|       |                                                "the tag must be the first key for a custom variant alternative";
 4328|       |                                             return;
 4329|       |                                          }
 4330|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4331|       |                                       }
 4332|       |                                    },
 4333|       |                                    value);
 4334|       |
 4335|       |                                 return; // we've decoded our target type
 4336|       |                              }
 4337|       |                              else [[unlikely]] {
 4338|       |                                 // Check if we have a default type (ids array shorter than variant)
 4339|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4340|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4341|       |                                 if constexpr (ids_size < variant_size) {
 4342|       |                                    // Use the first unlabeled type as the default
 4343|       |                                    const auto default_type_index = ids_size;
 4344|       |
 4345|       |                                    position_after_tag();
 4346|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4347|       |                                    if (value.index() != default_type_index)
 4348|       |                                       emplace_runtime_variant(value, default_type_index);
 4349|       |                                    std::visit(
 4350|       |                                       [&](auto&& v) {
 4351|       |                                          using V = std::decay_t<decltype(v)>;
 4352|       |                                          constexpr bool is_object =
 4353|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4354|       |                                          if constexpr (variant_unit_alternative<V>) {
 4355|       |                                             // A unit alternative carries no data; its object holds only the
 4356|       |                                             // discriminator. Consume that body through an empty reflected object so
 4357|       |                                             // unknown-key policy and terminator handling match every other
 4358|       |                                             // alternative.
 4359|       |                                             detail::variant_unit_body unit_body{};
 4360|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4361|       |                                                                                                tag_literal>(
 4362|       |                                                unit_body, ctx, it, end);
 4363|       |                                          }
 4364|       |                                          else if constexpr (is_object) {
 4365|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4366|       |                                                it = start; // tag is a struct field, must re-parse
 4367|       |                                             }
 4368|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4369|       |                                          }
 4370|       |                                          else if constexpr (is_memory_object<V>) {
 4371|       |                                             if (!v) {
 4372|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4373|       |                                                   if constexpr (requires { v.emplace(); }) {
 4374|       |                                                      v.emplace();
 4375|       |                                                   }
 4376|       |                                                   else {
 4377|       |                                                      v = typename V::value_type{};
 4378|       |                                                   }
 4379|       |                                                }
 4380|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4381|       |                                                   v = std::make_unique<typename V::element_type>();
 4382|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4383|       |                                                   v = std::make_shared<typename V::element_type>();
 4384|       |                                                else if constexpr (constructible<V>) {
 4385|       |                                                   v = meta_construct_v<V>();
 4386|       |                                                }
 4387|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4388|       |                                                                   can_allocate_raw_pointer<
 4389|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4390|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4391|       |                                                      return;
 4392|       |                                                   }
 4393|       |                                                }
 4394|       |                                                else {
 4395|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4396|       |                                                   return;
 4397|       |                                                }
 4398|       |                                             }
 4399|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4400|       |                                                it = start; // tag is a struct field, must re-parse
 4401|       |                                             }
 4402|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4403|       |                                                                                                              it, end);
 4404|       |                                          }
 4405|       |                                          else if constexpr (custom_read<V>) {
 4406|       |                                             // Custom handlers parse the remaining body themselves; this only
 4407|       |                                             // works when the tag was the first key (see above). If it came
 4408|       |                                             // later we were reset to the object start, so error rather than
 4409|       |                                             // let the custom handler absorb the tag.
 4410|       |                                             if (it == start) {
 4411|       |                                                ctx.error = error_code::feature_not_supported;
 4412|       |                                                ctx.custom_error_message =
 4413|       |                                                   "the tag must be the first key for a custom variant alternative";
 4414|       |                                                return;
 4415|       |                                             }
 4416|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4417|       |                                          }
 4418|       |                                       },
 4419|       |                                       value);
 4420|       |
 4421|       |                                    return;
 4422|       |                                 }
 4423|       |                                 else {
 4424|       |                                    ctx.error = error_code::no_matching_variant_type;
 4425|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4426|       |                                    return;
 4427|       |                                 }
 4428|       |                              }
 4429|       |                           }
 4430|       |                        }
 4431|       |
 4432|       |                        // Inline decode_hash lookup for variant deduction
 4433|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4434|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4435|       |                        const auto deduction_index =
 4436|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4437|       |                              key.data(), key.data() + key.size(), key.size());
 4438|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4439|       |                           [[likely]] {
 4440|       |                           possible_types &= deduction_bits[deduction_index];
 4441|       |                        }
 4442|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4443|       |                           ctx.error = error_code::unknown_key;
 4444|       |                           return;
 4445|       |                        }
 4446|       |                     }
 4447|       |                     else if constexpr (not tag_v<T>.empty()) {
 4448|       |                        // empty object case for variant, if there are no normal elements
 4449|       |                        if (key == tag_v<T>) {
 4450|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4451|       |                              return;
 4452|       |                           }
 4453|       |
 4454|       |                           std::string_view type_id{};
 4455|       |                           parse<JSON>::op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4456|       |                           if (bool(ctx.error)) [[unlikely]]
 4457|       |                              return;
 4458|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4459|       |                              return;
 4460|       |                           }
 4461|       |
 4462|       |                           const auto type_index = variant_id_to_index<T>::op(
 4463|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4464|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4465|       |                              position_after_tag();
 4466|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4467|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4468|       |                           }
 4469|       |                           else {
 4470|       |                              // Check if we have a default type (ids array shorter than variant)
 4471|       |                              constexpr auto ids_size = ids_v<T>.size();
 4472|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4473|       |                              if constexpr (ids_size < variant_size) {
 4474|       |                                 // Use the first unlabeled type as the default
 4475|       |                                 position_after_tag();
 4476|       |                                 const auto default_index = ids_size;
 4477|       |                                 tag_specified_index = default_index; // Store the default type index
 4478|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4479|       |                              }
 4480|       |                              else {
 4481|       |                                 ctx.error = error_code::no_matching_variant_type;
 4482|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4483|       |                                 return;
 4484|       |                              }
 4485|       |                           }
 4486|       |                           // Parse the type (handles tag skipping and unknown keys)
 4487|       |                           std::visit(
 4488|       |                              [&](auto&& v) {
 4489|       |                                 using V = std::decay_t<decltype(v)>;
 4490|       |                                 if constexpr (custom_read<V>) {
 4491|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4492|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4493|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4494|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4495|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4496|       |                                    // into its value, so error here rather than corrupt the result.
 4497|       |                                    if (it == start) {
 4498|       |                                       ctx.error = error_code::feature_not_supported;
 4499|       |                                       ctx.custom_error_message =
 4500|       |                                          "the tag must be the first key for a custom variant alternative";
 4501|       |                                       return;
 4502|       |                                    }
 4503|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4504|       |                                 }
 4505|       |                                 else {
 4506|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4507|       |                                       it = start; // tag is a struct field, must re-parse
 4508|       |                                    }
 4509|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4510|       |                                 }
 4511|       |                              },
 4512|       |                              value);
 4513|       |                           return;
 4514|       |                        }
 4515|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4516|       |                           ctx.error = error_code::unknown_key;
 4517|       |                           return;
 4518|       |                        }
 4519|       |                        else {
 4520|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4521|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4522|       |                              return;
 4523|       |                           }
 4524|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4525|       |                           if (bool(ctx.error)) [[unlikely]]
 4526|       |                              return;
 4527|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4528|       |                              return;
 4529|       |                           }
 4530|       |                           continue; // Continue loop to find the tag
 4531|       |                        }
 4532|       |                     }
 4533|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4534|       |                        ctx.error = error_code::unknown_key;
 4535|       |                        return;
 4536|       |                     }
 4537|       |
 4538|       |                     auto matching_types = possible_types.popcount();
 4539|       |                     if (matching_types == 0) {
 4540|       |                        ctx.error = error_code::no_matching_variant_type;
 4541|       |                        return;
 4542|       |                     }
 4543|       |                     // Only short-circuit for variants without tags
 4544|       |                     else if constexpr (tag_v<T>.empty()) {
 4545|       |                        if (matching_types == 1) {
 4546|       |                           it = start;
 4547|       |                           const auto type_index = possible_types.countr_zero();
 4548|       |
 4549|       |                           if (value.index() != static_cast<size_t>(type_index))
 4550|       |                              emplace_runtime_variant(value, type_index);
 4551|       |                           std::visit(
 4552|       |                              [&](auto&& v) {
 4553|       |                                 using V = std::decay_t<decltype(v)>;
 4554|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4555|       |                                 if constexpr (variant_unit_alternative<V>) {
 4556|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4557|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4558|       |                                    // terminator handling match every other alternative.
 4559|       |                                    detail::variant_unit_body unit_body{};
 4560|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4561|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4562|       |                                                                                                    end);
 4563|       |                                 }
 4564|       |                                 else if constexpr (is_object) {
 4565|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4566|       |                                 }
 4567|       |                                 else if constexpr (is_memory_object<V>) {
 4568|       |                                    if (!v) {
 4569|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4570|       |                                          if constexpr (requires { v.emplace(); }) {
 4571|       |                                             v.emplace();
 4572|       |                                          }
 4573|       |                                          else {
 4574|       |                                             v = typename V::value_type{};
 4575|       |                                          }
 4576|       |                                       }
 4577|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4578|       |                                          v = std::make_unique<typename V::element_type>();
 4579|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4580|       |                                          v = std::make_shared<typename V::element_type>();
 4581|       |                                       else if constexpr (constructible<V>) {
 4582|       |                                          v = meta_construct_v<V>();
 4583|       |                                       }
 4584|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4585|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4586|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4587|       |                                             return;
 4588|       |                                          }
 4589|       |                                       }
 4590|       |                                       else {
 4591|       |                                          ctx.error = error_code::invalid_nullable_read;
 4592|       |                                          return;
 4593|       |                                          // Cannot read into unset nullable that is not std::optional,
 4594|       |                                          // std::unique_ptr, or std::shared_ptr
 4595|       |                                       }
 4596|       |                                    }
 4597|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4598|       |                                       *v, ctx, it, end);
 4599|       |                                 }
 4600|       |                                 else if constexpr (custom_read<V>) {
 4601|       |                                    // Custom handlers parse the remaining body themselves.
 4602|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4603|       |                                 }
 4604|       |                              },
 4605|       |                              value);
 4606|       |
 4607|       |                           return; // we've decoded our target type
 4608|       |                        }
 4609|       |                     }
 4610|       |                     // For tagged variants, continue processing to validate tags
 4611|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4612|       |                        return;
 4613|       |                     }
 4614|       |
 4615|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4616|       |                     if (bool(ctx.error)) [[unlikely]]
 4617|       |                        return;
 4618|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4619|       |                        return;
 4620|       |                     }
 4621|       |                  }
 4622|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4623|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4624|       |                     // After parsing all keys, check if we have multiple matching types
 4625|       |                     // If so, choose the one with the fewest fields
 4626|       |                     auto final_matching = possible_types.popcount();
 4627|       |                     if (final_matching == 0) {
 4628|       |                        ctx.error = error_code::no_matching_variant_type;
 4629|       |                     }
 4630|       |                     else if (final_matching == 1) {
 4631|       |                        // Single type remains after field deduction
 4632|       |                        const auto type_index = possible_types.countr_zero();
 4633|       |
 4634|       |                        // Validate against tag if one was specified
 4635|       |                        if (tag_specified_index.has_value() &&
 4636|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4637|       |                           ctx.error = error_code::no_matching_variant_type;
 4638|       |                           return;
 4639|       |                        }
 4640|       |
 4641|       |                        it = start;
 4642|       |                        if (value.index() != static_cast<size_t>(type_index))
 4643|       |                           emplace_runtime_variant(value, type_index);
 4644|       |                        std::visit(
 4645|       |                           [&](auto&& v) {
 4646|       |                              using V = std::decay_t<decltype(v)>;
 4647|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4648|       |                              if constexpr (variant_unit_alternative<V>) {
 4649|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4650|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4651|       |                                 // terminator handling match every other alternative.
 4652|       |                                 detail::variant_unit_body unit_body{};
 4653|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4654|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4655|       |                                                                                                 end);
 4656|       |                              }
 4657|       |                              else if constexpr (is_object) {
 4658|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4659|       |                              }
 4660|       |                              else if constexpr (is_memory_object<V>) {
 4661|       |                                 if (!v) {
 4662|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4663|       |                                       if constexpr (requires { v.emplace(); }) {
 4664|       |                                          v.emplace();
 4665|       |                                       }
 4666|       |                                       else {
 4667|       |                                          v = typename V::value_type{};
 4668|       |                                       }
 4669|       |                                    }
 4670|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4671|       |                                       v = std::make_unique<typename V::element_type>();
 4672|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4673|       |                                       v = std::make_shared<typename V::element_type>();
 4674|       |                                    else if constexpr (constructible<V>) {
 4675|       |                                       v = meta_construct_v<V>();
 4676|       |                                    }
 4677|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4678|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4679|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4680|       |                                          return;
 4681|       |                                       }
 4682|       |                                    }
 4683|       |                                    else {
 4684|       |                                       ctx.error = error_code::invalid_nullable_read;
 4685|       |                                       return;
 4686|       |                                    }
 4687|       |                                 }
 4688|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4689|       |                                                                                                               it, end);
 4690|       |                              }
 4691|       |                              else if constexpr (custom_read<V>) {
 4692|       |                                 // Custom handlers parse the remaining body themselves.
 4693|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4694|       |                              }
 4695|       |                           },
 4696|       |                           value);
 4697|       |                     }
 4698|       |                     else if (final_matching > 1) {
 4699|       |                        constexpr auto N = std::variant_size_v<T>;
 4700|       |
 4701|       |                        // Compile-time array of field counts for each variant type
 4702|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4703|       |                           return std::array<size_t, N> {
 4704|       |                              ([]<size_t J = I>() -> size_t {
 4705|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4706|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4707|       |                                    return reflect<V>::size;
 4708|       |                                 }
 4709|       |                                 else if constexpr (is_memory_object<V>) {
 4710|       |                                    using X = memory_type<V>;
 4711|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4712|       |                                       return reflect<X>::size;
 4713|       |                                    }
 4714|       |                                    else {
 4715|       |                                       return (std::numeric_limits<size_t>::max)();
 4716|       |                                    }
 4717|       |                                 }
 4718|       |                                 else {
 4719|       |                                    return (std::numeric_limits<size_t>::max)();
 4720|       |                                 }
 4721|       |                              }.template operator()<I>())...
 4722|       |                           };
 4723|       |                        }(std::make_index_sequence<N>{});
 4724|       |
 4725|       |                        // Find the type with minimum field count among the possible types
 4726|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4727|       |                        size_t chosen_index = N; // Invalid index initially
 4728|       |
 4729|       |                        for (size_t i = 0; i < N; ++i) {
 4730|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4731|       |                              min_fields = field_counts[i];
 4732|       |                              chosen_index = i;
 4733|       |                           }
 4734|       |                        }
 4735|       |
 4736|       |                        if (chosen_index < N) {
 4737|       |                           // Validate against tag if one was specified
 4738|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4739|       |                              ctx.error = error_code::no_matching_variant_type;
 4740|       |                              return;
 4741|       |                           }
 4742|       |
 4743|       |                           it = start;
 4744|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4745|       |                           std::visit(
 4746|       |                              [&](auto&& v) {
 4747|       |                                 using V = std::decay_t<decltype(v)>;
 4748|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4749|       |                                 if constexpr (variant_unit_alternative<V>) {
 4750|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4751|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4752|       |                                    // terminator handling match every other alternative.
 4753|       |                                    detail::variant_unit_body unit_body{};
 4754|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4755|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4756|       |                                                                                                    end);
 4757|       |                                 }
 4758|       |                                 else if constexpr (is_object) {
 4759|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4760|       |                                 }
 4761|       |                                 else if constexpr (is_memory_object<V>) {
 4762|       |                                    if (!v) {
 4763|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4764|       |                                          if constexpr (requires { v.emplace(); }) {
 4765|       |                                             v.emplace();
 4766|       |                                          }
 4767|       |                                          else {
 4768|       |                                             v = typename V::value_type{};
 4769|       |                                          }
 4770|       |                                       }
 4771|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4772|       |                                          v = std::make_unique<typename V::element_type>();
 4773|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4774|       |                                          v = std::make_shared<typename V::element_type>();
 4775|       |                                       else if constexpr (constructible<V>) {
 4776|       |                                          v = meta_construct_v<V>();
 4777|       |                                       }
 4778|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4779|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4780|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4781|       |                                             return;
 4782|       |                                          }
 4783|       |                                       }
 4784|       |                                       else {
 4785|       |                                          ctx.error = error_code::invalid_nullable_read;
 4786|       |                                          return;
 4787|       |                                       }
 4788|       |                                    }
 4789|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4790|       |                                       *v, ctx, it, end);
 4791|       |                                 }
 4792|       |                                 else if constexpr (custom_read<V>) {
 4793|       |                                    // Custom handlers parse the remaining body themselves.
 4794|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4795|       |                                 }
 4796|       |                              },
 4797|       |                              value);
 4798|       |                        }
 4799|       |                        else {
 4800|       |                           ctx.error = error_code::no_matching_variant_type;
 4801|       |                        }
 4802|       |                     }
 4803|       |                  }
 4804|       |                  else {
 4805|       |                     // For variants with 0 or 1 object types, use the original error handling
 4806|       |                     ctx.error = error_code::no_matching_variant_type;
 4807|       |                  }
 4808|       |               }
 4809|      0|               break;
 4810|  23.2k|            }
 4811|   643k|            case '[':
  ------------------
  |  Branch (4811:13): [True: 643k, False: 2.05M]
  ------------------
 4812|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4813|   643k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4814|   643k|               break;
 4815|  5.83k|            case '"': {
  ------------------
  |  Branch (4815:13): [True: 5.83k, False: 2.69M]
  ------------------
 4816|  5.83k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4817|  5.83k|               break;
 4818|  23.2k|            }
 4819|    873|            case 't':
  ------------------
  |  Branch (4819:13): [True: 873, False: 2.70M]
  ------------------
 4820|  1.16k|            case 'f': {
  ------------------
  |  Branch (4820:13): [True: 287, False: 2.70M]
  ------------------
 4821|  1.16k|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4822|  1.16k|               break;
 4823|    873|            }
 4824|    592|            case 'n':
  ------------------
  |  Branch (4824:13): [True: 592, False: 2.70M]
  ------------------
 4825|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4826|       |                  ctx.error = error_code::no_matching_variant_type;
 4827|       |               }
 4828|    592|               else {
 4829|    592|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4830|    592|                  using V = std::variant_alternative_t<first_idx, T>;
 4831|    592|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4831:23): [True: 202, False: 390]
  ------------------
 4832|    592|                  match<"null", Opts>(ctx, it, end);
 4833|    592|               }
 4834|    592|               break;
 4835|  2.02M|            default: {
  ------------------
  |  Branch (4835:13): [True: 2.02M, False: 675k]
  ------------------
 4836|       |               // Not bool, string, object, or array so must be number or null
 4837|  2.02M|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4838|  2.02M|            }
 4839|  2.70M|            }
 4840|       |         }
 4841|       |         else {
 4842|       |            // For non-auto-deducible variants, try each type until one succeeds
 4843|       |            constexpr auto N = std::variant_size_v<T>;
 4844|       |            bool parsed = false;
 4845|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4846|       |
 4847|       |            for_each<N>([&]<size_t I>() {
 4848|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4849|       |
 4850|       |               auto copy_it = it;
 4851|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4852|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4853|       |               const auto copy_depth = ctx.depth;
 4854|       |
 4855|       |               // Try parsing as this type
 4856|       |               if (value.index() != I) {
 4857|       |                  emplace_runtime_variant(value, I);
 4858|       |               }
 4859|       |
 4860|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4861|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4862|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4863|       |               }
 4864|       |
 4865|       |               if (!bool(ctx.error)) {
 4866|       |                  parsed = true;
 4867|       |               }
 4868|       |               else if constexpr (not Options.null_terminated) {
 4869|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4870|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4871|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4872|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4873|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4874|       |                     parsed = true;
 4875|       |                     ctx.error = error_code::none;
 4876|       |                  }
 4877|       |                  else {
 4878|       |                     // Reset for next attempt (unless this is the last type)
 4879|       |                     it = copy_it;
 4880|       |                     rewind_depth<Options>(ctx, copy_depth);
 4881|       |                     if constexpr (I + 1 < N) {
 4882|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4883|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4884|       |                        }
 4885|       |                     }
 4886|       |                  }
 4887|       |               }
 4888|       |               else {
 4889|       |                  // Reset for next attempt (unless this is the last type)
 4890|       |                  it = copy_it;
 4891|       |                  rewind_depth<Options>(ctx, copy_depth);
 4892|       |                  if constexpr (I + 1 < N) {
 4893|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4894|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4895|       |                     }
 4896|       |                  }
 4897|       |               }
 4898|       |            });
 4899|       |         }
 4900|  2.70M|      }
_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_:
 3765|   645k|      {
 3766|   645k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3767|       |
 3768|       |         if constexpr (category_count == 0) {
 3769|       |            ctx.error = error_code::no_matching_variant_type;
 3770|       |         }
 3771|   645k|         else {
 3772|   645k|            constexpr auto N = std::variant_size_v<Variant>;
 3773|   645k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3774|   645k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3775|       |
 3776|   645k|            bool found_match{};
 3777|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3778|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3779|       |            // so the budget stops it and the failure already in hand is reported.
 3780|   645k|            bool exhausted{};
 3781|       |
 3782|       |            // First pass: const glaze types in this category
 3783|       |            if constexpr (const_count > 0) {
 3784|       |               for_each<N>([&]<size_t I>() {
 3785|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3786|       |                     return;
 3787|       |                  }
 3788|       |                  using V = std::variant_alternative_t<I, Variant>;
 3789|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3790|       |                     // run time substitute to compare to const value
 3791|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3792|       |                     auto copy_it{it};
 3793|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3794|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3795|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3796|       |                     const auto copy_depth{ctx.depth};
 3797|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3798|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3799|       |                     if (substitute == const_value) {
 3800|       |                        found_match = true;
 3801|       |                        if (!std::holds_alternative<V>(value)) {
 3802|       |                           value = V{};
 3803|       |                        }
 3804|       |                     }
 3805|       |                     else {
 3806|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3807|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3808|       |                           exhausted = true;
 3809|       |                        }
 3810|       |                        if constexpr (not Options.null_terminated) {
 3811|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3812|       |                              ctx.error = error_code::none;
 3813|       |                           }
 3814|       |                        }
 3815|       |                        it = copy_it;
 3816|       |                        rewind_depth<Options>(ctx, copy_depth);
 3817|       |                     }
 3818|       |                  }
 3819|       |               });
 3820|       |               if (found_match) {
 3821|       |                  return;
 3822|       |               }
 3823|       |            }
 3824|       |
 3825|       |            // Second pass: non-const types in this category
 3826|   645k|            if constexpr (non_const_count > 0) {
 3827|       |               // Track position within matching types for "is last" check.
 3828|       |               // We iterate over all variant indices but only process matching types,
 3829|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3830|       |               // the loop index directly corresponded to position in filtered set).
 3831|       |               // This has negligible cost: one increment per matching type.
 3832|   645k|               size_t non_const_idx = 0;
 3833|       |
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3836|   645k|                     return;
 3837|   645k|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|   645k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|   645k|                     auto copy_it{it};
 3841|   645k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|   645k|                     if (!std::holds_alternative<V>(value)) {
 3843|   645k|                        value = V{};
 3844|   645k|                     }
 3845|   645k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|   645k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|   645k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|   645k|                     }
 3849|   645k|                     if (!bool(ctx.error)) {
 3850|   645k|                        found_match = true;
 3851|   645k|                     }
 3852|   645k|                     else if constexpr (not Options.null_terminated) {
 3853|   645k|                        constexpr bool is_complete_type =
 3854|   645k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|   645k|                        if constexpr (is_complete_type) {
 3857|   645k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|   645k|                              found_match = true;
 3859|   645k|                              ctx.error = error_code::none;
 3860|   645k|                           }
 3861|   645k|                           else {
 3862|   645k|                              it = copy_it;
 3863|   645k|                              rewind_depth<Options>(ctx, copy_depth);
 3864|   645k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|   645k|                                  not variant_alternative_exhausted(ctx)) {
 3866|   645k|                                 ctx.error = error_code::none;
 3867|   645k|                              }
 3868|   645k|                           }
 3869|   645k|                        }
 3870|   645k|                        else {
 3871|   645k|                           it = copy_it;
 3872|   645k|                           rewind_depth<Options>(ctx, copy_depth);
 3873|   645k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|   645k|                               not variant_alternative_exhausted(ctx)) {
 3875|   645k|                              ctx.error = error_code::none;
 3876|   645k|                           }
 3877|   645k|                        }
 3878|   645k|                     }
 3879|   645k|                     else {
 3880|   645k|                        it = copy_it;
 3881|   645k|                        rewind_depth<Options>(ctx, copy_depth);
 3882|   645k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|   645k|                            not variant_alternative_exhausted(ctx)) {
 3884|   645k|                           ctx.error = error_code::none;
 3885|   645k|                        }
 3886|   645k|                     }
 3887|   645k|                     ++non_const_idx;
 3888|   645k|                  }
 3889|   645k|               });
 3890|   645k|               if (!found_match) {
  ------------------
  |  Branch (3890:20): [True: 13.3k, False: 631k]
  ------------------
 3891|  13.3k|                  if constexpr (non_const_count == 1) {
 3892|       |                     // Keep the specific error from the single type we tried
 3893|       |                  }
 3894|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3895|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3896|       |                     ctx.error = error_code::no_matching_variant_type;
 3897|       |                  }
 3898|  13.3k|               }
 3899|       |            }
 3900|       |            else {
 3901|       |               ctx.error = error_code::no_matching_variant_type;
 3902|       |            }
 3903|   645k|         }
 3904|   645k|      }
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|   645k|               });
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|   645k|               });
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|   645k|               });
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|   645k|               });
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|   645k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|   645k|                     auto copy_it{it};
 3841|   645k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|   645k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3842:26): [True: 481k, False: 163k]
  ------------------
 3843|   481k|                        value = V{};
 3844|   481k|                     }
 3845|   645k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|   645k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3846:26): [True: 13.3k, False: 631k]
  |  Branch (3846:45): [True: 0, False: 13.3k]
  ------------------
 3847|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|      0|                     }
 3849|   645k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3849:26): [True: 631k, False: 13.3k]
  ------------------
 3850|   631k|                        found_match = true;
 3851|   631k|                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|  13.3k|                     else {
 3880|  13.3k|                        it = copy_it;
 3881|  13.3k|                        rewind_depth<Options>(ctx, copy_depth);
 3882|  13.3k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3882:29): [True: 0, False: 13.3k]
  |  Branch (3882:68): [True: 0, False: 0]
  ------------------
 3883|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3883:29): [True: 0, False: 0]
  ------------------
 3884|      0|                           ctx.error = error_code::none;
 3885|      0|                        }
 3886|  13.3k|                     }
 3887|   645k|                     ++non_const_idx;
 3888|   645k|                  }
 3889|   645k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS4_9allocatorIS9_EEEETkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
   49|   645k|      {
   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|   645k|         else {
   60|   645k|            using V = std::remove_cvref_t<T>;
   61|   645k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|   645k|                                             end);
   63|   645k|         }
   64|   645k|      }
_ZN3glz4fromILj10ENSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS1_9allocatorIS6_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERS9_TkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
 2349|   645k|      {
 2350|   645k|         constexpr auto Opts = ws_handled_off<Options>();
 2351|       |         if constexpr (!check_ws_handled(Options)) {
 2352|       |            if (skip_ws<Opts>(ctx, it, end)) {
 2353|       |               return;
 2354|       |            }
 2355|       |         }
 2356|       |
 2357|   645k|         if (match_invalid_end<'[', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2357:14): [True: 0, False: 645k]
  ------------------
 2358|      0|            return;
 2359|      0|         }
 2360|       |         // one nesting level (see enter_depth): counted in both modes so the limit binds,
 2361|       |         // released at each syntactic close below
 2362|   645k|         if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (2362:14): [True: 11, False: 645k]
  ------------------
 2363|     11|            return;
 2364|     11|         }
 2365|       |
 2366|   645k|         const auto ws_start = it;
 2367|   645k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2367:14): [True: 0, False: 645k]
  ------------------
 2368|      0|            return;
 2369|      0|         }
 2370|       |
 2371|   645k|         if (*it == ']') {
  ------------------
  |  Branch (2371:14): [True: 4.70k, False: 640k]
  ------------------
 2372|  4.70k|            --ctx.depth;
 2373|  4.70k|            ++it;
 2374|  4.70k|            if constexpr ((resizable<T> || is_inplace_vector<T>) && not check_append_arrays(Opts)) {
 2375|  4.70k|               value.clear();
 2376|       |
 2377|       |               if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2378|       |                  value.shrink_to_fit();
 2379|       |               }
 2380|  4.70k|            }
 2381|  4.70k|            return;
 2382|  4.70k|         }
 2383|       |
 2384|   640k|         const size_t ws_size = size_t(it - ws_start);
 2385|       |
 2386|   640k|         static constexpr bool should_append = (resizable<T> || is_inplace_vector<T>) && check_append_arrays(Opts);
  ------------------
  |  Branch (2386:49): [True: 640k, Folded]
  |  Branch (2386:65): [Folded, False: 0]
  |  Branch (2386:90): [Folded, False: 0]
  ------------------
 2387|   640k|         if constexpr (not should_append) {
 2388|   640k|            const auto n = value.size();
 2389|       |
 2390|   640k|            auto value_it = value.begin();
 2391|       |
 2392|   648k|            for (size_t i = 0; i < n; ++i) {
  ------------------
  |  Branch (2392:32): [True: 168k, False: 480k]
  ------------------
 2393|   168k|               parse<JSON>::op<ws_handled<Opts>()>(*value_it++, ctx, it, end);
 2394|   168k|               if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2394:20): [True: 830, False: 167k]
  ------------------
 2395|    830|                  return;
 2396|   167k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2396:20): [True: 0, False: 167k]
  ------------------
 2397|      0|                  return;
 2398|      0|               }
 2399|   167k|               if (*it == ',') {
  ------------------
  |  Branch (2399:20): [True: 7.93k, False: 159k]
  ------------------
 2400|  7.93k|                  ++it;
 2401|       |
 2402|  7.93k|                  if constexpr (!Opts.minified && !Opts.comments) {
 2403|  7.93k|                     if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2403:26): [True: 5.18k, False: 2.74k]
  |  Branch (2403:37): [True: 4.75k, False: 438]
  ------------------
 2404|  4.75k|                        skip_matching_ws(ws_start, it, ws_size);
 2405|  4.75k|                     }
 2406|  7.93k|                  }
 2407|       |
 2408|  7.93k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2408:23): [True: 0, False: 7.93k]
  ------------------
 2409|      0|                     return;
 2410|      0|                  }
 2411|  7.93k|               }
 2412|   159k|               else if (*it == ']') {
  ------------------
  |  Branch (2412:25): [True: 159k, False: 93]
  ------------------
 2413|   159k|                  --ctx.depth;
 2414|   159k|                  ++it;
 2415|   159k|                  if constexpr (erasable<T>) {
 2416|   159k|                     value.erase(value_it,
 2417|   159k|                                 value.end()); // use erase rather than resize for non-default constructible elements
 2418|       |
 2419|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2420|       |                        value.shrink_to_fit();
 2421|       |                     }
 2422|   159k|                  }
 2423|   159k|                  return;
 2424|   159k|               }
 2425|     93|               else [[unlikely]] {
 2426|     93|                  ctx.error = error_code::expected_bracket;
 2427|     93|                  return;
 2428|     93|               }
 2429|   167k|            }
 2430|   640k|         }
 2431|       |
 2432|       |         if constexpr (Opts.partial_read) {
 2433|       |            // partial_read stops early on a success path, so give the level back like the
 2434|       |            // syntactic-close paths do; otherwise it accumulates across reads sharing a context.
 2435|       |            --ctx.depth;
 2436|       |            return;
 2437|       |         }
 2438|   640k|         else {
 2439|       |            // growing
 2440|   640k|            if constexpr (emplace_backable<T> || has_try_emplace_back<T>) {
 2441|  1.75M|               while (it < end) {
  ------------------
  |  Branch (2441:23): [True: 1.59M, False: 160k]
  ------------------
 2442|       |                  // Streaming refill point: at start of each iteration, ensure buffer has data
 2443|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2444|       |                     if (ctx.stream.enabled()) {
 2445|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2446|       |                        const size_t remaining = ctx.stream.size() - consumed;
 2447|       |                        // Refill when less than half of buffer remains to ensure space for next element
 2448|       |                        if (remaining <= ctx.stream.size() / 2 || it >= end) {
 2449|       |                           const char* new_it;
 2450|       |                           const char* new_end;
 2451|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2452|       |                           it = new_it;
 2453|       |                           end = new_end;
 2454|       |                           if (it >= end && ctx.stream.at_eof()) {
 2455|       |                              break; // No more data, exit loop normally
 2456|       |                           }
 2457|       |                        }
 2458|       |                     }
 2459|       |                  }
 2460|       |
 2461|       |                  if constexpr (has_try_emplace_back<T>) {
 2462|       |                     if (value.try_emplace_back())
 2463|       |                        parse<JSON>::op<ws_handled<Opts>()>(value.back(), ctx, it, end);
 2464|       |                     else
 2465|       |                        ctx.error = error_code::exceeded_static_array_size;
 2466|       |                  }
 2467|  1.59M|                  else {
 2468|  1.59M|                     parse<JSON>::op<ws_handled<Opts>()>(value.emplace_back(), ctx, it, end);
 2469|  1.59M|                  }
 2470|       |
 2471|  1.59M|                  if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2471:23): [True: 11.4k, False: 1.58M]
  ------------------
 2472|  11.4k|                     return;
 2473|       |
 2474|       |                  // Streaming refill point: after parsing each element, refill if buffer is low
 2475|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2476|       |                     if (ctx.stream.enabled()) {
 2477|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2478|       |                        // Refill when less than 25% of buffer remains to ensure enough space for next element
 2479|       |                        if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 2480|       |                           const char* new_it;
 2481|       |                           const char* new_end;
 2482|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2483|       |                           it = new_it;
 2484|       |                           end = new_end;
 2485|       |                           if (it >= end && ctx.stream.at_eof()) {
 2486|       |                              ctx.error = error_code::unexpected_end;
 2487|       |                              return;
 2488|       |                           }
 2489|       |                        }
 2490|       |                     }
 2491|       |                  }
 2492|       |
 2493|  1.58M|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2493:23): [True: 0, False: 1.58M]
  ------------------
 2494|      0|                     return;
 2495|      0|                  }
 2496|  1.58M|                  if (*it == ',') [[likely]] {
  ------------------
  |  Branch (2496:23): [True: 1.11M, False: 468k]
  ------------------
 2497|  1.11M|                     ++it;
 2498|       |
 2499|  1.11M|                     if constexpr (!Opts.minified && !Opts.comments) {
 2500|  1.11M|                        if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2500:29): [True: 27.4k, False: 1.09M]
  |  Branch (2500:40): [True: 26.9k, False: 519]
  ------------------
 2501|  26.9k|                           skip_matching_ws(ws_start, it, ws_size);
 2502|  26.9k|                        }
 2503|  1.11M|                     }
 2504|       |
 2505|  1.11M|                     if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2505:26): [True: 0, False: 1.11M]
  ------------------
 2506|      0|                        return;
 2507|      0|                     }
 2508|  1.11M|                  }
 2509|   468k|                  else if (*it == ']') {
  ------------------
  |  Branch (2509:28): [True: 467k, False: 1.01k]
  ------------------
 2510|   467k|                     --ctx.depth;
 2511|   467k|                     ++it;
 2512|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2513|       |                        value.shrink_to_fit();
 2514|       |                     }
 2515|   467k|                     return;
 2516|   467k|                  }
 2517|  1.01k|                  else [[unlikely]] {
 2518|  1.01k|                     ctx.error = error_code::expected_bracket;
 2519|  1.01k|                     return;
 2520|  1.01k|                  }
 2521|  1.58M|               }
 2522|       |
 2523|       |               // A valid array always returns from inside the loop upon reaching ']'.
 2524|       |               // For a null-terminated buffer the loop can only exit here by falling
 2525|       |               // through when `it` reaches the terminator without a closing bracket,
 2526|       |               // which means the input was truncated (e.g. "[", "[1," or "[1,2,").
 2527|       |               // Non-null-terminated buffers surface this through skip_ws/depth
 2528|       |               // tracking (or the streaming refill break), so this guard is limited
 2529|       |               // to the null-terminated case.
 2530|   160k|               if constexpr (Opts.null_terminated) {
 2531|   160k|                  ctx.error = error_code::unexpected_end;
 2532|   160k|               }
 2533|       |            }
 2534|       |            else {
 2535|       |               ctx.error = error_code::exceeded_static_array_size;
 2536|       |            }
 2537|   640k|         }
 2538|   640k|      }
_ZN3glz12rewind_depthITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10is_contextENS_7contextEEEvRT0_j:
 3737|  15.8k|   {
 3738|  15.8k|      if (ctx.error == error_code::exceeded_max_recursive_depth) [[unlikely]] {
  ------------------
  |  Branch (3738:11): [True: 1.36k, False: 14.4k]
  ------------------
 3739|  1.36k|         return;
 3740|  1.36k|      }
 3741|  14.4k|      if constexpr (Opts.null_terminated) {
 3742|  14.4k|         ctx.depth = depth;
 3743|       |      }
 3744|       |      else {
 3745|       |         if (ctx.error != error_code::end_reached && ctx.error != error_code::unexpected_end) {
 3746|       |            ctx.depth = depth;
 3747|       |         }
 3748|       |      }
 3749|  14.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_4optsELj10ELb1ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 631k, False: 13.3k]
  |  Branch (3835:38): [True: 0, False: 13.3k]
  |  Branch (3835:51): [True: 1.36k, False: 12.0k]
  ------------------
 3836|   632k|                     return;
 3837|   632k|                  }
 3838|  12.0k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  12.0k|               });
_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_:
 3765|  6.89k|      {
 3766|  6.89k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3767|       |
 3768|       |         if constexpr (category_count == 0) {
 3769|       |            ctx.error = error_code::no_matching_variant_type;
 3770|       |         }
 3771|  6.89k|         else {
 3772|  6.89k|            constexpr auto N = std::variant_size_v<Variant>;
 3773|  6.89k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3774|  6.89k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3775|       |
 3776|  6.89k|            bool found_match{};
 3777|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3778|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3779|       |            // so the budget stops it and the failure already in hand is reported.
 3780|  6.89k|            bool exhausted{};
 3781|       |
 3782|       |            // First pass: const glaze types in this category
 3783|       |            if constexpr (const_count > 0) {
 3784|       |               for_each<N>([&]<size_t I>() {
 3785|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3786|       |                     return;
 3787|       |                  }
 3788|       |                  using V = std::variant_alternative_t<I, Variant>;
 3789|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3790|       |                     // run time substitute to compare to const value
 3791|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3792|       |                     auto copy_it{it};
 3793|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3794|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3795|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3796|       |                     const auto copy_depth{ctx.depth};
 3797|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3798|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3799|       |                     if (substitute == const_value) {
 3800|       |                        found_match = true;
 3801|       |                        if (!std::holds_alternative<V>(value)) {
 3802|       |                           value = V{};
 3803|       |                        }
 3804|       |                     }
 3805|       |                     else {
 3806|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3807|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3808|       |                           exhausted = true;
 3809|       |                        }
 3810|       |                        if constexpr (not Options.null_terminated) {
 3811|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3812|       |                              ctx.error = error_code::none;
 3813|       |                           }
 3814|       |                        }
 3815|       |                        it = copy_it;
 3816|       |                        rewind_depth<Options>(ctx, copy_depth);
 3817|       |                     }
 3818|       |                  }
 3819|       |               });
 3820|       |               if (found_match) {
 3821|       |                  return;
 3822|       |               }
 3823|       |            }
 3824|       |
 3825|       |            // Second pass: non-const types in this category
 3826|  6.89k|            if constexpr (non_const_count > 0) {
 3827|       |               // Track position within matching types for "is last" check.
 3828|       |               // We iterate over all variant indices but only process matching types,
 3829|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3830|       |               // the loop index directly corresponded to position in filtered set).
 3831|       |               // This has negligible cost: one increment per matching type.
 3832|  6.89k|               size_t non_const_idx = 0;
 3833|       |
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3836|  6.89k|                     return;
 3837|  6.89k|                  }
 3838|  6.89k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  6.89k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  6.89k|                     auto copy_it{it};
 3841|  6.89k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  6.89k|                     if (!std::holds_alternative<V>(value)) {
 3843|  6.89k|                        value = V{};
 3844|  6.89k|                     }
 3845|  6.89k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  6.89k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|  6.89k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|  6.89k|                     }
 3849|  6.89k|                     if (!bool(ctx.error)) {
 3850|  6.89k|                        found_match = true;
 3851|  6.89k|                     }
 3852|  6.89k|                     else if constexpr (not Options.null_terminated) {
 3853|  6.89k|                        constexpr bool is_complete_type =
 3854|  6.89k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|  6.89k|                        if constexpr (is_complete_type) {
 3857|  6.89k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|  6.89k|                              found_match = true;
 3859|  6.89k|                              ctx.error = error_code::none;
 3860|  6.89k|                           }
 3861|  6.89k|                           else {
 3862|  6.89k|                              it = copy_it;
 3863|  6.89k|                              rewind_depth<Options>(ctx, copy_depth);
 3864|  6.89k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|  6.89k|                                  not variant_alternative_exhausted(ctx)) {
 3866|  6.89k|                                 ctx.error = error_code::none;
 3867|  6.89k|                              }
 3868|  6.89k|                           }
 3869|  6.89k|                        }
 3870|  6.89k|                        else {
 3871|  6.89k|                           it = copy_it;
 3872|  6.89k|                           rewind_depth<Options>(ctx, copy_depth);
 3873|  6.89k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|  6.89k|                               not variant_alternative_exhausted(ctx)) {
 3875|  6.89k|                              ctx.error = error_code::none;
 3876|  6.89k|                           }
 3877|  6.89k|                        }
 3878|  6.89k|                     }
 3879|  6.89k|                     else {
 3880|  6.89k|                        it = copy_it;
 3881|  6.89k|                        rewind_depth<Options>(ctx, copy_depth);
 3882|  6.89k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|  6.89k|                            not variant_alternative_exhausted(ctx)) {
 3884|  6.89k|                           ctx.error = error_code::none;
 3885|  6.89k|                        }
 3886|  6.89k|                     }
 3887|  6.89k|                     ++non_const_idx;
 3888|  6.89k|                  }
 3889|  6.89k|               });
 3890|  6.89k|               if (!found_match) {
  ------------------
  |  Branch (3890:20): [True: 824, False: 6.07k]
  ------------------
 3891|    824|                  if constexpr (non_const_count == 1) {
 3892|       |                     // Keep the specific error from the single type we tried
 3893|       |                  }
 3894|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3895|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3896|       |                     ctx.error = error_code::no_matching_variant_type;
 3897|       |                  }
 3898|    824|               }
 3899|       |            }
 3900|       |            else {
 3901|       |               ctx.error = error_code::no_matching_variant_type;
 3902|       |            }
 3903|  6.89k|         }
 3904|  6.89k|      }
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 6.89k]
  |  Branch (3835:38): [True: 0, False: 6.89k]
  |  Branch (3835:51): [True: 0, False: 6.89k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  6.89k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  6.89k|               });
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 6.89k]
  |  Branch (3835:38): [True: 0, False: 6.89k]
  |  Branch (3835:51): [True: 0, False: 6.89k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  6.89k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  6.89k|               });
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 6.89k]
  |  Branch (3835:38): [True: 0, False: 6.89k]
  |  Branch (3835:51): [True: 0, False: 6.89k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  6.89k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  6.89k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  6.89k|                     auto copy_it{it};
 3841|  6.89k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  6.89k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3842:26): [True: 5.49k, False: 1.40k]
  ------------------
 3843|  5.49k|                        value = V{};
 3844|  5.49k|                     }
 3845|  6.89k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  6.89k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3846:26): [True: 824, False: 6.07k]
  |  Branch (3846:45): [True: 0, False: 824]
  ------------------
 3847|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|      0|                     }
 3849|  6.89k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3849:26): [True: 6.07k, False: 824]
  ------------------
 3850|  6.07k|                        found_match = true;
 3851|  6.07k|                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|    824|                     else {
 3880|    824|                        it = copy_it;
 3881|    824|                        rewind_depth<Options>(ctx, copy_depth);
 3882|    824|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3882:29): [True: 0, False: 824]
  |  Branch (3882:68): [True: 0, False: 0]
  ------------------
 3883|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3883:29): [True: 0, False: 0]
  ------------------
 3884|      0|                           ctx.error = error_code::none;
 3885|      0|                        }
 3886|    824|                     }
 3887|  6.89k|                     ++non_const_idx;
 3888|  6.89k|                  }
 3889|  6.89k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|  6.89k|      {
   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.89k|         else {
   60|  6.89k|            using V = std::remove_cvref_t<T>;
   61|  6.89k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  6.89k|                                             end);
   63|  6.89k|         }
   64|  6.89k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEQntcl15check_is_paddedTL0__EEEvRT2_OT3_OT0_T1_:
 1084|  6.89k|      {
 1085|       |         if constexpr (check_string_as_number(Opts)) {
 1086|       |            auto start = it;
 1087|       |            skip_number<Opts>(ctx, it, end);
 1088|       |            if (bool(ctx.error)) [[unlikely]] {
 1089|       |               return;
 1090|       |            }
 1091|       |            if (start == it) [[unlikely]] {
 1092|       |               ctx.error = error_code::parse_number_failure;
 1093|       |               return;
 1094|       |            }
 1095|       |            value.append(start, size_t(it - start));
 1096|       |         }
 1097|  6.89k|         else {
 1098|  6.89k|            if constexpr (!check_opening_handled(Opts)) {
 1099|       |               if constexpr (!check_ws_handled(Opts)) {
 1100|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 1101|       |                     return;
 1102|       |                  }
 1103|       |               }
 1104|       |
 1105|  6.89k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (1105:20): [True: 0, False: 6.89k]
  ------------------
 1106|      0|                  return;
 1107|      0|               }
 1108|  6.89k|            }
 1109|       |
 1110|  6.89k|            if constexpr (not check_raw_string(Opts)) {
 1111|  6.89k|               static constexpr auto string_padding_bytes = 8;
 1112|       |
 1113|  6.89k|               if (size_t(end - it) >= 8) {
  ------------------
  |  Branch (1113:20): [True: 6.47k, False: 426]
  ------------------
 1114|  6.47k|                  auto start = it;
 1115|  6.47k|                  uint64_t ascii_acc{};
 1116|  6.47k|                  const auto end8 = end - 8;
 1117|  1.61M|                  while (true) {
  ------------------
  |  Branch (1117:26): [True: 1.61M, Folded]
  ------------------
 1118|  1.61M|                     if (it >= end8) [[unlikely]] {
  ------------------
  |  Branch (1118:26): [True: 489, False: 1.61M]
  ------------------
 1119|    489|                        break;
 1120|    489|                     }
 1121|       |
 1122|  1.61M|                     uint64_t chunk;
 1123|  1.61M|                     std::memcpy(&chunk, it, 8);
 1124|       |                     if constexpr (std::endian::native == std::endian::big) {
 1125|       |                        chunk = std::byteswap(chunk);
 1126|       |                     }
 1127|  1.61M|                     ascii_acc |= chunk;
 1128|  1.61M|                     const uint64_t test_chars = has_quote(chunk);
 1129|  1.61M|                     if (test_chars) {
  ------------------
  |  Branch (1129:26): [True: 7.97k, False: 1.60M]
  ------------------
 1130|  7.97k|                        it += (countr_zero(test_chars) >> 3);
 1131|       |
 1132|  7.97k|                        auto* prev = it - 1;
 1133|  10.4k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1133:32): [True: 2.52k, False: 7.97k]
  ------------------
 1134|  2.52k|                           --prev;
 1135|  2.52k|                        }
 1136|  7.97k|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1136:29): [True: 5.98k, False: 1.99k]
  ------------------
 1137|  5.98k|                           goto continue_decode;
 1138|  5.98k|                        }
 1139|  1.99k|                        ++it; // skip the escaped quote
 1140|  1.99k|                     }
 1141|  1.60M|                     else {
 1142|  1.60M|                        it += 8;
 1143|  1.60M|                     }
 1144|  1.61M|                  }
 1145|       |
 1146|  2.19k|                  while (it[-1] == '\\') [[unlikely]] {
  ------------------
  |  Branch (1146:26): [True: 1.70k, False: 489]
  ------------------
 1147|       |                     // if we ended on an escape character then we need to rewind
 1148|       |                     // because we lost our context
 1149|  1.70k|                     --it;
 1150|  1.70k|                  }
 1151|       |
 1152|       |                  // The byte-wise tail keeps feeding the accumulator: it has to cover every byte of
 1153|       |                  // the string, or a non-ASCII byte reached here would be waved through unvalidated.
 1154|  3.88k|                  for (; it < end; ++it) {
  ------------------
  |  Branch (1154:26): [True: 3.77k, False: 111]
  ------------------
 1155|  3.77k|                     ascii_acc |= uint8_t(*it);
 1156|  3.77k|                     if (*it == '"') {
  ------------------
  |  Branch (1156:26): [True: 448, False: 3.33k]
  ------------------
 1157|    448|                        auto* prev = it - 1;
 1158|  1.50k|                        while (*prev == '\\') {
  ------------------
  |  Branch (1158:32): [True: 1.05k, False: 448]
  ------------------
 1159|  1.05k|                           --prev;
 1160|  1.05k|                        }
 1161|    448|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (1161:29): [True: 378, False: 70]
  ------------------
 1162|    378|                           goto continue_decode;
 1163|    378|                        }
 1164|    448|                     }
 1165|  3.77k|                  }
 1166|       |
 1167|    111|                  ctx.error = error_code::unexpected_end;
 1168|    111|                  return;
 1169|       |
 1170|  6.36k|               continue_decode:
 1171|       |
 1172|  6.36k|                  if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (1172:23): [True: 178, False: 6.18k]
  ------------------
 1173|    178|                     return;
 1174|    178|                  }
 1175|       |
 1176|  6.18k|                  const auto available_padding = size_t(end - it);
 1177|  6.18k|                  auto n = size_t(it - start);
 1178|  6.18k|                  if (available_padding >= 8) [[likely]] {
  ------------------
  |  Branch (1178:23): [True: 5.83k, False: 353]
  ------------------
 1179|  5.83k|                     value.resize(n + string_padding_bytes);
 1180|       |
 1181|  5.83k|                     auto* p = value.data();
 1182|       |
 1183|  27.4k|                     while (true) {
  ------------------
  |  Branch (1183:29): [True: 27.4k, Folded]
  ------------------
 1184|  27.4k|                        if (start >= it) {
  ------------------
  |  Branch (1184:29): [True: 5.33k, False: 22.0k]
  ------------------
 1185|  5.33k|                           break;
 1186|  5.33k|                        }
 1187|       |
 1188|  22.0k|                        std::memcpy(p, start, 8);
 1189|  22.0k|                        uint64_t swar;
 1190|  22.0k|                        std::memcpy(&swar, p, 8);
 1191|       |                        if constexpr (std::endian::native == std::endian::big) {
 1192|       |                           swar = std::byteswap(swar);
 1193|       |                        }
 1194|       |
 1195|  22.0k|                        constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1196|  22.0k|                        const uint64_t lo7 = swar & lo7_mask;
 1197|  22.0k|                        const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1198|  22.0k|                        const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1199|  22.0k|                        uint64_t next = ~((backslash & less_32) | swar);
 1200|       |
 1201|  22.0k|                        next &= repeat_byte8(0b10000000);
 1202|  22.0k|                        if (next == 0) {
  ------------------
  |  Branch (1202:29): [True: 19.6k, False: 2.44k]
  ------------------
 1203|  19.6k|                           start += 8;
 1204|  19.6k|                           p += 8;
 1205|  19.6k|                           continue;
 1206|  19.6k|                        }
 1207|       |
 1208|  2.44k|                        next = countr_zero(next) >> 3;
 1209|  2.44k|                        start += next;
 1210|  2.44k|                        if (start >= it) {
  ------------------
  |  Branch (1210:29): [True: 376, False: 2.06k]
  ------------------
 1211|    376|                           break;
 1212|    376|                        }
 1213|       |
 1214|  2.06k|                        if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1214:29): [True: 40, False: 2.02k]
  ------------------
 1215|     40|                           ctx.error = error_code::syntax_error;
 1216|     40|                           return;
 1217|     40|                        }
 1218|  2.02k|                        ++start; // skip the escape
 1219|  2.02k|                        if (*start == 'u') {
  ------------------
  |  Branch (1219:29): [True: 1.35k, False: 678]
  ------------------
 1220|  1.35k|                           ++start;
 1221|  1.35k|                           p += next;
 1222|  1.35k|                           const auto mark = start;
 1223|  1.35k|                           const auto offset = handle_unicode_code_point(start, p, end);
 1224|  1.35k|                           if (offset == 0) [[unlikely]] {
  ------------------
  |  Branch (1224:32): [True: 74, False: 1.27k]
  ------------------
 1225|     74|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1226|     74|                              return;
 1227|     74|                           }
 1228|  1.27k|                           n += offset;
 1229|       |                           // escape + u + unicode code points
 1230|  1.27k|                           n -= 2 + uint32_t(start - mark);
 1231|  1.27k|                        }
 1232|    678|                        else {
 1233|    678|                           p += next;
 1234|    678|                           *p = char_unescape_table[uint8_t(*start)];
 1235|    678|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1235:32): [True: 10, False: 668]
  ------------------
 1236|     10|                              ctx.error = error_code::invalid_escape;
 1237|     10|                              return;
 1238|     10|                           }
 1239|    668|                           ++p;
 1240|    668|                           ++start;
 1241|    668|                           --n;
 1242|    668|                        }
 1243|  2.02k|                     }
 1244|       |
 1245|  5.70k|                     value.resize(n);
 1246|  5.70k|                     ++it;
 1247|  5.70k|                  }
 1248|    353|                  else {
 1249|       |                     // For large inputs this case of running out of buffer is very rare
 1250|    353|                     value.resize(n);
 1251|    353|                     auto* p = value.data();
 1252|       |
 1253|    353|                     it = start;
 1254|   833k|                     while (it < end) [[likely]] {
  ------------------
  |  Branch (1254:29): [True: 833k, False: 0]
  ------------------
 1255|   833k|                        if (*it == '"') {
  ------------------
  |  Branch (1255:29): [True: 200, False: 833k]
  ------------------
 1256|    200|                           value.resize(size_t(p - value.data()));
 1257|    200|                           ++it;
 1258|    200|                           return;
 1259|    200|                        }
 1260|       |
 1261|   833k|                        if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1261:29): [True: 48, False: 833k]
  ------------------
 1262|     48|                           ctx.error = error_code::syntax_error;
 1263|     48|                           return;
 1264|     48|                        }
 1265|       |
 1266|   833k|                        *p = *it;
 1267|       |
 1268|   833k|                        if (*it == '\\') {
  ------------------
  |  Branch (1268:29): [True: 1.81k, False: 831k]
  ------------------
 1269|  1.81k|                           ++it; // skip the escape
 1270|  1.81k|                           if (*it == 'u') {
  ------------------
  |  Branch (1270:32): [True: 1.06k, False: 750]
  ------------------
 1271|  1.06k|                              ++it;
 1272|  1.06k|                              if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1272:35): [True: 84, False: 978]
  ------------------
 1273|     84|                                 ctx.error = error_code::unicode_escape_conversion_failure;
 1274|     84|                                 return;
 1275|     84|                              }
 1276|  1.06k|                           }
 1277|    750|                           else {
 1278|    750|                              *p = char_unescape_table[uint8_t(*it)];
 1279|    750|                              if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1279:35): [True: 21, False: 729]
  ------------------
 1280|     21|                                 ctx.error = error_code::invalid_escape;
 1281|     21|                                 return;
 1282|     21|                              }
 1283|    729|                              ++p;
 1284|    729|                              ++it;
 1285|    729|                           }
 1286|  1.81k|                        }
 1287|   831k|                        else {
 1288|   831k|                           ++it;
 1289|   831k|                           ++p;
 1290|   831k|                        }
 1291|   833k|                     }
 1292|       |
 1293|      0|                     ctx.error = error_code::unexpected_end;
 1294|      0|                  }
 1295|  6.18k|               }
 1296|    426|               else {
 1297|       |                  // For short strings
 1298|       |
 1299|    426|                  std::array<char, 8> buffer{};
 1300|       |
 1301|    426|                  auto* p = buffer.data();
 1302|    426|                  const auto* const utf8_start = it;
 1303|       |
 1304|    940|                  while (it < end) [[likely]] {
  ------------------
  |  Branch (1304:26): [True: 940, False: 0]
  ------------------
 1305|    940|                     *p = *it;
 1306|    940|                     if (*it == '"') {
  ------------------
  |  Branch (1306:26): [True: 235, False: 705]
  ------------------
 1307|    235|                        if (validate_utf8_span<Opts>(ctx, utf8_start, it)) [[unlikely]] {
  ------------------
  |  Branch (1307:29): [True: 67, False: 168]
  ------------------
 1308|     67|                           return;
 1309|     67|                        }
 1310|    168|                        const size_t n = size_t(p - buffer.data());
 1311|    168|#if __has_cpp_attribute(assume) >= 202207L
 1312|    168|                        [[assume(n <= sizeof(buffer))]];
 1313|    168|#endif
 1314|    168|                        value.assign(buffer.data(), n);
 1315|    168|                        ++it;
 1316|       |                        if constexpr (not Opts.null_terminated) {
 1317|       |                           if (it == end) {
 1318|       |                              ctx.error = error_code::end_reached;
 1319|       |                              return;
 1320|       |                           }
 1321|       |                        }
 1322|    168|                        return;
 1323|    235|                     }
 1324|    705|                     else if (*it == '\\') {
  ------------------
  |  Branch (1324:31): [True: 99, False: 606]
  ------------------
 1325|     99|                        ++it; // skip the escape
 1326|       |                        if constexpr (not Opts.null_terminated) {
 1327|       |                           if (it == end) [[unlikely]] {
 1328|       |                              ctx.error = error_code::unexpected_end;
 1329|       |                              return;
 1330|       |                           }
 1331|       |                        }
 1332|     99|                        if (*it == 'u') {
  ------------------
  |  Branch (1332:29): [True: 54, False: 45]
  ------------------
 1333|     54|                           ++it;
 1334|       |                           if constexpr (not Opts.null_terminated) {
 1335|       |                              if (it == end) [[unlikely]] {
 1336|       |                                 ctx.error = error_code::unexpected_end;
 1337|       |                                 return;
 1338|       |                              }
 1339|       |                           }
 1340|     54|                           if (!handle_unicode_code_point(it, p, end)) [[unlikely]] {
  ------------------
  |  Branch (1340:32): [True: 13, False: 41]
  ------------------
 1341|     13|                              ctx.error = error_code::unicode_escape_conversion_failure;
 1342|     13|                              return;
 1343|     13|                           }
 1344|     54|                        }
 1345|     45|                        else {
 1346|     45|                           *p = char_unescape_table[uint8_t(*it)];
 1347|     45|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1347:32): [True: 12, False: 33]
  ------------------
 1348|     12|                              ctx.error = error_code::invalid_escape;
 1349|     12|                              return;
 1350|     12|                           }
 1351|     33|                           ++p;
 1352|     33|                           ++it;
 1353|     33|                        }
 1354|     99|                     }
 1355|    606|                     else if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1355:31): [True: 166, False: 440]
  ------------------
 1356|    166|                        ctx.error = error_code::syntax_error;
 1357|    166|                        return;
 1358|    166|                     }
 1359|    440|                     else {
 1360|    440|                        ++it;
 1361|    440|                        ++p;
 1362|    440|                     }
 1363|    940|                  }
 1364|       |
 1365|      0|                  ctx.error = error_code::unexpected_end;
 1366|      0|               }
 1367|       |            }
 1368|       |            else {
 1369|       |               // raw_string
 1370|       |               auto start = it;
 1371|       |               skip_string_view(ctx, it, end);
 1372|       |               if (bool(ctx.error)) [[unlikely]]
 1373|       |                  return;
 1374|       |
 1375|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1376|       |                  return;
 1377|       |               }
 1378|       |
 1379|       |               value.assign(start, size_t(it - start));
 1380|       |               ++it;
 1381|       |            }
 1382|  6.89k|         }
 1383|  6.89k|      }
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 6.07k, False: 824]
  |  Branch (3835:38): [True: 0, False: 824]
  |  Branch (3835:51): [True: 0, False: 824]
  ------------------
 3836|  6.07k|                     return;
 3837|  6.07k|                  }
 3838|    824|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    824|               });
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 6.07k, False: 824]
  |  Branch (3835:38): [True: 0, False: 824]
  |  Branch (3835:51): [True: 0, False: 824]
  ------------------
 3836|  6.07k|                     return;
 3837|  6.07k|                  }
 3838|    824|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    824|               });
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 6.07k, False: 824]
  |  Branch (3835:38): [True: 0, False: 824]
  |  Branch (3835:51): [True: 0, False: 824]
  ------------------
 3836|  6.07k|                     return;
 3837|  6.07k|                  }
 3838|    824|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    824|               });
_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_:
 3765|  1.34k|      {
 3766|  1.34k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3767|       |
 3768|       |         if constexpr (category_count == 0) {
 3769|       |            ctx.error = error_code::no_matching_variant_type;
 3770|       |         }
 3771|  1.34k|         else {
 3772|  1.34k|            constexpr auto N = std::variant_size_v<Variant>;
 3773|  1.34k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3774|  1.34k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3775|       |
 3776|  1.34k|            bool found_match{};
 3777|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3778|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3779|       |            // so the budget stops it and the failure already in hand is reported.
 3780|  1.34k|            bool exhausted{};
 3781|       |
 3782|       |            // First pass: const glaze types in this category
 3783|       |            if constexpr (const_count > 0) {
 3784|       |               for_each<N>([&]<size_t I>() {
 3785|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3786|       |                     return;
 3787|       |                  }
 3788|       |                  using V = std::variant_alternative_t<I, Variant>;
 3789|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3790|       |                     // run time substitute to compare to const value
 3791|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3792|       |                     auto copy_it{it};
 3793|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3794|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3795|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3796|       |                     const auto copy_depth{ctx.depth};
 3797|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3798|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3799|       |                     if (substitute == const_value) {
 3800|       |                        found_match = true;
 3801|       |                        if (!std::holds_alternative<V>(value)) {
 3802|       |                           value = V{};
 3803|       |                        }
 3804|       |                     }
 3805|       |                     else {
 3806|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3807|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3808|       |                           exhausted = true;
 3809|       |                        }
 3810|       |                        if constexpr (not Options.null_terminated) {
 3811|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3812|       |                              ctx.error = error_code::none;
 3813|       |                           }
 3814|       |                        }
 3815|       |                        it = copy_it;
 3816|       |                        rewind_depth<Options>(ctx, copy_depth);
 3817|       |                     }
 3818|       |                  }
 3819|       |               });
 3820|       |               if (found_match) {
 3821|       |                  return;
 3822|       |               }
 3823|       |            }
 3824|       |
 3825|       |            // Second pass: non-const types in this category
 3826|  1.34k|            if constexpr (non_const_count > 0) {
 3827|       |               // Track position within matching types for "is last" check.
 3828|       |               // We iterate over all variant indices but only process matching types,
 3829|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3830|       |               // the loop index directly corresponded to position in filtered set).
 3831|       |               // This has negligible cost: one increment per matching type.
 3832|  1.34k|               size_t non_const_idx = 0;
 3833|       |
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3836|  1.34k|                     return;
 3837|  1.34k|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  1.34k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  1.34k|                     auto copy_it{it};
 3841|  1.34k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  1.34k|                     if (!std::holds_alternative<V>(value)) {
 3843|  1.34k|                        value = V{};
 3844|  1.34k|                     }
 3845|  1.34k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  1.34k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|  1.34k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|  1.34k|                     }
 3849|  1.34k|                     if (!bool(ctx.error)) {
 3850|  1.34k|                        found_match = true;
 3851|  1.34k|                     }
 3852|  1.34k|                     else if constexpr (not Options.null_terminated) {
 3853|  1.34k|                        constexpr bool is_complete_type =
 3854|  1.34k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|  1.34k|                        if constexpr (is_complete_type) {
 3857|  1.34k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|  1.34k|                              found_match = true;
 3859|  1.34k|                              ctx.error = error_code::none;
 3860|  1.34k|                           }
 3861|  1.34k|                           else {
 3862|  1.34k|                              it = copy_it;
 3863|  1.34k|                              rewind_depth<Options>(ctx, copy_depth);
 3864|  1.34k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|  1.34k|                                  not variant_alternative_exhausted(ctx)) {
 3866|  1.34k|                                 ctx.error = error_code::none;
 3867|  1.34k|                              }
 3868|  1.34k|                           }
 3869|  1.34k|                        }
 3870|  1.34k|                        else {
 3871|  1.34k|                           it = copy_it;
 3872|  1.34k|                           rewind_depth<Options>(ctx, copy_depth);
 3873|  1.34k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|  1.34k|                               not variant_alternative_exhausted(ctx)) {
 3875|  1.34k|                              ctx.error = error_code::none;
 3876|  1.34k|                           }
 3877|  1.34k|                        }
 3878|  1.34k|                     }
 3879|  1.34k|                     else {
 3880|  1.34k|                        it = copy_it;
 3881|  1.34k|                        rewind_depth<Options>(ctx, copy_depth);
 3882|  1.34k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|  1.34k|                            not variant_alternative_exhausted(ctx)) {
 3884|  1.34k|                           ctx.error = error_code::none;
 3885|  1.34k|                        }
 3886|  1.34k|                     }
 3887|  1.34k|                     ++non_const_idx;
 3888|  1.34k|                  }
 3889|  1.34k|               });
 3890|  1.34k|               if (!found_match) {
  ------------------
  |  Branch (3890:20): [True: 235, False: 1.10k]
  ------------------
 3891|    235|                  if constexpr (non_const_count == 1) {
 3892|       |                     // Keep the specific error from the single type we tried
 3893|       |                  }
 3894|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3895|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3896|       |                     ctx.error = error_code::no_matching_variant_type;
 3897|       |                  }
 3898|    235|               }
 3899|       |            }
 3900|       |            else {
 3901|       |               ctx.error = error_code::no_matching_variant_type;
 3902|       |            }
 3903|  1.34k|         }
 3904|  1.34k|      }
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  1.34k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  1.34k|                     auto copy_it{it};
 3841|  1.34k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  1.34k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3842:26): [True: 1.13k, False: 209]
  ------------------
 3843|  1.13k|                        value = V{};
 3844|  1.13k|                     }
 3845|  1.34k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  1.34k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3846:26): [True: 235, False: 1.10k]
  |  Branch (3846:45): [True: 0, False: 235]
  ------------------
 3847|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|      0|                     }
 3849|  1.34k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3849:26): [True: 1.10k, False: 235]
  ------------------
 3850|  1.10k|                        found_match = true;
 3851|  1.10k|                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|    235|                     else {
 3880|    235|                        it = copy_it;
 3881|    235|                        rewind_depth<Options>(ctx, copy_depth);
 3882|    235|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3882:29): [True: 0, False: 235]
  |  Branch (3882:68): [True: 0, False: 0]
  ------------------
 3883|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3883:29): [True: 0, False: 0]
  ------------------
 3884|      0|                           ctx.error = error_code::none;
 3885|      0|                        }
 3886|    235|                     }
 3887|  1.34k|                     ++non_const_idx;
 3888|  1.34k|                  }
 3889|  1.34k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  1.34k|      {
   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.34k|         else {
   60|  1.34k|            using V = std::remove_cvref_t<T>;
   61|  1.34k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  1.34k|                                             end);
   63|  1.34k|         }
   64|  1.34k|      }
_ZN3glz4fromILj10EbE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEETkNS_6bool_tERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
  710|  1.34k|      {
  711|       |         if constexpr (check_quoted_num(Opts)) {
  712|       |            if (skip_ws<Opts>(ctx, it, end)) {
  713|       |               return;
  714|       |            }
  715|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  716|       |               return;
  717|       |            }
  718|       |         }
  719|       |
  720|       |         if constexpr (!check_ws_handled(Opts)) {
  721|       |            if (skip_ws<Opts>(ctx, it, end)) {
  722|       |               return;
  723|       |            }
  724|       |         }
  725|       |
  726|       |         if constexpr (check_bools_as_numbers(Opts)) {
  727|       |            if (*it == '1') {
  728|       |               value = true;
  729|       |               ++it;
  730|       |            }
  731|       |            else if (*it == '0') {
  732|       |               value = false;
  733|       |               ++it;
  734|       |            }
  735|       |            else {
  736|       |               ctx.error = error_code::syntax_error;
  737|       |               return;
  738|       |            }
  739|       |         }
  740|  1.34k|         else {
  741|  1.34k|            if constexpr (not check_is_padded(Opts)) {
  742|  1.34k|               if (size_t(end - it) < 4) [[unlikely]] {
  ------------------
  |  Branch (742:20): [True: 45, False: 1.29k]
  ------------------
  743|     45|                  ctx.error = error_code::expected_true_or_false;
  744|     45|                  return;
  745|     45|               }
  746|  1.34k|            }
  747|       |
  748|  1.29k|            uint32_t c;
  749|  1.34k|            static constexpr uint32_t u_true = 0b01100101'01110101'01110010'01110100;
  750|  1.34k|            static constexpr uint32_t u_fals = 0b01110011'01101100'01100001'01100110;
  751|  1.34k|            std::memcpy(&c, it, 4);
  752|       |            if constexpr (std::endian::native == std::endian::big) {
  753|       |               c = std::byteswap(c);
  754|       |            }
  755|  1.34k|            it += 4;
  756|  1.34k|            if (c == u_true) {
  ------------------
  |  Branch (756:17): [True: 847, False: 493]
  ------------------
  757|    847|               value = true;
  758|    847|            }
  759|    493|            else if (it == end) [[unlikely]] {
  ------------------
  |  Branch (759:22): [True: 26, False: 467]
  ------------------
  760|     26|               ctx.error = error_code::unexpected_end;
  761|     26|               return;
  762|     26|            }
  763|    467|            else {
  764|    467|               if (c == u_fals && (*it == 'e')) [[likely]] {
  ------------------
  |  Branch (764:20): [True: 275, False: 192]
  |  Branch (764:35): [True: 258, False: 17]
  ------------------
  765|    258|                  value = false;
  766|    258|                  ++it;
  767|    258|               }
  768|    209|               else [[unlikely]] {
  769|    209|                  ctx.error = error_code::expected_true_or_false;
  770|    209|                  return;
  771|    209|               }
  772|    467|            }
  773|  1.34k|         }
  774|       |
  775|       |         if constexpr (check_quoted_num(Opts)) {
  776|       |            if constexpr (not Opts.null_terminated) {
  777|       |               if (it == end) [[unlikely]] {
  778|       |                  ctx.error = error_code::unexpected_end;
  779|       |                  return;
  780|       |               }
  781|       |            }
  782|       |            if (match<'"'>(ctx, it)) {
  783|       |               return;
  784|       |            }
  785|       |            if constexpr (not Opts.null_terminated) {
  786|       |               if (it == end) {
  787|       |                  ctx.error = error_code::end_reached;
  788|       |                  return;
  789|       |               }
  790|       |            }
  791|       |         }
  792|  1.34k|         else {
  793|       |            if constexpr (not Opts.null_terminated) {
  794|       |               if (it == end) {
  795|       |                  ctx.error = error_code::end_reached;
  796|       |                  return;
  797|       |               }
  798|       |            }
  799|  1.34k|         }
  800|  1.34k|      }
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 1.10k, False: 235]
  |  Branch (3835:38): [True: 0, False: 235]
  |  Branch (3835:51): [True: 0, False: 235]
  ------------------
 3836|  1.10k|                     return;
 3837|  1.10k|                  }
 3838|    235|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    235|               });
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 1.10k, False: 235]
  |  Branch (3835:38): [True: 0, False: 235]
  |  Branch (3835:51): [True: 0, False: 235]
  ------------------
 3836|  1.10k|                     return;
 3837|  1.10k|                  }
 3838|    235|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    235|               });
_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_:
 3765|  2.02M|      {
 3766|  2.02M|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3767|       |
 3768|       |         if constexpr (category_count == 0) {
 3769|       |            ctx.error = error_code::no_matching_variant_type;
 3770|       |         }
 3771|  2.02M|         else {
 3772|  2.02M|            constexpr auto N = std::variant_size_v<Variant>;
 3773|  2.02M|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3774|  2.02M|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3775|       |
 3776|  2.02M|            bool found_match{};
 3777|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3778|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3779|       |            // so the budget stops it and the failure already in hand is reported.
 3780|  2.02M|            bool exhausted{};
 3781|       |
 3782|       |            // First pass: const glaze types in this category
 3783|       |            if constexpr (const_count > 0) {
 3784|       |               for_each<N>([&]<size_t I>() {
 3785|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3786|       |                     return;
 3787|       |                  }
 3788|       |                  using V = std::variant_alternative_t<I, Variant>;
 3789|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3790|       |                     // run time substitute to compare to const value
 3791|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3792|       |                     auto copy_it{it};
 3793|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3794|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3795|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3796|       |                     const auto copy_depth{ctx.depth};
 3797|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3798|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3799|       |                     if (substitute == const_value) {
 3800|       |                        found_match = true;
 3801|       |                        if (!std::holds_alternative<V>(value)) {
 3802|       |                           value = V{};
 3803|       |                        }
 3804|       |                     }
 3805|       |                     else {
 3806|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3807|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3808|       |                           exhausted = true;
 3809|       |                        }
 3810|       |                        if constexpr (not Options.null_terminated) {
 3811|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3812|       |                              ctx.error = error_code::none;
 3813|       |                           }
 3814|       |                        }
 3815|       |                        it = copy_it;
 3816|       |                        rewind_depth<Options>(ctx, copy_depth);
 3817|       |                     }
 3818|       |                  }
 3819|       |               });
 3820|       |               if (found_match) {
 3821|       |                  return;
 3822|       |               }
 3823|       |            }
 3824|       |
 3825|       |            // Second pass: non-const types in this category
 3826|  2.02M|            if constexpr (non_const_count > 0) {
 3827|       |               // Track position within matching types for "is last" check.
 3828|       |               // We iterate over all variant indices but only process matching types,
 3829|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3830|       |               // the loop index directly corresponded to position in filtered set).
 3831|       |               // This has negligible cost: one increment per matching type.
 3832|  2.02M|               size_t non_const_idx = 0;
 3833|       |
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  2.02M|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  2.02M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  2.02M|                     auto copy_it{it};
 3841|  2.02M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  2.02M|                     if (!std::holds_alternative<V>(value)) {
 3843|  2.02M|                        value = V{};
 3844|  2.02M|                     }
 3845|  2.02M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  2.02M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|  2.02M|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|  2.02M|                     }
 3849|  2.02M|                     if (!bool(ctx.error)) {
 3850|  2.02M|                        found_match = true;
 3851|  2.02M|                     }
 3852|  2.02M|                     else if constexpr (not Options.null_terminated) {
 3853|  2.02M|                        constexpr bool is_complete_type =
 3854|  2.02M|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|  2.02M|                        if constexpr (is_complete_type) {
 3857|  2.02M|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|  2.02M|                              found_match = true;
 3859|  2.02M|                              ctx.error = error_code::none;
 3860|  2.02M|                           }
 3861|  2.02M|                           else {
 3862|  2.02M|                              it = copy_it;
 3863|  2.02M|                              rewind_depth<Options>(ctx, copy_depth);
 3864|  2.02M|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|  2.02M|                                  not variant_alternative_exhausted(ctx)) {
 3866|  2.02M|                                 ctx.error = error_code::none;
 3867|  2.02M|                              }
 3868|  2.02M|                           }
 3869|  2.02M|                        }
 3870|  2.02M|                        else {
 3871|  2.02M|                           it = copy_it;
 3872|  2.02M|                           rewind_depth<Options>(ctx, copy_depth);
 3873|  2.02M|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|  2.02M|                               not variant_alternative_exhausted(ctx)) {
 3875|  2.02M|                              ctx.error = error_code::none;
 3876|  2.02M|                           }
 3877|  2.02M|                        }
 3878|  2.02M|                     }
 3879|  2.02M|                     else {
 3880|  2.02M|                        it = copy_it;
 3881|  2.02M|                        rewind_depth<Options>(ctx, copy_depth);
 3882|  2.02M|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|  2.02M|                            not variant_alternative_exhausted(ctx)) {
 3884|  2.02M|                           ctx.error = error_code::none;
 3885|  2.02M|                        }
 3886|  2.02M|                     }
 3887|  2.02M|                     ++non_const_idx;
 3888|  2.02M|                  }
 3889|  2.02M|               });
 3890|  2.02M|               if (!found_match) {
  ------------------
  |  Branch (3890:20): [True: 1.34k, False: 2.02M]
  ------------------
 3891|  1.34k|                  if constexpr (non_const_count == 1) {
 3892|       |                     // Keep the specific error from the single type we tried
 3893|       |                  }
 3894|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3895|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3896|       |                     ctx.error = error_code::no_matching_variant_type;
 3897|       |                  }
 3898|  1.34k|               }
 3899|       |            }
 3900|       |            else {
 3901|       |               ctx.error = error_code::no_matching_variant_type;
 3902|       |            }
 3903|  2.02M|         }
 3904|  2.02M|      }
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 2.02M]
  |  Branch (3835:38): [True: 0, False: 2.02M]
  |  Branch (3835:51): [True: 0, False: 2.02M]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  2.02M|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  2.02M|               });
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 2.02M]
  |  Branch (3835:38): [True: 0, False: 2.02M]
  |  Branch (3835:51): [True: 0, False: 2.02M]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  2.02M|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  2.02M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  2.02M|                     auto copy_it{it};
 3841|  2.02M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  2.02M|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3842:26): [True: 1.78M, False: 242k]
  ------------------
 3843|  1.78M|                        value = V{};
 3844|  1.78M|                     }
 3845|  2.02M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  2.02M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3846:26): [True: 1.34k, False: 2.02M]
  |  Branch (3846:45): [True: 0, False: 1.34k]
  ------------------
 3847|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|      0|                     }
 3849|  2.02M|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3849:26): [True: 2.02M, False: 1.34k]
  ------------------
 3850|  2.02M|                        found_match = true;
 3851|  2.02M|                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|  1.34k|                     else {
 3880|  1.34k|                        it = copy_it;
 3881|  1.34k|                        rewind_depth<Options>(ctx, copy_depth);
 3882|  1.34k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3882:29): [True: 0, False: 1.34k]
  |  Branch (3882:68): [True: 0, False: 0]
  ------------------
 3883|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3883:29): [True: 0, False: 0]
  ------------------
 3884|      0|                           ctx.error = error_code::none;
 3885|      0|                        }
 3886|  1.34k|                     }
 3887|  2.02M|                     ++non_const_idx;
 3888|  2.02M|                  }
 3889|  2.02M|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERdTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  2.02M|      {
   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.02M|         else {
   60|  2.02M|            using V = std::remove_cvref_t<T>;
   61|  2.02M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  2.02M|                                             end);
   63|  2.02M|         }
   64|  2.02M|      }
_ZN3glz4fromILj10EdE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERPKcRdTkNS_10is_contextERNS_7contextES5_EEvOT1_OT2_OT0_T3_:
  808|  2.02M|      {
  809|       |         if constexpr (check_quoted_num(Opts)) {
  810|       |            if (skip_ws<Opts>(ctx, it, end)) {
  811|       |               return;
  812|       |            }
  813|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  814|       |               return;
  815|       |            }
  816|       |         }
  817|       |
  818|       |         if constexpr (!check_ws_handled(Opts)) {
  819|       |            if (skip_ws<Opts>(ctx, it, end)) {
  820|       |               return;
  821|       |            }
  822|       |         }
  823|       |
  824|  2.02M|         using V = std::decay_t<decltype(value)>;
  825|       |         if constexpr (int_t<V>) {
  826|       |            static_assert(sizeof(*it) == sizeof(char));
  827|       |
  828|       |            if constexpr (Opts.null_terminated) {
  829|       |               if (not glz::atoi(value, it)) [[unlikely]] {
  830|       |                  ctx.error = error_code::parse_number_failure;
  831|       |                  return;
  832|       |               }
  833|       |            }
  834|       |            else {
  835|       |               if (not glz::atoi(value, it, end)) [[unlikely]] {
  836|       |                  ctx.error = error_code::parse_number_failure;
  837|       |                  return;
  838|       |               }
  839|       |            }
  840|       |         }
  841|  2.02M|         else {
  842|       |// float128_t requires std::from_chars for floating-point, unavailable on older Apple platforms (iOS < 16.3)
  843|  2.02M|#if !defined(_LIBCPP_VERSION) || defined(_LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT)
  844|       |            if constexpr (is_float128<V>) {
  845|       |               auto [ptr, ec] = std::from_chars(it, end, value);
  846|       |               if (ec != std::errc()) {
  847|       |                  ctx.error = error_code::parse_number_failure;
  848|       |                  return;
  849|       |               }
  850|       |               it = ptr;
  851|       |            }
  852|       |            else
  853|       |#endif
  854|  2.02M|            {
  855|       |               if constexpr (std::is_volatile_v<std::remove_reference_t<decltype(value)>>) {
  856|       |                  // Hardware may interact with value changes, so we parse into a temporary and assign in one
  857|       |                  // place
  858|       |                  V temp;
  859|       |                  if constexpr (is_size_optimized(Opts)) {
  860|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, temp);
  861|       |                     if (ec != std::errc{}) [[unlikely]] {
  862|       |                        ctx.error = error_code::parse_number_failure;
  863|       |                        return;
  864|       |                     }
  865|       |                     it = ptr;
  866|       |                  }
  867|       |                  else {
  868|       |                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, temp);
  869|       |                     if (ec != std::errc()) [[unlikely]] {
  870|       |                        ctx.error = error_code::parse_number_failure;
  871|       |                        return;
  872|       |                     }
  873|       |                     it = ptr;
  874|       |                  }
  875|       |                  value = temp;
  876|       |               }
  877|  2.02M|               else {
  878|       |                  if constexpr (is_size_optimized(Opts)) {
  879|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, value);
  880|       |                     if (ec != std::errc{}) [[unlikely]] {
  881|       |                        ctx.error = error_code::parse_number_failure;
  882|       |                        return;
  883|       |                     }
  884|       |                     it = ptr;
  885|       |                  }
  886|  2.02M|                  else {
  887|  2.02M|                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, value);
  888|  2.02M|                     if (ec != std::errc()) [[unlikely]] {
  ------------------
  |  Branch (888:26): [True: 1.34k, False: 2.02M]
  ------------------
  889|  1.34k|                        ctx.error = error_code::parse_number_failure;
  890|  1.34k|                        return;
  891|  1.34k|                     }
  892|  2.02M|                     it = ptr;
  893|  2.02M|                  }
  894|  2.02M|               }
  895|  2.02M|            }
  896|  2.02M|         }
  897|       |
  898|       |         if constexpr (check_quoted_num(Opts)) {
  899|       |            if constexpr (not Opts.null_terminated) {
  900|       |               if (it == end) [[unlikely]] {
  901|       |                  ctx.error = error_code::unexpected_end;
  902|       |                  return;
  903|       |               }
  904|       |            }
  905|       |            if (match<'"'>(ctx, it)) {
  906|       |               return;
  907|       |            }
  908|       |            if constexpr (not Opts.null_terminated) {
  909|       |               if (it == end) {
  910|       |                  ctx.error = error_code::end_reached;
  911|       |                  return;
  912|       |               }
  913|       |            }
  914|       |         }
  915|  2.02M|         else {
  916|       |            if constexpr (not Opts.null_terminated) {
  917|       |               if (it == end) {
  918|       |                  ctx.error = error_code::end_reached;
  919|       |                  return;
  920|       |               }
  921|       |            }
  922|  2.02M|         }
  923|  2.02M|      }
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 2.02M, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 2.02M, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 2.02M, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 2.02M, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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_:
 5276|  10.5k|   {
 5277|  10.5k|      context ctx{};
 5278|  10.5k|      return read<opts{}>(value, std::forward<Buffer>(buffer), ctx);
 5279|  10.5k|   }
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  10.5k|      {
   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|  10.5k|         else {
   60|  10.5k|            using V = std::remove_cvref_t<T>;
   61|  10.5k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  10.5k|                                             end);
   63|  10.5k|         }
   64|  10.5k|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  10.5k|      {
  151|  10.5k|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  10.5k|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  10.5k|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  10.5k|      }
_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_:
 4093|  10.5k|      {
 4094|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 4095|       |            read_adjacent<Options>(value, ctx, it, end);
 4096|       |         }
 4097|  10.5k|         else {
 4098|  10.5k|            read_deduced<Options>(value, ctx, it, end);
 4099|  10.5k|         }
 4100|  10.5k|      }
_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_:
 4104|  10.5k|      {
 4105|  10.5k|         constexpr auto Opts = ws_handled_off<Options>();
 4106|  10.5k|         if constexpr (variant_is_auto_deducible<T>()) {
 4107|  10.5k|            if constexpr (not check_ws_handled(Options)) {
 4108|  10.5k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (4108:20): [True: 0, False: 10.5k]
  ------------------
 4109|      0|                  return;
 4110|      0|               }
 4111|  10.5k|            }
 4112|       |
 4113|  10.5k|            switch (*it) {
 4114|     16|            case '\0':
  ------------------
  |  Branch (4114:13): [True: 16, False: 10.5k]
  ------------------
 4115|     16|               ctx.error = error_code::unexpected_end;
 4116|     16|               return;
 4117|  4.67k|            case '{': {
  ------------------
  |  Branch (4117:13): [True: 4.67k, False: 5.86k]
  ------------------
 4118|       |               // This branch consumes the brace itself and hands the object to a reader with
 4119|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 4120|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 4121|       |               // the reader below.
 4122|  4.67k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (4122:20): [True: 0, False: 4.67k]
  ------------------
 4123|      0|                  return;
 4124|      0|               }
 4125|       |
 4126|  4.67k|               ++it;
 4127|       |               if constexpr (not Opts.null_terminated) {
 4128|       |                  if (it == end) [[unlikely]] {
 4129|       |                     ctx.error = error_code::unexpected_end;
 4130|       |                     return;
 4131|       |                  }
 4132|       |               }
 4133|  4.67k|               using type_counts = variant_type_count<T>;
 4134|  4.67k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 4135|       |               if constexpr (n_object_candidates < 1) {
 4136|       |                  ctx.error = error_code::no_matching_variant_type;
 4137|       |                  return;
 4138|       |               }
 4139|  4.67k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 4140|  4.67k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 4141|  4.67k|                  using V = std::variant_alternative_t<first_idx, T>;
 4142|  4.67k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4142:23): [True: 4.67k, False: 0]
  ------------------
 4143|  4.67k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 4144|  4.67k|                  return;
 4145|       |               }
 4146|       |               else {
 4147|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 4148|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 4149|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 4150|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 4151|       |
 4152|       |                  // Track if we've encountered a tag and what value it had
 4153|       |                  std::optional<size_t> tag_specified_index{};
 4154|       |
 4155|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 4156|       |                     return;
 4157|       |                  }
 4158|       |                  auto start = it;
 4159|       |                  bool first_key = true;
 4160|       |                  // Parse bifurcation for tagged variants:
 4161|       |                  //
 4162|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 4163|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 4164|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 4165|       |                  //
 4166|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 4167|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 4168|       |                  // it advances past the trailing comma so the object parser picks up at the
 4169|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 4170|       |                  //
 4171|       |                  // One exception: if the tag name is also a field on the resolved struct
 4172|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 4173|       |                  // the struct field. This override is applied inside each std::visit lambda.
 4174|       |                  auto position_after_tag = [&] {
 4175|       |                     if (first_key) {
 4176|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 4177|       |                     }
 4178|       |                     else {
 4179|       |                        it = start; // tag was not the first key, re-parse from the beginning
 4180|       |                     }
 4181|       |                  };
 4182|       |                  while (*it != '}') {
 4183|       |                     if (it != start) {
 4184|       |                        first_key = false;
 4185|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 4186|       |                           return;
 4187|       |                        }
 4188|       |                     }
 4189|       |
 4190|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4191|       |                        return;
 4192|       |                     }
 4193|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4194|       |                        return;
 4195|       |                     }
 4196|       |
 4197|       |                     auto* key_start = it;
 4198|       |                     skip_string_view(ctx, it, end);
 4199|       |                     if (bool(ctx.error)) [[unlikely]]
 4200|       |                        return;
 4201|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 4202|       |                        return;
 4203|       |                     const sv key = {key_start, size_t(it - key_start)};
 4204|       |
 4205|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4206|       |                        return;
 4207|       |                     }
 4208|       |
 4209|       |                     if constexpr (deduction_key_count > 0) {
 4210|       |                        // We first check if a tag is defined and see if the key matches the tag
 4211|       |                        if constexpr (not tag_v<T>.empty()) {
 4212|       |                           if (key == tag_v<T>) {
 4213|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 4214|       |                                 return;
 4215|       |                              }
 4216|       |
 4217|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 4218|       |
 4219|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 4220|       |                              if constexpr (std::integral<id_type>) {
 4221|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4222|       |                              }
 4223|       |                              else {
 4224|       |                                 from<JSON, sv>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4225|       |                              }
 4226|       |                              if (bool(ctx.error)) [[unlikely]]
 4227|       |                                 return;
 4228|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4229|       |                                 return;
 4230|       |                              }
 4231|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4232|       |                                 ctx.error = error_code::syntax_error;
 4233|       |                                 return;
 4234|       |                              }
 4235|       |
 4236|       |                              size_t type_index;
 4237|       |                              if constexpr (std::integral<id_type>) {
 4238|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4239|       |                              }
 4240|       |                              else {
 4241|       |                                 type_index = variant_id_to_index<T>::op(
 4242|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4243|       |                              }
 4244|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4245|       |                                 // Check if the deduced types include the tag-specified type
 4246|       |                                 // If not, the tag doesn't match the fields
 4247|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4248|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4249|       |                                 // Check if the tag-specified type is still possible
 4250|       |                                 const bool type_is_possible = possible_types[type_index];
 4251|       |                                 if (!type_is_possible) {
 4252|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4253|       |                                    ctx.error = error_code::no_matching_variant_type;
 4254|       |                                    return;
 4255|       |                                 }
 4256|       |
 4257|       |                                 position_after_tag();
 4258|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4259|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4260|       |                                 std::visit(
 4261|       |                                    [&](auto&& v) {
 4262|       |                                       using V = std::decay_t<decltype(v)>;
 4263|       |                                       constexpr bool is_object =
 4264|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4265|       |                                       if constexpr (variant_unit_alternative<V>) {
 4266|       |                                          // A unit alternative carries no data; its object holds only the
 4267|       |                                          // discriminator. Consume that body through an empty reflected object so
 4268|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4269|       |                                          detail::variant_unit_body unit_body{};
 4270|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4271|       |                                                                                             tag_literal>(unit_body,
 4272|       |                                                                                                          ctx, it, end);
 4273|       |                                       }
 4274|       |                                       else if constexpr (is_object) {
 4275|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4276|       |                                             it = start; // tag is a struct field, must re-parse
 4277|       |                                          }
 4278|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4279|       |                                                                                                           end);
 4280|       |                                       }
 4281|       |                                       else if constexpr (is_memory_object<V>) {
 4282|       |                                          if (!v) {
 4283|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4284|       |                                                if constexpr (requires { v.emplace(); }) {
 4285|       |                                                   v.emplace();
 4286|       |                                                }
 4287|       |                                                else {
 4288|       |                                                   v = typename V::value_type{};
 4289|       |                                                }
 4290|       |                                             }
 4291|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4292|       |                                                v = std::make_unique<typename V::element_type>();
 4293|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4294|       |                                                v = std::make_shared<typename V::element_type>();
 4295|       |                                             else if constexpr (constructible<V>) {
 4296|       |                                                v = meta_construct_v<V>();
 4297|       |                                             }
 4298|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4299|       |                                                                can_allocate_raw_pointer<Opts,
 4300|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4301|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4302|       |                                                   return;
 4303|       |                                                }
 4304|       |                                             }
 4305|       |                                             else {
 4306|       |                                                ctx.error = error_code::invalid_nullable_read;
 4307|       |                                                return;
 4308|       |                                                // Cannot read into unset nullable that is not std::optional,
 4309|       |                                                // std::unique_ptr, or std::shared_ptr
 4310|       |                                             }
 4311|       |                                          }
 4312|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4313|       |                                             it = start; // tag is a struct field, must re-parse
 4314|       |                                          }
 4315|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4316|       |                                             *v, ctx, it, end);
 4317|       |                                       }
 4318|       |                                       else if constexpr (custom_read<V>) {
 4319|       |                                          // Custom handlers parse the remaining body themselves and do not
 4320|       |                                          // accept the tag template parameter; the tag was already consumed.
 4321|       |                                          // This only works when the tag was the first key. If it came later,
 4322|       |                                          // we were reset to the object start and the custom handler would
 4323|       |                                          // absorb the tag, so error rather than corrupt the value.
 4324|       |                                          if (it == start) {
 4325|       |                                             ctx.error = error_code::feature_not_supported;
 4326|       |                                             ctx.custom_error_message =
 4327|       |                                                "the tag must be the first key for a custom variant alternative";
 4328|       |                                             return;
 4329|       |                                          }
 4330|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4331|       |                                       }
 4332|       |                                    },
 4333|       |                                    value);
 4334|       |
 4335|       |                                 return; // we've decoded our target type
 4336|       |                              }
 4337|       |                              else [[unlikely]] {
 4338|       |                                 // Check if we have a default type (ids array shorter than variant)
 4339|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4340|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4341|       |                                 if constexpr (ids_size < variant_size) {
 4342|       |                                    // Use the first unlabeled type as the default
 4343|       |                                    const auto default_type_index = ids_size;
 4344|       |
 4345|       |                                    position_after_tag();
 4346|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4347|       |                                    if (value.index() != default_type_index)
 4348|       |                                       emplace_runtime_variant(value, default_type_index);
 4349|       |                                    std::visit(
 4350|       |                                       [&](auto&& v) {
 4351|       |                                          using V = std::decay_t<decltype(v)>;
 4352|       |                                          constexpr bool is_object =
 4353|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4354|       |                                          if constexpr (variant_unit_alternative<V>) {
 4355|       |                                             // A unit alternative carries no data; its object holds only the
 4356|       |                                             // discriminator. Consume that body through an empty reflected object so
 4357|       |                                             // unknown-key policy and terminator handling match every other
 4358|       |                                             // alternative.
 4359|       |                                             detail::variant_unit_body unit_body{};
 4360|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4361|       |                                                                                                tag_literal>(
 4362|       |                                                unit_body, ctx, it, end);
 4363|       |                                          }
 4364|       |                                          else if constexpr (is_object) {
 4365|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4366|       |                                                it = start; // tag is a struct field, must re-parse
 4367|       |                                             }
 4368|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4369|       |                                          }
 4370|       |                                          else if constexpr (is_memory_object<V>) {
 4371|       |                                             if (!v) {
 4372|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4373|       |                                                   if constexpr (requires { v.emplace(); }) {
 4374|       |                                                      v.emplace();
 4375|       |                                                   }
 4376|       |                                                   else {
 4377|       |                                                      v = typename V::value_type{};
 4378|       |                                                   }
 4379|       |                                                }
 4380|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4381|       |                                                   v = std::make_unique<typename V::element_type>();
 4382|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4383|       |                                                   v = std::make_shared<typename V::element_type>();
 4384|       |                                                else if constexpr (constructible<V>) {
 4385|       |                                                   v = meta_construct_v<V>();
 4386|       |                                                }
 4387|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4388|       |                                                                   can_allocate_raw_pointer<
 4389|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4390|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4391|       |                                                      return;
 4392|       |                                                   }
 4393|       |                                                }
 4394|       |                                                else {
 4395|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4396|       |                                                   return;
 4397|       |                                                }
 4398|       |                                             }
 4399|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4400|       |                                                it = start; // tag is a struct field, must re-parse
 4401|       |                                             }
 4402|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4403|       |                                                                                                              it, end);
 4404|       |                                          }
 4405|       |                                          else if constexpr (custom_read<V>) {
 4406|       |                                             // Custom handlers parse the remaining body themselves; this only
 4407|       |                                             // works when the tag was the first key (see above). If it came
 4408|       |                                             // later we were reset to the object start, so error rather than
 4409|       |                                             // let the custom handler absorb the tag.
 4410|       |                                             if (it == start) {
 4411|       |                                                ctx.error = error_code::feature_not_supported;
 4412|       |                                                ctx.custom_error_message =
 4413|       |                                                   "the tag must be the first key for a custom variant alternative";
 4414|       |                                                return;
 4415|       |                                             }
 4416|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4417|       |                                          }
 4418|       |                                       },
 4419|       |                                       value);
 4420|       |
 4421|       |                                    return;
 4422|       |                                 }
 4423|       |                                 else {
 4424|       |                                    ctx.error = error_code::no_matching_variant_type;
 4425|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4426|       |                                    return;
 4427|       |                                 }
 4428|       |                              }
 4429|       |                           }
 4430|       |                        }
 4431|       |
 4432|       |                        // Inline decode_hash lookup for variant deduction
 4433|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4434|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4435|       |                        const auto deduction_index =
 4436|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4437|       |                              key.data(), key.data() + key.size(), key.size());
 4438|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4439|       |                           [[likely]] {
 4440|       |                           possible_types &= deduction_bits[deduction_index];
 4441|       |                        }
 4442|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4443|       |                           ctx.error = error_code::unknown_key;
 4444|       |                           return;
 4445|       |                        }
 4446|       |                     }
 4447|       |                     else if constexpr (not tag_v<T>.empty()) {
 4448|       |                        // empty object case for variant, if there are no normal elements
 4449|       |                        if (key == tag_v<T>) {
 4450|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4451|       |                              return;
 4452|       |                           }
 4453|       |
 4454|       |                           std::string_view type_id{};
 4455|       |                           parse<JSON>::op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4456|       |                           if (bool(ctx.error)) [[unlikely]]
 4457|       |                              return;
 4458|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4459|       |                              return;
 4460|       |                           }
 4461|       |
 4462|       |                           const auto type_index = variant_id_to_index<T>::op(
 4463|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4464|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4465|       |                              position_after_tag();
 4466|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4467|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4468|       |                           }
 4469|       |                           else {
 4470|       |                              // Check if we have a default type (ids array shorter than variant)
 4471|       |                              constexpr auto ids_size = ids_v<T>.size();
 4472|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4473|       |                              if constexpr (ids_size < variant_size) {
 4474|       |                                 // Use the first unlabeled type as the default
 4475|       |                                 position_after_tag();
 4476|       |                                 const auto default_index = ids_size;
 4477|       |                                 tag_specified_index = default_index; // Store the default type index
 4478|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4479|       |                              }
 4480|       |                              else {
 4481|       |                                 ctx.error = error_code::no_matching_variant_type;
 4482|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4483|       |                                 return;
 4484|       |                              }
 4485|       |                           }
 4486|       |                           // Parse the type (handles tag skipping and unknown keys)
 4487|       |                           std::visit(
 4488|       |                              [&](auto&& v) {
 4489|       |                                 using V = std::decay_t<decltype(v)>;
 4490|       |                                 if constexpr (custom_read<V>) {
 4491|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4492|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4493|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4494|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4495|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4496|       |                                    // into its value, so error here rather than corrupt the result.
 4497|       |                                    if (it == start) {
 4498|       |                                       ctx.error = error_code::feature_not_supported;
 4499|       |                                       ctx.custom_error_message =
 4500|       |                                          "the tag must be the first key for a custom variant alternative";
 4501|       |                                       return;
 4502|       |                                    }
 4503|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4504|       |                                 }
 4505|       |                                 else {
 4506|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4507|       |                                       it = start; // tag is a struct field, must re-parse
 4508|       |                                    }
 4509|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4510|       |                                 }
 4511|       |                              },
 4512|       |                              value);
 4513|       |                           return;
 4514|       |                        }
 4515|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4516|       |                           ctx.error = error_code::unknown_key;
 4517|       |                           return;
 4518|       |                        }
 4519|       |                        else {
 4520|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4521|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4522|       |                              return;
 4523|       |                           }
 4524|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4525|       |                           if (bool(ctx.error)) [[unlikely]]
 4526|       |                              return;
 4527|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4528|       |                              return;
 4529|       |                           }
 4530|       |                           continue; // Continue loop to find the tag
 4531|       |                        }
 4532|       |                     }
 4533|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4534|       |                        ctx.error = error_code::unknown_key;
 4535|       |                        return;
 4536|       |                     }
 4537|       |
 4538|       |                     auto matching_types = possible_types.popcount();
 4539|       |                     if (matching_types == 0) {
 4540|       |                        ctx.error = error_code::no_matching_variant_type;
 4541|       |                        return;
 4542|       |                     }
 4543|       |                     // Only short-circuit for variants without tags
 4544|       |                     else if constexpr (tag_v<T>.empty()) {
 4545|       |                        if (matching_types == 1) {
 4546|       |                           it = start;
 4547|       |                           const auto type_index = possible_types.countr_zero();
 4548|       |
 4549|       |                           if (value.index() != static_cast<size_t>(type_index))
 4550|       |                              emplace_runtime_variant(value, type_index);
 4551|       |                           std::visit(
 4552|       |                              [&](auto&& v) {
 4553|       |                                 using V = std::decay_t<decltype(v)>;
 4554|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4555|       |                                 if constexpr (variant_unit_alternative<V>) {
 4556|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4557|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4558|       |                                    // terminator handling match every other alternative.
 4559|       |                                    detail::variant_unit_body unit_body{};
 4560|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4561|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4562|       |                                                                                                    end);
 4563|       |                                 }
 4564|       |                                 else if constexpr (is_object) {
 4565|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4566|       |                                 }
 4567|       |                                 else if constexpr (is_memory_object<V>) {
 4568|       |                                    if (!v) {
 4569|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4570|       |                                          if constexpr (requires { v.emplace(); }) {
 4571|       |                                             v.emplace();
 4572|       |                                          }
 4573|       |                                          else {
 4574|       |                                             v = typename V::value_type{};
 4575|       |                                          }
 4576|       |                                       }
 4577|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4578|       |                                          v = std::make_unique<typename V::element_type>();
 4579|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4580|       |                                          v = std::make_shared<typename V::element_type>();
 4581|       |                                       else if constexpr (constructible<V>) {
 4582|       |                                          v = meta_construct_v<V>();
 4583|       |                                       }
 4584|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4585|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4586|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4587|       |                                             return;
 4588|       |                                          }
 4589|       |                                       }
 4590|       |                                       else {
 4591|       |                                          ctx.error = error_code::invalid_nullable_read;
 4592|       |                                          return;
 4593|       |                                          // Cannot read into unset nullable that is not std::optional,
 4594|       |                                          // std::unique_ptr, or std::shared_ptr
 4595|       |                                       }
 4596|       |                                    }
 4597|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4598|       |                                       *v, ctx, it, end);
 4599|       |                                 }
 4600|       |                                 else if constexpr (custom_read<V>) {
 4601|       |                                    // Custom handlers parse the remaining body themselves.
 4602|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4603|       |                                 }
 4604|       |                              },
 4605|       |                              value);
 4606|       |
 4607|       |                           return; // we've decoded our target type
 4608|       |                        }
 4609|       |                     }
 4610|       |                     // For tagged variants, continue processing to validate tags
 4611|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4612|       |                        return;
 4613|       |                     }
 4614|       |
 4615|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4616|       |                     if (bool(ctx.error)) [[unlikely]]
 4617|       |                        return;
 4618|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4619|       |                        return;
 4620|       |                     }
 4621|       |                  }
 4622|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4623|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4624|       |                     // After parsing all keys, check if we have multiple matching types
 4625|       |                     // If so, choose the one with the fewest fields
 4626|       |                     auto final_matching = possible_types.popcount();
 4627|       |                     if (final_matching == 0) {
 4628|       |                        ctx.error = error_code::no_matching_variant_type;
 4629|       |                     }
 4630|       |                     else if (final_matching == 1) {
 4631|       |                        // Single type remains after field deduction
 4632|       |                        const auto type_index = possible_types.countr_zero();
 4633|       |
 4634|       |                        // Validate against tag if one was specified
 4635|       |                        if (tag_specified_index.has_value() &&
 4636|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4637|       |                           ctx.error = error_code::no_matching_variant_type;
 4638|       |                           return;
 4639|       |                        }
 4640|       |
 4641|       |                        it = start;
 4642|       |                        if (value.index() != static_cast<size_t>(type_index))
 4643|       |                           emplace_runtime_variant(value, type_index);
 4644|       |                        std::visit(
 4645|       |                           [&](auto&& v) {
 4646|       |                              using V = std::decay_t<decltype(v)>;
 4647|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4648|       |                              if constexpr (variant_unit_alternative<V>) {
 4649|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4650|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4651|       |                                 // terminator handling match every other alternative.
 4652|       |                                 detail::variant_unit_body unit_body{};
 4653|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4654|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4655|       |                                                                                                 end);
 4656|       |                              }
 4657|       |                              else if constexpr (is_object) {
 4658|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4659|       |                              }
 4660|       |                              else if constexpr (is_memory_object<V>) {
 4661|       |                                 if (!v) {
 4662|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4663|       |                                       if constexpr (requires { v.emplace(); }) {
 4664|       |                                          v.emplace();
 4665|       |                                       }
 4666|       |                                       else {
 4667|       |                                          v = typename V::value_type{};
 4668|       |                                       }
 4669|       |                                    }
 4670|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4671|       |                                       v = std::make_unique<typename V::element_type>();
 4672|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4673|       |                                       v = std::make_shared<typename V::element_type>();
 4674|       |                                    else if constexpr (constructible<V>) {
 4675|       |                                       v = meta_construct_v<V>();
 4676|       |                                    }
 4677|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4678|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4679|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4680|       |                                          return;
 4681|       |                                       }
 4682|       |                                    }
 4683|       |                                    else {
 4684|       |                                       ctx.error = error_code::invalid_nullable_read;
 4685|       |                                       return;
 4686|       |                                    }
 4687|       |                                 }
 4688|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4689|       |                                                                                                               it, end);
 4690|       |                              }
 4691|       |                              else if constexpr (custom_read<V>) {
 4692|       |                                 // Custom handlers parse the remaining body themselves.
 4693|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4694|       |                              }
 4695|       |                           },
 4696|       |                           value);
 4697|       |                     }
 4698|       |                     else if (final_matching > 1) {
 4699|       |                        constexpr auto N = std::variant_size_v<T>;
 4700|       |
 4701|       |                        // Compile-time array of field counts for each variant type
 4702|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4703|       |                           return std::array<size_t, N> {
 4704|       |                              ([]<size_t J = I>() -> size_t {
 4705|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4706|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4707|       |                                    return reflect<V>::size;
 4708|       |                                 }
 4709|       |                                 else if constexpr (is_memory_object<V>) {
 4710|       |                                    using X = memory_type<V>;
 4711|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4712|       |                                       return reflect<X>::size;
 4713|       |                                    }
 4714|       |                                    else {
 4715|       |                                       return (std::numeric_limits<size_t>::max)();
 4716|       |                                    }
 4717|       |                                 }
 4718|       |                                 else {
 4719|       |                                    return (std::numeric_limits<size_t>::max)();
 4720|       |                                 }
 4721|       |                              }.template operator()<I>())...
 4722|       |                           };
 4723|       |                        }(std::make_index_sequence<N>{});
 4724|       |
 4725|       |                        // Find the type with minimum field count among the possible types
 4726|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4727|       |                        size_t chosen_index = N; // Invalid index initially
 4728|       |
 4729|       |                        for (size_t i = 0; i < N; ++i) {
 4730|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4731|       |                              min_fields = field_counts[i];
 4732|       |                              chosen_index = i;
 4733|       |                           }
 4734|       |                        }
 4735|       |
 4736|       |                        if (chosen_index < N) {
 4737|       |                           // Validate against tag if one was specified
 4738|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4739|       |                              ctx.error = error_code::no_matching_variant_type;
 4740|       |                              return;
 4741|       |                           }
 4742|       |
 4743|       |                           it = start;
 4744|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4745|       |                           std::visit(
 4746|       |                              [&](auto&& v) {
 4747|       |                                 using V = std::decay_t<decltype(v)>;
 4748|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4749|       |                                 if constexpr (variant_unit_alternative<V>) {
 4750|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4751|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4752|       |                                    // terminator handling match every other alternative.
 4753|       |                                    detail::variant_unit_body unit_body{};
 4754|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4755|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4756|       |                                                                                                    end);
 4757|       |                                 }
 4758|       |                                 else if constexpr (is_object) {
 4759|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4760|       |                                 }
 4761|       |                                 else if constexpr (is_memory_object<V>) {
 4762|       |                                    if (!v) {
 4763|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4764|       |                                          if constexpr (requires { v.emplace(); }) {
 4765|       |                                             v.emplace();
 4766|       |                                          }
 4767|       |                                          else {
 4768|       |                                             v = typename V::value_type{};
 4769|       |                                          }
 4770|       |                                       }
 4771|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4772|       |                                          v = std::make_unique<typename V::element_type>();
 4773|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4774|       |                                          v = std::make_shared<typename V::element_type>();
 4775|       |                                       else if constexpr (constructible<V>) {
 4776|       |                                          v = meta_construct_v<V>();
 4777|       |                                       }
 4778|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4779|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4780|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4781|       |                                             return;
 4782|       |                                          }
 4783|       |                                       }
 4784|       |                                       else {
 4785|       |                                          ctx.error = error_code::invalid_nullable_read;
 4786|       |                                          return;
 4787|       |                                       }
 4788|       |                                    }
 4789|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4790|       |                                       *v, ctx, it, end);
 4791|       |                                 }
 4792|       |                                 else if constexpr (custom_read<V>) {
 4793|       |                                    // Custom handlers parse the remaining body themselves.
 4794|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4795|       |                                 }
 4796|       |                              },
 4797|       |                              value);
 4798|       |                        }
 4799|       |                        else {
 4800|       |                           ctx.error = error_code::no_matching_variant_type;
 4801|       |                        }
 4802|       |                     }
 4803|       |                  }
 4804|       |                  else {
 4805|       |                     // For variants with 0 or 1 object types, use the original error handling
 4806|       |                     ctx.error = error_code::no_matching_variant_type;
 4807|       |                  }
 4808|       |               }
 4809|      0|               break;
 4810|  4.67k|            }
 4811|  2.00k|            case '[':
  ------------------
  |  Branch (4811:13): [True: 2.00k, False: 8.53k]
  ------------------
 4812|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4813|  2.00k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4814|  2.00k|               break;
 4815|  1.06k|            case '"': {
  ------------------
  |  Branch (4815:13): [True: 1.06k, False: 9.47k]
  ------------------
 4816|  1.06k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4817|  1.06k|               break;
 4818|  4.67k|            }
 4819|     65|            case 't':
  ------------------
  |  Branch (4819:13): [True: 65, False: 10.4k]
  ------------------
 4820|    180|            case 'f': {
  ------------------
  |  Branch (4820:13): [True: 115, False: 10.4k]
  ------------------
 4821|    180|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4822|    180|               break;
 4823|     65|            }
 4824|     73|            case 'n':
  ------------------
  |  Branch (4824:13): [True: 73, False: 10.4k]
  ------------------
 4825|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4826|       |                  ctx.error = error_code::no_matching_variant_type;
 4827|       |               }
 4828|     73|               else {
 4829|     73|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4830|     73|                  using V = std::variant_alternative_t<first_idx, T>;
 4831|     73|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4831:23): [True: 0, False: 73]
  ------------------
 4832|     73|                  match<"null", Opts>(ctx, it, end);
 4833|     73|               }
 4834|     73|               break;
 4835|  2.52k|            default: {
  ------------------
  |  Branch (4835:13): [True: 2.52k, False: 8.01k]
  ------------------
 4836|       |               // Not bool, string, object, or array so must be number or null
 4837|  2.52k|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4838|  2.52k|            }
 4839|  10.5k|            }
 4840|       |         }
 4841|       |         else {
 4842|       |            // For non-auto-deducible variants, try each type until one succeeds
 4843|       |            constexpr auto N = std::variant_size_v<T>;
 4844|       |            bool parsed = false;
 4845|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4846|       |
 4847|       |            for_each<N>([&]<size_t I>() {
 4848|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4849|       |
 4850|       |               auto copy_it = it;
 4851|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4852|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4853|       |               const auto copy_depth = ctx.depth;
 4854|       |
 4855|       |               // Try parsing as this type
 4856|       |               if (value.index() != I) {
 4857|       |                  emplace_runtime_variant(value, I);
 4858|       |               }
 4859|       |
 4860|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4861|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4862|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4863|       |               }
 4864|       |
 4865|       |               if (!bool(ctx.error)) {
 4866|       |                  parsed = true;
 4867|       |               }
 4868|       |               else if constexpr (not Options.null_terminated) {
 4869|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4870|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4871|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4872|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4873|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4874|       |                     parsed = true;
 4875|       |                     ctx.error = error_code::none;
 4876|       |                  }
 4877|       |                  else {
 4878|       |                     // Reset for next attempt (unless this is the last type)
 4879|       |                     it = copy_it;
 4880|       |                     rewind_depth<Options>(ctx, copy_depth);
 4881|       |                     if constexpr (I + 1 < N) {
 4882|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4883|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4884|       |                        }
 4885|       |                     }
 4886|       |                  }
 4887|       |               }
 4888|       |               else {
 4889|       |                  // Reset for next attempt (unless this is the last type)
 4890|       |                  it = copy_it;
 4891|       |                  rewind_depth<Options>(ctx, copy_depth);
 4892|       |                  if constexpr (I + 1 < N) {
 4893|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4894|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4895|       |                     }
 4896|       |                  }
 4897|       |               }
 4898|       |            });
 4899|       |         }
 4900|  10.5k|      }
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj33EEERNS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES4_EEEETkNS_10is_contextERNS_7contextERPKcSD_EEvOT0_OT1_OT2_T3_:
   49|  27.9k|      {
   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|  27.9k|         else {
   60|  27.9k|            using V = std::remove_cvref_t<T>;
   61|  27.9k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  27.9k|                                             end);
   63|  27.9k|         }
   64|  27.9k|      }
_ZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj33EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_:
 3085|  27.9k|      {
 3086|  27.9k|         static constexpr auto num_members = reflect<T>::size;
 3087|       |
 3088|  27.9k|         static constexpr auto Opts = opening_handled_off<ws_handled_off<Options>()>();
 3089|       |         if constexpr (!check_opening_handled(Options)) {
 3090|       |            if constexpr (!check_ws_handled(Options)) {
 3091|       |               if (skip_ws<Opts>(ctx, it, end)) {
 3092|       |                  return;
 3093|       |               }
 3094|       |            }
 3095|       |            if (match_invalid_end<'{', Opts>(ctx, it, end)) {
 3096|       |               return;
 3097|       |            }
 3098|       |            if constexpr (not Opts.null_terminated) {
 3099|       |               if (it == end) [[unlikely]] {
 3100|       |                  ctx.error = error_code::unexpected_end;
 3101|       |                  return;
 3102|       |               }
 3103|       |            }
 3104|       |            // one nesting level (see enter_depth): counted in both modes so the limit binds,
 3105|       |            // released at each syntactic close below
 3106|       |            if (enter_depth(ctx)) [[unlikely]] {
 3107|       |               return;
 3108|       |            }
 3109|       |         }
 3110|  27.9k|         const auto ws_start = it;
 3111|  27.9k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3111:14): [True: 0, False: 27.9k]
  ------------------
 3112|      0|            return;
 3113|      0|         }
 3114|  27.9k|         const size_t ws_size = size_t(it - ws_start);
 3115|       |
 3116|       |         if constexpr ((glaze_object_t<T> || reflectable<T>) && num_members == 0 && Opts.error_on_unknown_keys) {
 3117|       |            if constexpr (not tag.sv().empty()) {
 3118|       |               if (*it == '"') {
 3119|       |                  ++it;
 3120|       |                  if constexpr (not Opts.null_terminated) {
 3121|       |                     if (it == end) [[unlikely]] {
 3122|       |                        ctx.error = error_code::unexpected_end;
 3123|       |                        return;
 3124|       |                     }
 3125|       |                  }
 3126|       |
 3127|       |                  const auto start = it;
 3128|       |                  skip_string_view(ctx, it, end);
 3129|       |                  if (bool(ctx.error)) [[unlikely]]
 3130|       |                     return;
 3131|       |                  if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3132|       |                     return;
 3133|       |                  const sv key{start, size_t(it - start)};
 3134|       |                  ++it;
 3135|       |                  if constexpr (not Opts.null_terminated) {
 3136|       |                     if (it == end) [[unlikely]] {
 3137|       |                        ctx.error = error_code::unexpected_end;
 3138|       |                        return;
 3139|       |                     }
 3140|       |                  }
 3141|       |
 3142|       |                  if (key == tag.sv()) {
 3143|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3144|       |                        return;
 3145|       |                     }
 3146|       |
 3147|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3148|       |                     if (bool(ctx.error)) [[unlikely]]
 3149|       |                        return;
 3150|       |
 3151|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3152|       |                        return;
 3153|       |                     }
 3154|       |                  }
 3155|       |                  else {
 3156|       |                     ctx.error = error_code::unknown_key;
 3157|       |                     return;
 3158|       |                  }
 3159|       |               }
 3160|       |            }
 3161|       |
 3162|       |            if (*it == '}') [[likely]] {
 3163|       |               --ctx.depth;
 3164|       |               if constexpr (glaze_object_t<T> || reflectable<T>) {
 3165|       |                  if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 3166|       |                     auto wrapper = self_constraint_v<T>(value);
 3167|       |                     from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 3168|       |                     if (bool(ctx.error)) {
 3169|       |                        return;
 3170|       |                     }
 3171|       |                  }
 3172|       |               }
 3173|       |               ++it;
 3174|       |               if constexpr (not Opts.null_terminated) {
 3175|       |                  if (it == end) {
 3176|       |                     ctx.error = error_code::end_reached;
 3177|       |                     return;
 3178|       |                  }
 3179|       |               }
 3180|       |               if constexpr (Opts.partial_read) {
 3181|       |                  ctx.error = error_code::partial_read_complete;
 3182|       |               }
 3183|       |               return;
 3184|       |            }
 3185|       |            ctx.error = error_code::unknown_key;
 3186|       |            return;
 3187|       |         }
 3188|  27.9k|         else {
 3189|  27.9k|            decltype(auto) fields = [&]() -> decltype(auto) {
 3190|  27.9k|               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 3191|  27.9k|                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 3192|  27.9k|                  return bit_array<num_members>{};
 3193|  27.9k|               }
 3194|  27.9k|               else {
 3195|  27.9k|                  return nullptr;
 3196|  27.9k|               }
 3197|  27.9k|            }();
 3198|       |
 3199|  27.9k|            size_t read_count{}; // for partial_read
 3200|       |
 3201|  27.9k|            bool first = true;
 3202|   965k|            while (true) {
  ------------------
  |  Branch (3202:20): [True: 940k, Folded]
  ------------------
 3203|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.partial_read) {
 3204|       |                  static constexpr bit_array<num_members> all_fields = [] {
 3205|       |                     bit_array<num_members> arr{};
 3206|       |                     for (size_t i = 0; i < num_members; ++i) {
 3207|       |                        arr[i] = true;
 3208|       |                     }
 3209|       |                     return arr;
 3210|       |                  }();
 3211|       |
 3212|       |                  if ((all_fields & fields) == all_fields) {
 3213|       |                     ctx.error = error_code::partial_read_complete;
 3214|       |                     --ctx.depth; // as above: an early success still closes this level
 3215|       |                     return;
 3216|       |                  }
 3217|       |               }
 3218|       |
 3219|       |               // Streaming refill point: at start of each iteration, ensure buffer has data
 3220|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 3221|       |                  if (ctx.stream.enabled()) {
 3222|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 3223|       |                     const size_t remaining = ctx.stream.size() - consumed;
 3224|       |                     // Refill when less than half of buffer remains to ensure space for next key-value pair
 3225|       |                     if (remaining <= ctx.stream.size() / 2 || it >= end) {
 3226|       |                        const char* new_it;
 3227|       |                        const char* new_end;
 3228|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 3229|       |                        it = new_it;
 3230|       |                        end = new_end;
 3231|       |                        if (it >= end && ctx.stream.at_eof()) {
 3232|       |                           ctx.error = error_code::unexpected_end;
 3233|       |                           return;
 3234|       |                        }
 3235|       |                     }
 3236|       |                  }
 3237|       |               }
 3238|       |
 3239|   940k|               if (*it == '}') {
  ------------------
  |  Branch (3239:20): [True: 2.74k, False: 937k]
  ------------------
 3240|  2.74k|                  --ctx.depth;
 3241|       |                  if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.error_on_missing_keys) {
 3242|       |                     constexpr auto req_fields = required_fields<T, Opts>();
 3243|       |                     if ((req_fields & fields) != req_fields) {
 3244|       |                        for (size_t i = 0; i < num_members; ++i) {
 3245|       |                           if (not fields[i] && req_fields[i]) {
 3246|       |                              ctx.custom_error_message = reflect<T>::keys[i];
 3247|       |                              // We just return the first missing key in order to avoid heap allocations
 3248|       |                              break;
 3249|       |                           }
 3250|       |                        }
 3251|       |
 3252|       |                        ctx.error = error_code::missing_key;
 3253|       |                        return;
 3254|       |                     }
 3255|       |                  }
 3256|       |                  if constexpr (glaze_object_t<T> || reflectable<T>) {
 3257|       |                     if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 3258|       |                        auto wrapper = self_constraint_v<T>(value);
 3259|       |                        from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 3260|       |                        if (bool(ctx.error)) {
 3261|       |                           return;
 3262|       |                        }
 3263|       |                     }
 3264|       |                  }
 3265|  2.74k|                  ++it; // Increment after checking for missing keys so errors are within buffer bounds
 3266|       |                  if constexpr (not Opts.null_terminated) {
 3267|       |                     if (it == end) {
 3268|       |                        ctx.error = error_code::end_reached;
 3269|       |                        return;
 3270|       |                     }
 3271|       |                  }
 3272|  2.74k|                  return;
 3273|  2.74k|               }
 3274|   937k|               else if (first) {
  ------------------
  |  Branch (3274:25): [True: 26.1k, False: 911k]
  ------------------
 3275|  26.1k|                  first = false;
 3276|  26.1k|               }
 3277|   911k|               else {
 3278|   911k|                  if (match_invalid_end<',', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3278:23): [True: 440, False: 911k]
  ------------------
 3279|    440|                     return;
 3280|    440|                  }
 3281|       |                  if constexpr (not Opts.null_terminated) {
 3282|       |                     if (it == end) [[unlikely]] {
 3283|       |                        ctx.error = error_code::unexpected_end;
 3284|       |                        return;
 3285|       |                     }
 3286|       |                  }
 3287|       |
 3288|       |                  if constexpr ((not Opts.minified) && (num_members > 1 || not Opts.error_on_unknown_keys) &&
 3289|       |                                (!Opts.comments)) {
 3290|       |                     if (ws_size && ws_size < size_t(end - it)) {
 3291|       |                        skip_matching_ws(ws_start, it, ws_size);
 3292|       |                     }
 3293|       |                  }
 3294|       |
 3295|   911k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3295:23): [True: 0, False: 911k]
  ------------------
 3296|      0|                     return;
 3297|      0|                  }
 3298|   911k|               }
 3299|       |
 3300|   937k|               constexpr auto reflection_type = glaze_object_t<T> || reflectable<T>;
  ------------------
  |  Branch (3300:49): [Folded, False: 0]
  |  Branch (3300:70): [Folded, False: 0]
  ------------------
 3301|       |
 3302|       |               if constexpr (reflection_type && (num_members == 0)) {
 3303|       |                  if constexpr (Opts.error_on_unknown_keys) {
 3304|       |                     static_assert(false_v<T>, "This should be unreachable");
 3305|       |                  }
 3306|       |                  else {
 3307|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 3308|       |                        return;
 3309|       |                     }
 3310|       |
 3311|       |                     // parsing to an empty object, but at this point the JSON presents keys
 3312|       |
 3313|       |                     // Unknown key handler does not unescape keys. Unknown escaped keys are
 3314|       |                     // handled by the user.
 3315|       |
 3316|       |                     const auto start = it;
 3317|       |                     skip_string_view(ctx, it, end);
 3318|       |                     if (bool(ctx.error)) [[unlikely]]
 3319|       |                        return;
 3320|       |                     if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3321|       |                        return;
 3322|       |                     const sv key{start, size_t(it - start)};
 3323|       |                     ++it;
 3324|       |                     if constexpr (not Opts.null_terminated) {
 3325|       |                        if (it == end) [[unlikely]] {
 3326|       |                           ctx.error = error_code::unexpected_end;
 3327|       |                           return;
 3328|       |                        }
 3329|       |                     }
 3330|       |
 3331|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3332|       |                        return;
 3333|       |                     }
 3334|       |
 3335|       |                     // Check if this key is the variant tag that should be skipped
 3336|       |                     if constexpr (not tag.sv().empty()) {
 3337|       |                        if (key == tag.sv()) {
 3338|       |                           // Skip the tag value
 3339|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3340|       |                           if (bool(ctx.error)) [[unlikely]]
 3341|       |                              return;
 3342|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 3343|       |                              return;
 3344|       |                           }
 3345|       |                           continue;
 3346|       |                        }
 3347|       |                     }
 3348|       |
 3349|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3350|       |                     if (bool(ctx.error)) [[unlikely]]
 3351|       |                        return;
 3352|       |                     if constexpr (not Opts.null_terminated) {
 3353|       |                        if (it == end) [[unlikely]] {
 3354|       |                           ctx.error = error_code::unexpected_end;
 3355|       |                           return;
 3356|       |                        }
 3357|       |                     }
 3358|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3359|       |                        return;
 3360|       |                     }
 3361|       |                  }
 3362|       |               }
 3363|       |               else if constexpr (reflection_type) {
 3364|       |                  static_assert(bool(hash_info<T>.type));
 3365|       |
 3366|       |                  if (*it != '"') [[unlikely]] {
 3367|       |                     ctx.error = error_code::expected_quote;
 3368|       |                     return;
 3369|       |                  }
 3370|       |                  ++it;
 3371|       |                  if constexpr (not Opts.null_terminated) {
 3372|       |                     if (it == end) [[unlikely]] {
 3373|       |                        ctx.error = error_code::unexpected_end;
 3374|       |                        return;
 3375|       |                     }
 3376|       |                  }
 3377|       |
 3378|       |                  if constexpr (not tag.sv().empty() && not contains_tag<T, tag>()) {
 3379|       |                     // For tagged variants we first check to see if the key matches the tag
 3380|       |                     // We only need to do this if the tag is not part of the keys
 3381|       |
 3382|       |                     const auto start = it;
 3383|       |                     skip_string_view(ctx, it, end);
 3384|       |                     if (bool(ctx.error)) [[unlikely]]
 3385|       |                        return;
 3386|       |                     if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 3387|       |                        return;
 3388|       |                     const sv key{start, size_t(it - start)};
 3389|       |                     ++it;
 3390|       |                     if constexpr (not Opts.null_terminated) {
 3391|       |                        if (it == end) [[unlikely]] {
 3392|       |                           ctx.error = error_code::unexpected_end;
 3393|       |                           return;
 3394|       |                        }
 3395|       |                     }
 3396|       |
 3397|       |                     if (key == tag.sv()) {
 3398|       |                        if (parse_ws_colon<Opts>(ctx, it, end)) {
 3399|       |                           return;
 3400|       |                        }
 3401|       |
 3402|       |                        parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3403|       |                        if (bool(ctx.error)) [[unlikely]]
 3404|       |                           return;
 3405|       |
 3406|       |                        if (skip_ws<Opts>(ctx, it, end)) {
 3407|       |                           return;
 3408|       |                        }
 3409|       |                        continue;
 3410|       |                     }
 3411|       |                     else {
 3412|       |                        it = start; // reset the iterator
 3413|       |                     }
 3414|       |                  }
 3415|       |
 3416|       |                  if constexpr (Opts.error_on_missing_keys || Opts.partial_read) {
 3417|       |                     size_t index = num_members;
 3418|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end, index);
 3419|       |                     if (bool(ctx.error)) [[unlikely]]
 3420|       |                        return;
 3421|       |                     if (index < num_members) {
 3422|       |                        fields[index] = true;
 3423|       |                     }
 3424|       |                  }
 3425|       |                  else {
 3426|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end);
 3427|       |                     if (bool(ctx.error)) [[unlikely]]
 3428|       |                        return;
 3429|       |                  }
 3430|       |               }
 3431|   937k|               else {
 3432|       |                  // For types like std::map, std::unordered_map
 3433|       |
 3434|   937k|                  auto reading = [&](auto&& key) {
 3435|   937k|                     if constexpr (Opts.partial_read) {
 3436|   937k|                        if (auto element = value.find(key); element != value.end()) {
 3437|   937k|                           ++read_count;
 3438|   937k|                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3439|   937k|                        }
 3440|   937k|                        else {
 3441|   937k|                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3442|   937k|                        }
 3443|   937k|                     }
 3444|   937k|                     else {
 3445|   937k|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3446|   937k|                     }
 3447|   937k|                  };
 3448|       |
 3449|       |                  // using Key = std::conditional_t<heterogeneous_map<T>, sv, typename T::key_type>;
 3450|   937k|                  using Key = typename T::key_type;
 3451|   937k|                  if constexpr (std::is_same_v<Key, std::string>) {
 3452|   937k|                     ctx.scratch.clear();
 3453|   937k|                     parse<JSON>::op<Opts>(ctx.scratch, ctx, it, end);
 3454|   937k|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3454:26): [True: 1.57k, False: 935k]
  ------------------
 3455|  1.57k|                        return;
 3456|       |
 3457|   935k|                     if (parse_ws_colon<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3457:26): [True: 835, False: 934k]
  ------------------
 3458|    835|                        return;
 3459|    835|                     }
 3460|       |
 3461|   934k|                     reading(ctx.scratch);
 3462|       |                     if constexpr (Opts.partial_read) {
 3463|       |                        if (read_count == value.size()) {
 3464|       |                           return;
 3465|       |                        }
 3466|       |                     }
 3467|   934k|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3467:26): [True: 22.3k, False: 912k]
  ------------------
 3468|  22.3k|                        return;
 3469|       |                  }
 3470|       |                  else if constexpr (str_t<Key>) {
 3471|       |                     Key key;
 3472|       |                     parse<JSON>::op<Opts>(key, ctx, it, end);
 3473|       |                     if (bool(ctx.error)) [[unlikely]]
 3474|       |                        return;
 3475|       |
 3476|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3477|       |                        return;
 3478|       |                     }
 3479|       |
 3480|       |                     reading(key);
 3481|       |                     if constexpr (Opts.partial_read) {
 3482|       |                        if (read_count == value.size()) {
 3483|       |                           return;
 3484|       |                        }
 3485|       |                     }
 3486|       |                     if (bool(ctx.error)) [[unlikely]]
 3487|       |                        return;
 3488|       |                  }
 3489|       |                  else {
 3490|       |                     Key key_value{};
 3491|       |                     if constexpr (is_named_enum<Key> || mimics_str_t<Key>) {
 3492|       |                        parse<JSON>::op<Opts>(key_value, ctx, it, end);
 3493|       |                     }
 3494|       |                     else if constexpr (std::is_arithmetic_v<Key>) {
 3495|       |                        // prefer over quoted_t below to avoid double parsing of quoted_t
 3496|       |                        parse<JSON>::op<opt_true<Opts, quoted_num_opt_tag{}>>(key_value, ctx, it, end);
 3497|       |                     }
 3498|       |                     else {
 3499|       |                        parse<JSON>::op<opt_false<Opts, raw_string_opt_tag{}>>(quoted_t<Key>{key_value}, ctx, it, end);
 3500|       |                     }
 3501|       |                     if (bool(ctx.error)) [[unlikely]]
 3502|       |                        return;
 3503|       |
 3504|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3505|       |                        return;
 3506|       |                     }
 3507|       |
 3508|       |                     reading(key_value);
 3509|       |                     if constexpr (Opts.partial_read) {
 3510|       |                        if (read_count == value.size()) {
 3511|       |                           return;
 3512|       |                        }
 3513|       |                     }
 3514|       |                     if (bool(ctx.error)) [[unlikely]]
 3515|       |                        return;
 3516|       |                  }
 3517|   937k|               }
 3518|       |
 3519|       |               // Streaming refill point: after parsing each key-value pair, refill if buffer is low
 3520|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 3521|       |                  if (ctx.stream.enabled()) {
 3522|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 3523|       |                     // Refill when less than 25% of buffer remains to ensure enough space for next element
 3524|       |                     if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 3525|       |                        const char* new_it;
 3526|       |                        const char* new_end;
 3527|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 3528|       |                        it = new_it;
 3529|       |                        end = new_end;
 3530|       |                        if (it >= end && ctx.stream.at_eof()) {
 3531|       |                           ctx.error = error_code::unexpected_end;
 3532|       |                           return;
 3533|       |                        }
 3534|       |                     }
 3535|       |                  }
 3536|       |               }
 3537|       |
 3538|   937k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3538:20): [True: 0, False: 937k]
  ------------------
 3539|      0|                  return;
 3540|      0|               }
 3541|   937k|            }
 3542|  27.9k|         }
 3543|  27.9k|      }
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj33EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlvE_clEv:
 3189|  27.9k|            decltype(auto) fields = [&]() -> decltype(auto) {
 3190|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 3191|       |                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 3192|       |                  return bit_array<num_members>{};
 3193|       |               }
 3194|  27.9k|               else {
 3195|  27.9k|                  return nullptr;
 3196|  27.9k|               }
 3197|  27.9k|            }();
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|   937k|      {
   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|   937k|         else {
   60|   937k|            using V = std::remove_cvref_t<T>;
   61|   937k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|   937k|                                             end);
   63|   937k|         }
   64|   937k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEQcl15check_is_paddedTL0__EEEvRT2_OT3_OT0_T1_:
  933|   937k|      {
  934|       |         if constexpr (check_string_as_number(Opts)) {
  935|       |            auto start = it;
  936|       |            skip_number<Opts>(ctx, it, end);
  937|       |            if (bool(ctx.error)) [[unlikely]] {
  938|       |               return;
  939|       |            }
  940|       |            value.append(start, size_t(it - start));
  941|       |         }
  942|   937k|         else {
  943|   937k|            if constexpr (!check_opening_handled(Opts)) {
  944|   937k|               if constexpr (!check_ws_handled(Opts)) {
  945|   937k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (945:23): [True: 0, False: 937k]
  ------------------
  946|      0|                     return;
  947|      0|                  }
  948|   937k|               }
  949|       |
  950|   937k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (950:20): [True: 320, False: 936k]
  ------------------
  951|    320|                  return;
  952|    320|               }
  953|   937k|            }
  954|       |
  955|   937k|            if constexpr (not check_raw_string(Opts)) {
  956|   937k|               static constexpr auto string_padding_bytes = 8;
  957|       |
  958|   937k|               auto start = it;
  959|   937k|               uint64_t ascii_acc{};
  960|  5.29M|               while (true) {
  ------------------
  |  Branch (960:23): [True: 5.29M, Folded]
  ------------------
  961|  5.29M|                  if (it >= end) [[unlikely]] {
  ------------------
  |  Branch (961:23): [True: 512, False: 5.29M]
  ------------------
  962|    512|                     ctx.error = error_code::unexpected_end;
  963|    512|                     return;
  964|    512|                  }
  965|       |
  966|  5.29M|                  uint64_t chunk;
  967|  5.29M|                  std::memcpy(&chunk, it, 8);
  968|       |                  if constexpr (std::endian::native == std::endian::big) {
  969|       |                     chunk = std::byteswap(chunk);
  970|       |                  }
  971|  5.29M|                  ascii_acc |= chunk;
  972|  5.29M|                  const uint64_t test_chars = has_quote(chunk);
  973|  5.29M|                  if (test_chars) {
  ------------------
  |  Branch (973:23): [True: 937k, False: 4.35M]
  ------------------
  974|   937k|                     it += (countr_zero(test_chars) >> 3);
  975|       |
  976|   937k|                     auto* prev = it - 1;
  977|   940k|                     while (*prev == '\\') {
  ------------------
  |  Branch (977:29): [True: 3.02k, False: 937k]
  ------------------
  978|  3.02k|                        --prev;
  979|  3.02k|                     }
  980|   937k|                     if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (980:26): [True: 936k, False: 1.46k]
  ------------------
  981|   936k|                        break;
  982|   936k|                     }
  983|  1.46k|                     ++it; // skip the escaped quote
  984|  1.46k|                  }
  985|  4.35M|                  else {
  986|  4.35M|                     it += 8;
  987|  4.35M|                  }
  988|  5.29M|               }
  989|       |
  990|   936k|               if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (990:20): [True: 379, False: 936k]
  ------------------
  991|    379|                  return;
  992|    379|               }
  993|       |
  994|   936k|               auto n = size_t(it - start);
  995|   936k|               value.resize(n + string_padding_bytes);
  996|       |
  997|   936k|               auto* p = value.data();
  998|       |
  999|  5.64M|               while (true) {
  ------------------
  |  Branch (999:23): [True: 5.64M, Folded]
  ------------------
 1000|  5.64M|                  if (start >= it) {
  ------------------
  |  Branch (1000:23): [True: 934k, False: 4.70M]
  ------------------
 1001|   934k|                     break;
 1002|   934k|                  }
 1003|       |
 1004|  4.70M|                  std::memcpy(p, start, 8);
 1005|  4.70M|                  uint64_t swar;
 1006|  4.70M|                  std::memcpy(&swar, p, 8);
 1007|       |                  if constexpr (std::endian::native == std::endian::big) {
 1008|       |                     swar = std::byteswap(swar);
 1009|       |                  }
 1010|       |
 1011|  4.70M|                  constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1012|  4.70M|                  const uint64_t lo7 = swar & lo7_mask;
 1013|  4.70M|                  const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1014|  4.70M|                  const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1015|  4.70M|                  uint64_t next = ~((backslash & less_32) | swar);
 1016|       |
 1017|  4.70M|                  next &= repeat_byte8(0b10000000);
 1018|  4.70M|                  if (next == 0) {
  ------------------
  |  Branch (1018:23): [True: 4.67M, False: 29.7k]
  ------------------
 1019|  4.67M|                     start += 8;
 1020|  4.67M|                     p += 8;
 1021|  4.67M|                     continue;
 1022|  4.67M|                  }
 1023|       |
 1024|  29.7k|                  next = countr_zero(next) >> 3;
 1025|  29.7k|                  start += next;
 1026|  29.7k|                  if (start >= it) {
  ------------------
  |  Branch (1026:23): [True: 1.44k, False: 28.3k]
  ------------------
 1027|  1.44k|                     break;
 1028|  1.44k|                  }
 1029|       |
 1030|  28.3k|                  if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1030:23): [True: 176, False: 28.1k]
  ------------------
 1031|    176|                     ctx.error = error_code::syntax_error;
 1032|    176|                     return;
 1033|    176|                  }
 1034|  28.1k|                  ++start; // skip the escape
 1035|  28.1k|                  if (*start == 'u') {
  ------------------
  |  Branch (1035:23): [True: 20.1k, False: 7.95k]
  ------------------
 1036|  20.1k|                     ++start;
 1037|  20.1k|                     p += next;
 1038|  20.1k|                     const auto mark = start;
 1039|  20.1k|                     const auto offset = handle_unicode_code_point(start, p, end);
 1040|  20.1k|                     if (offset == 0) [[unlikely]] {
  ------------------
  |  Branch (1040:26): [True: 151, False: 20.0k]
  ------------------
 1041|    151|                        ctx.error = error_code::unicode_escape_conversion_failure;
 1042|    151|                        return;
 1043|    151|                     }
 1044|  20.0k|                     n += offset;
 1045|       |                     // escape + u + unicode code points
 1046|  20.0k|                     n -= 2 + uint32_t(start - mark);
 1047|  20.0k|                  }
 1048|  7.95k|                  else {
 1049|  7.95k|                     p += next;
 1050|  7.95k|                     *p = char_unescape_table[uint8_t(*start)];
 1051|  7.95k|                     if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1051:26): [True: 34, False: 7.91k]
  ------------------
 1052|     34|                        ctx.error = error_code::invalid_escape;
 1053|     34|                        return;
 1054|     34|                     }
 1055|  7.91k|                     ++p;
 1056|  7.91k|                     ++start;
 1057|  7.91k|                     --n;
 1058|  7.91k|                  }
 1059|  28.1k|               }
 1060|       |
 1061|   936k|               value.resize(n);
 1062|   936k|               ++it;
 1063|       |            }
 1064|       |            else {
 1065|       |               // raw_string
 1066|       |               auto start = it;
 1067|       |               skip_string_view(ctx, it, end);
 1068|       |               if (bool(ctx.error)) [[unlikely]]
 1069|       |                  return;
 1070|       |
 1071|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1072|       |                  return;
 1073|       |               }
 1074|       |
 1075|       |               value.assign(start, size_t(it - start));
 1076|       |               ++it;
 1077|       |            }
 1078|   937k|         }
 1079|   937k|      }
_ZN3glz14parse_ws_colonITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT0_OT1_T2_:
  159|   935k|   {
  160|   935k|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (160:11): [True: 0, False: 935k]
  ------------------
  161|      0|         return true;
  162|      0|      }
  163|   935k|      if (match_invalid_end<':', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (163:11): [True: 835, False: 934k]
  ------------------
  164|    835|         return true;
  165|    835|      }
  166|   934k|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (166:11): [True: 0, False: 934k]
  ------------------
  167|      0|         return true;
  168|      0|      }
  169|   934k|      return false;
  170|   934k|   }
_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_:
 3434|   934k|                  auto reading = [&](auto&& key) {
 3435|       |                     if constexpr (Opts.partial_read) {
 3436|       |                        if (auto element = value.find(key); element != value.end()) {
 3437|       |                           ++read_count;
 3438|       |                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3439|       |                        }
 3440|       |                        else {
 3441|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3442|       |                        }
 3443|       |                     }
 3444|   934k|                     else {
 3445|   934k|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3446|   934k|                     }
 3447|   934k|                  };
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  2.70M|      {
   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.70M|         else {
   60|  2.70M|            using V = std::remove_cvref_t<T>;
   61|  2.70M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  2.70M|                                             end);
   63|  2.70M|         }
   64|  2.70M|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  2.70M|      {
  151|  2.70M|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  2.70M|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  2.70M|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  2.70M|      }
_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_:
 4093|  2.70M|      {
 4094|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 4095|       |            read_adjacent<Options>(value, ctx, it, end);
 4096|       |         }
 4097|  2.70M|         else {
 4098|  2.70M|            read_deduced<Options>(value, ctx, it, end);
 4099|  2.70M|         }
 4100|  2.70M|      }
_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_:
 4104|  2.70M|      {
 4105|  2.70M|         constexpr auto Opts = ws_handled_off<Options>();
 4106|  2.70M|         if constexpr (variant_is_auto_deducible<T>()) {
 4107|       |            if constexpr (not check_ws_handled(Options)) {
 4108|       |               if (skip_ws<Opts>(ctx, it, end)) {
 4109|       |                  return;
 4110|       |               }
 4111|       |            }
 4112|       |
 4113|  2.70M|            switch (*it) {
 4114|  1.29k|            case '\0':
  ------------------
  |  Branch (4114:13): [True: 1.29k, False: 2.69M]
  ------------------
 4115|  1.29k|               ctx.error = error_code::unexpected_end;
 4116|  1.29k|               return;
 4117|  23.2k|            case '{': {
  ------------------
  |  Branch (4117:13): [True: 23.2k, False: 2.67M]
  ------------------
 4118|       |               // This branch consumes the brace itself and hands the object to a reader with
 4119|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 4120|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 4121|       |               // the reader below.
 4122|  23.2k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (4122:20): [True: 4, False: 23.2k]
  ------------------
 4123|      4|                  return;
 4124|      4|               }
 4125|       |
 4126|  23.2k|               ++it;
 4127|       |               if constexpr (not Opts.null_terminated) {
 4128|       |                  if (it == end) [[unlikely]] {
 4129|       |                     ctx.error = error_code::unexpected_end;
 4130|       |                     return;
 4131|       |                  }
 4132|       |               }
 4133|  23.2k|               using type_counts = variant_type_count<T>;
 4134|  23.2k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 4135|       |               if constexpr (n_object_candidates < 1) {
 4136|       |                  ctx.error = error_code::no_matching_variant_type;
 4137|       |                  return;
 4138|       |               }
 4139|  23.2k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 4140|  23.2k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 4141|  23.2k|                  using V = std::variant_alternative_t<first_idx, T>;
 4142|  23.2k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4142:23): [True: 22.8k, False: 379]
  ------------------
 4143|  23.2k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 4144|  23.2k|                  return;
 4145|       |               }
 4146|       |               else {
 4147|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 4148|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 4149|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 4150|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 4151|       |
 4152|       |                  // Track if we've encountered a tag and what value it had
 4153|       |                  std::optional<size_t> tag_specified_index{};
 4154|       |
 4155|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 4156|       |                     return;
 4157|       |                  }
 4158|       |                  auto start = it;
 4159|       |                  bool first_key = true;
 4160|       |                  // Parse bifurcation for tagged variants:
 4161|       |                  //
 4162|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 4163|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 4164|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 4165|       |                  //
 4166|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 4167|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 4168|       |                  // it advances past the trailing comma so the object parser picks up at the
 4169|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 4170|       |                  //
 4171|       |                  // One exception: if the tag name is also a field on the resolved struct
 4172|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 4173|       |                  // the struct field. This override is applied inside each std::visit lambda.
 4174|       |                  auto position_after_tag = [&] {
 4175|       |                     if (first_key) {
 4176|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 4177|       |                     }
 4178|       |                     else {
 4179|       |                        it = start; // tag was not the first key, re-parse from the beginning
 4180|       |                     }
 4181|       |                  };
 4182|       |                  while (*it != '}') {
 4183|       |                     if (it != start) {
 4184|       |                        first_key = false;
 4185|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 4186|       |                           return;
 4187|       |                        }
 4188|       |                     }
 4189|       |
 4190|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4191|       |                        return;
 4192|       |                     }
 4193|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4194|       |                        return;
 4195|       |                     }
 4196|       |
 4197|       |                     auto* key_start = it;
 4198|       |                     skip_string_view(ctx, it, end);
 4199|       |                     if (bool(ctx.error)) [[unlikely]]
 4200|       |                        return;
 4201|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 4202|       |                        return;
 4203|       |                     const sv key = {key_start, size_t(it - key_start)};
 4204|       |
 4205|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 4206|       |                        return;
 4207|       |                     }
 4208|       |
 4209|       |                     if constexpr (deduction_key_count > 0) {
 4210|       |                        // We first check if a tag is defined and see if the key matches the tag
 4211|       |                        if constexpr (not tag_v<T>.empty()) {
 4212|       |                           if (key == tag_v<T>) {
 4213|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 4214|       |                                 return;
 4215|       |                              }
 4216|       |
 4217|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 4218|       |
 4219|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 4220|       |                              if constexpr (std::integral<id_type>) {
 4221|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4222|       |                              }
 4223|       |                              else {
 4224|       |                                 from<JSON, sv>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4225|       |                              }
 4226|       |                              if (bool(ctx.error)) [[unlikely]]
 4227|       |                                 return;
 4228|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4229|       |                                 return;
 4230|       |                              }
 4231|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4232|       |                                 ctx.error = error_code::syntax_error;
 4233|       |                                 return;
 4234|       |                              }
 4235|       |
 4236|       |                              size_t type_index;
 4237|       |                              if constexpr (std::integral<id_type>) {
 4238|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4239|       |                              }
 4240|       |                              else {
 4241|       |                                 type_index = variant_id_to_index<T>::op(
 4242|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4243|       |                              }
 4244|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4245|       |                                 // Check if the deduced types include the tag-specified type
 4246|       |                                 // If not, the tag doesn't match the fields
 4247|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4248|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4249|       |                                 // Check if the tag-specified type is still possible
 4250|       |                                 const bool type_is_possible = possible_types[type_index];
 4251|       |                                 if (!type_is_possible) {
 4252|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4253|       |                                    ctx.error = error_code::no_matching_variant_type;
 4254|       |                                    return;
 4255|       |                                 }
 4256|       |
 4257|       |                                 position_after_tag();
 4258|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4259|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4260|       |                                 std::visit(
 4261|       |                                    [&](auto&& v) {
 4262|       |                                       using V = std::decay_t<decltype(v)>;
 4263|       |                                       constexpr bool is_object =
 4264|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4265|       |                                       if constexpr (variant_unit_alternative<V>) {
 4266|       |                                          // A unit alternative carries no data; its object holds only the
 4267|       |                                          // discriminator. Consume that body through an empty reflected object so
 4268|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4269|       |                                          detail::variant_unit_body unit_body{};
 4270|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4271|       |                                                                                             tag_literal>(unit_body,
 4272|       |                                                                                                          ctx, it, end);
 4273|       |                                       }
 4274|       |                                       else if constexpr (is_object) {
 4275|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4276|       |                                             it = start; // tag is a struct field, must re-parse
 4277|       |                                          }
 4278|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4279|       |                                                                                                           end);
 4280|       |                                       }
 4281|       |                                       else if constexpr (is_memory_object<V>) {
 4282|       |                                          if (!v) {
 4283|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4284|       |                                                if constexpr (requires { v.emplace(); }) {
 4285|       |                                                   v.emplace();
 4286|       |                                                }
 4287|       |                                                else {
 4288|       |                                                   v = typename V::value_type{};
 4289|       |                                                }
 4290|       |                                             }
 4291|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4292|       |                                                v = std::make_unique<typename V::element_type>();
 4293|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4294|       |                                                v = std::make_shared<typename V::element_type>();
 4295|       |                                             else if constexpr (constructible<V>) {
 4296|       |                                                v = meta_construct_v<V>();
 4297|       |                                             }
 4298|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4299|       |                                                                can_allocate_raw_pointer<Opts,
 4300|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4301|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4302|       |                                                   return;
 4303|       |                                                }
 4304|       |                                             }
 4305|       |                                             else {
 4306|       |                                                ctx.error = error_code::invalid_nullable_read;
 4307|       |                                                return;
 4308|       |                                                // Cannot read into unset nullable that is not std::optional,
 4309|       |                                                // std::unique_ptr, or std::shared_ptr
 4310|       |                                             }
 4311|       |                                          }
 4312|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4313|       |                                             it = start; // tag is a struct field, must re-parse
 4314|       |                                          }
 4315|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4316|       |                                             *v, ctx, it, end);
 4317|       |                                       }
 4318|       |                                       else if constexpr (custom_read<V>) {
 4319|       |                                          // Custom handlers parse the remaining body themselves and do not
 4320|       |                                          // accept the tag template parameter; the tag was already consumed.
 4321|       |                                          // This only works when the tag was the first key. If it came later,
 4322|       |                                          // we were reset to the object start and the custom handler would
 4323|       |                                          // absorb the tag, so error rather than corrupt the value.
 4324|       |                                          if (it == start) {
 4325|       |                                             ctx.error = error_code::feature_not_supported;
 4326|       |                                             ctx.custom_error_message =
 4327|       |                                                "the tag must be the first key for a custom variant alternative";
 4328|       |                                             return;
 4329|       |                                          }
 4330|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4331|       |                                       }
 4332|       |                                    },
 4333|       |                                    value);
 4334|       |
 4335|       |                                 return; // we've decoded our target type
 4336|       |                              }
 4337|       |                              else [[unlikely]] {
 4338|       |                                 // Check if we have a default type (ids array shorter than variant)
 4339|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4340|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4341|       |                                 if constexpr (ids_size < variant_size) {
 4342|       |                                    // Use the first unlabeled type as the default
 4343|       |                                    const auto default_type_index = ids_size;
 4344|       |
 4345|       |                                    position_after_tag();
 4346|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4347|       |                                    if (value.index() != default_type_index)
 4348|       |                                       emplace_runtime_variant(value, default_type_index);
 4349|       |                                    std::visit(
 4350|       |                                       [&](auto&& v) {
 4351|       |                                          using V = std::decay_t<decltype(v)>;
 4352|       |                                          constexpr bool is_object =
 4353|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4354|       |                                          if constexpr (variant_unit_alternative<V>) {
 4355|       |                                             // A unit alternative carries no data; its object holds only the
 4356|       |                                             // discriminator. Consume that body through an empty reflected object so
 4357|       |                                             // unknown-key policy and terminator handling match every other
 4358|       |                                             // alternative.
 4359|       |                                             detail::variant_unit_body unit_body{};
 4360|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4361|       |                                                                                                tag_literal>(
 4362|       |                                                unit_body, ctx, it, end);
 4363|       |                                          }
 4364|       |                                          else if constexpr (is_object) {
 4365|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4366|       |                                                it = start; // tag is a struct field, must re-parse
 4367|       |                                             }
 4368|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4369|       |                                          }
 4370|       |                                          else if constexpr (is_memory_object<V>) {
 4371|       |                                             if (!v) {
 4372|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4373|       |                                                   if constexpr (requires { v.emplace(); }) {
 4374|       |                                                      v.emplace();
 4375|       |                                                   }
 4376|       |                                                   else {
 4377|       |                                                      v = typename V::value_type{};
 4378|       |                                                   }
 4379|       |                                                }
 4380|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4381|       |                                                   v = std::make_unique<typename V::element_type>();
 4382|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4383|       |                                                   v = std::make_shared<typename V::element_type>();
 4384|       |                                                else if constexpr (constructible<V>) {
 4385|       |                                                   v = meta_construct_v<V>();
 4386|       |                                                }
 4387|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4388|       |                                                                   can_allocate_raw_pointer<
 4389|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4390|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4391|       |                                                      return;
 4392|       |                                                   }
 4393|       |                                                }
 4394|       |                                                else {
 4395|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4396|       |                                                   return;
 4397|       |                                                }
 4398|       |                                             }
 4399|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4400|       |                                                it = start; // tag is a struct field, must re-parse
 4401|       |                                             }
 4402|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4403|       |                                                                                                              it, end);
 4404|       |                                          }
 4405|       |                                          else if constexpr (custom_read<V>) {
 4406|       |                                             // Custom handlers parse the remaining body themselves; this only
 4407|       |                                             // works when the tag was the first key (see above). If it came
 4408|       |                                             // later we were reset to the object start, so error rather than
 4409|       |                                             // let the custom handler absorb the tag.
 4410|       |                                             if (it == start) {
 4411|       |                                                ctx.error = error_code::feature_not_supported;
 4412|       |                                                ctx.custom_error_message =
 4413|       |                                                   "the tag must be the first key for a custom variant alternative";
 4414|       |                                                return;
 4415|       |                                             }
 4416|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4417|       |                                          }
 4418|       |                                       },
 4419|       |                                       value);
 4420|       |
 4421|       |                                    return;
 4422|       |                                 }
 4423|       |                                 else {
 4424|       |                                    ctx.error = error_code::no_matching_variant_type;
 4425|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4426|       |                                    return;
 4427|       |                                 }
 4428|       |                              }
 4429|       |                           }
 4430|       |                        }
 4431|       |
 4432|       |                        // Inline decode_hash lookup for variant deduction
 4433|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4434|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4435|       |                        const auto deduction_index =
 4436|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4437|       |                              key.data(), key.data() + key.size(), key.size());
 4438|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4439|       |                           [[likely]] {
 4440|       |                           possible_types &= deduction_bits[deduction_index];
 4441|       |                        }
 4442|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4443|       |                           ctx.error = error_code::unknown_key;
 4444|       |                           return;
 4445|       |                        }
 4446|       |                     }
 4447|       |                     else if constexpr (not tag_v<T>.empty()) {
 4448|       |                        // empty object case for variant, if there are no normal elements
 4449|       |                        if (key == tag_v<T>) {
 4450|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4451|       |                              return;
 4452|       |                           }
 4453|       |
 4454|       |                           std::string_view type_id{};
 4455|       |                           parse<JSON>::op<ws_handled<Opts>()>(type_id, ctx, it, end);
 4456|       |                           if (bool(ctx.error)) [[unlikely]]
 4457|       |                              return;
 4458|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4459|       |                              return;
 4460|       |                           }
 4461|       |
 4462|       |                           const auto type_index = variant_id_to_index<T>::op(
 4463|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4464|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4465|       |                              position_after_tag();
 4466|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4467|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4468|       |                           }
 4469|       |                           else {
 4470|       |                              // Check if we have a default type (ids array shorter than variant)
 4471|       |                              constexpr auto ids_size = ids_v<T>.size();
 4472|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4473|       |                              if constexpr (ids_size < variant_size) {
 4474|       |                                 // Use the first unlabeled type as the default
 4475|       |                                 position_after_tag();
 4476|       |                                 const auto default_index = ids_size;
 4477|       |                                 tag_specified_index = default_index; // Store the default type index
 4478|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4479|       |                              }
 4480|       |                              else {
 4481|       |                                 ctx.error = error_code::no_matching_variant_type;
 4482|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4483|       |                                 return;
 4484|       |                              }
 4485|       |                           }
 4486|       |                           // Parse the type (handles tag skipping and unknown keys)
 4487|       |                           std::visit(
 4488|       |                              [&](auto&& v) {
 4489|       |                                 using V = std::decay_t<decltype(v)>;
 4490|       |                                 if constexpr (custom_read<V>) {
 4491|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4492|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4493|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4494|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4495|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4496|       |                                    // into its value, so error here rather than corrupt the result.
 4497|       |                                    if (it == start) {
 4498|       |                                       ctx.error = error_code::feature_not_supported;
 4499|       |                                       ctx.custom_error_message =
 4500|       |                                          "the tag must be the first key for a custom variant alternative";
 4501|       |                                       return;
 4502|       |                                    }
 4503|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4504|       |                                 }
 4505|       |                                 else {
 4506|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4507|       |                                       it = start; // tag is a struct field, must re-parse
 4508|       |                                    }
 4509|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4510|       |                                 }
 4511|       |                              },
 4512|       |                              value);
 4513|       |                           return;
 4514|       |                        }
 4515|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4516|       |                           ctx.error = error_code::unknown_key;
 4517|       |                           return;
 4518|       |                        }
 4519|       |                        else {
 4520|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4521|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4522|       |                              return;
 4523|       |                           }
 4524|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4525|       |                           if (bool(ctx.error)) [[unlikely]]
 4526|       |                              return;
 4527|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4528|       |                              return;
 4529|       |                           }
 4530|       |                           continue; // Continue loop to find the tag
 4531|       |                        }
 4532|       |                     }
 4533|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4534|       |                        ctx.error = error_code::unknown_key;
 4535|       |                        return;
 4536|       |                     }
 4537|       |
 4538|       |                     auto matching_types = possible_types.popcount();
 4539|       |                     if (matching_types == 0) {
 4540|       |                        ctx.error = error_code::no_matching_variant_type;
 4541|       |                        return;
 4542|       |                     }
 4543|       |                     // Only short-circuit for variants without tags
 4544|       |                     else if constexpr (tag_v<T>.empty()) {
 4545|       |                        if (matching_types == 1) {
 4546|       |                           it = start;
 4547|       |                           const auto type_index = possible_types.countr_zero();
 4548|       |
 4549|       |                           if (value.index() != static_cast<size_t>(type_index))
 4550|       |                              emplace_runtime_variant(value, type_index);
 4551|       |                           std::visit(
 4552|       |                              [&](auto&& v) {
 4553|       |                                 using V = std::decay_t<decltype(v)>;
 4554|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4555|       |                                 if constexpr (variant_unit_alternative<V>) {
 4556|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4557|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4558|       |                                    // terminator handling match every other alternative.
 4559|       |                                    detail::variant_unit_body unit_body{};
 4560|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4561|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4562|       |                                                                                                    end);
 4563|       |                                 }
 4564|       |                                 else if constexpr (is_object) {
 4565|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4566|       |                                 }
 4567|       |                                 else if constexpr (is_memory_object<V>) {
 4568|       |                                    if (!v) {
 4569|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4570|       |                                          if constexpr (requires { v.emplace(); }) {
 4571|       |                                             v.emplace();
 4572|       |                                          }
 4573|       |                                          else {
 4574|       |                                             v = typename V::value_type{};
 4575|       |                                          }
 4576|       |                                       }
 4577|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4578|       |                                          v = std::make_unique<typename V::element_type>();
 4579|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4580|       |                                          v = std::make_shared<typename V::element_type>();
 4581|       |                                       else if constexpr (constructible<V>) {
 4582|       |                                          v = meta_construct_v<V>();
 4583|       |                                       }
 4584|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4585|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4586|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4587|       |                                             return;
 4588|       |                                          }
 4589|       |                                       }
 4590|       |                                       else {
 4591|       |                                          ctx.error = error_code::invalid_nullable_read;
 4592|       |                                          return;
 4593|       |                                          // Cannot read into unset nullable that is not std::optional,
 4594|       |                                          // std::unique_ptr, or std::shared_ptr
 4595|       |                                       }
 4596|       |                                    }
 4597|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4598|       |                                       *v, ctx, it, end);
 4599|       |                                 }
 4600|       |                                 else if constexpr (custom_read<V>) {
 4601|       |                                    // Custom handlers parse the remaining body themselves.
 4602|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4603|       |                                 }
 4604|       |                              },
 4605|       |                              value);
 4606|       |
 4607|       |                           return; // we've decoded our target type
 4608|       |                        }
 4609|       |                     }
 4610|       |                     // For tagged variants, continue processing to validate tags
 4611|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4612|       |                        return;
 4613|       |                     }
 4614|       |
 4615|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4616|       |                     if (bool(ctx.error)) [[unlikely]]
 4617|       |                        return;
 4618|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4619|       |                        return;
 4620|       |                     }
 4621|       |                  }
 4622|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4623|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4624|       |                     // After parsing all keys, check if we have multiple matching types
 4625|       |                     // If so, choose the one with the fewest fields
 4626|       |                     auto final_matching = possible_types.popcount();
 4627|       |                     if (final_matching == 0) {
 4628|       |                        ctx.error = error_code::no_matching_variant_type;
 4629|       |                     }
 4630|       |                     else if (final_matching == 1) {
 4631|       |                        // Single type remains after field deduction
 4632|       |                        const auto type_index = possible_types.countr_zero();
 4633|       |
 4634|       |                        // Validate against tag if one was specified
 4635|       |                        if (tag_specified_index.has_value() &&
 4636|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4637|       |                           ctx.error = error_code::no_matching_variant_type;
 4638|       |                           return;
 4639|       |                        }
 4640|       |
 4641|       |                        it = start;
 4642|       |                        if (value.index() != static_cast<size_t>(type_index))
 4643|       |                           emplace_runtime_variant(value, type_index);
 4644|       |                        std::visit(
 4645|       |                           [&](auto&& v) {
 4646|       |                              using V = std::decay_t<decltype(v)>;
 4647|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4648|       |                              if constexpr (variant_unit_alternative<V>) {
 4649|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4650|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4651|       |                                 // terminator handling match every other alternative.
 4652|       |                                 detail::variant_unit_body unit_body{};
 4653|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4654|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4655|       |                                                                                                 end);
 4656|       |                              }
 4657|       |                              else if constexpr (is_object) {
 4658|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4659|       |                              }
 4660|       |                              else if constexpr (is_memory_object<V>) {
 4661|       |                                 if (!v) {
 4662|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4663|       |                                       if constexpr (requires { v.emplace(); }) {
 4664|       |                                          v.emplace();
 4665|       |                                       }
 4666|       |                                       else {
 4667|       |                                          v = typename V::value_type{};
 4668|       |                                       }
 4669|       |                                    }
 4670|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4671|       |                                       v = std::make_unique<typename V::element_type>();
 4672|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4673|       |                                       v = std::make_shared<typename V::element_type>();
 4674|       |                                    else if constexpr (constructible<V>) {
 4675|       |                                       v = meta_construct_v<V>();
 4676|       |                                    }
 4677|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4678|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4679|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4680|       |                                          return;
 4681|       |                                       }
 4682|       |                                    }
 4683|       |                                    else {
 4684|       |                                       ctx.error = error_code::invalid_nullable_read;
 4685|       |                                       return;
 4686|       |                                    }
 4687|       |                                 }
 4688|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4689|       |                                                                                                               it, end);
 4690|       |                              }
 4691|       |                              else if constexpr (custom_read<V>) {
 4692|       |                                 // Custom handlers parse the remaining body themselves.
 4693|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4694|       |                              }
 4695|       |                           },
 4696|       |                           value);
 4697|       |                     }
 4698|       |                     else if (final_matching > 1) {
 4699|       |                        constexpr auto N = std::variant_size_v<T>;
 4700|       |
 4701|       |                        // Compile-time array of field counts for each variant type
 4702|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4703|       |                           return std::array<size_t, N> {
 4704|       |                              ([]<size_t J = I>() -> size_t {
 4705|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4706|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4707|       |                                    return reflect<V>::size;
 4708|       |                                 }
 4709|       |                                 else if constexpr (is_memory_object<V>) {
 4710|       |                                    using X = memory_type<V>;
 4711|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4712|       |                                       return reflect<X>::size;
 4713|       |                                    }
 4714|       |                                    else {
 4715|       |                                       return (std::numeric_limits<size_t>::max)();
 4716|       |                                    }
 4717|       |                                 }
 4718|       |                                 else {
 4719|       |                                    return (std::numeric_limits<size_t>::max)();
 4720|       |                                 }
 4721|       |                              }.template operator()<I>())...
 4722|       |                           };
 4723|       |                        }(std::make_index_sequence<N>{});
 4724|       |
 4725|       |                        // Find the type with minimum field count among the possible types
 4726|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4727|       |                        size_t chosen_index = N; // Invalid index initially
 4728|       |
 4729|       |                        for (size_t i = 0; i < N; ++i) {
 4730|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4731|       |                              min_fields = field_counts[i];
 4732|       |                              chosen_index = i;
 4733|       |                           }
 4734|       |                        }
 4735|       |
 4736|       |                        if (chosen_index < N) {
 4737|       |                           // Validate against tag if one was specified
 4738|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4739|       |                              ctx.error = error_code::no_matching_variant_type;
 4740|       |                              return;
 4741|       |                           }
 4742|       |
 4743|       |                           it = start;
 4744|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4745|       |                           std::visit(
 4746|       |                              [&](auto&& v) {
 4747|       |                                 using V = std::decay_t<decltype(v)>;
 4748|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4749|       |                                 if constexpr (variant_unit_alternative<V>) {
 4750|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4751|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4752|       |                                    // terminator handling match every other alternative.
 4753|       |                                    detail::variant_unit_body unit_body{};
 4754|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4755|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4756|       |                                                                                                    end);
 4757|       |                                 }
 4758|       |                                 else if constexpr (is_object) {
 4759|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4760|       |                                 }
 4761|       |                                 else if constexpr (is_memory_object<V>) {
 4762|       |                                    if (!v) {
 4763|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4764|       |                                          if constexpr (requires { v.emplace(); }) {
 4765|       |                                             v.emplace();
 4766|       |                                          }
 4767|       |                                          else {
 4768|       |                                             v = typename V::value_type{};
 4769|       |                                          }
 4770|       |                                       }
 4771|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4772|       |                                          v = std::make_unique<typename V::element_type>();
 4773|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4774|       |                                          v = std::make_shared<typename V::element_type>();
 4775|       |                                       else if constexpr (constructible<V>) {
 4776|       |                                          v = meta_construct_v<V>();
 4777|       |                                       }
 4778|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4779|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4780|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4781|       |                                             return;
 4782|       |                                          }
 4783|       |                                       }
 4784|       |                                       else {
 4785|       |                                          ctx.error = error_code::invalid_nullable_read;
 4786|       |                                          return;
 4787|       |                                       }
 4788|       |                                    }
 4789|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4790|       |                                       *v, ctx, it, end);
 4791|       |                                 }
 4792|       |                                 else if constexpr (custom_read<V>) {
 4793|       |                                    // Custom handlers parse the remaining body themselves.
 4794|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4795|       |                                 }
 4796|       |                              },
 4797|       |                              value);
 4798|       |                        }
 4799|       |                        else {
 4800|       |                           ctx.error = error_code::no_matching_variant_type;
 4801|       |                        }
 4802|       |                     }
 4803|       |                  }
 4804|       |                  else {
 4805|       |                     // For variants with 0 or 1 object types, use the original error handling
 4806|       |                     ctx.error = error_code::no_matching_variant_type;
 4807|       |                  }
 4808|       |               }
 4809|      0|               break;
 4810|  23.2k|            }
 4811|   643k|            case '[':
  ------------------
  |  Branch (4811:13): [True: 643k, False: 2.05M]
  ------------------
 4812|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4813|   643k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4814|   643k|               break;
 4815|  5.83k|            case '"': {
  ------------------
  |  Branch (4815:13): [True: 5.83k, False: 2.69M]
  ------------------
 4816|  5.83k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4817|  5.83k|               break;
 4818|  23.2k|            }
 4819|    873|            case 't':
  ------------------
  |  Branch (4819:13): [True: 873, False: 2.70M]
  ------------------
 4820|  1.16k|            case 'f': {
  ------------------
  |  Branch (4820:13): [True: 287, False: 2.70M]
  ------------------
 4821|  1.16k|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4822|  1.16k|               break;
 4823|    873|            }
 4824|    592|            case 'n':
  ------------------
  |  Branch (4824:13): [True: 592, False: 2.70M]
  ------------------
 4825|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4826|       |                  ctx.error = error_code::no_matching_variant_type;
 4827|       |               }
 4828|    592|               else {
 4829|    592|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4830|    592|                  using V = std::variant_alternative_t<first_idx, T>;
 4831|    592|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4831:23): [True: 202, False: 390]
  ------------------
 4832|    592|                  match<"null", Opts>(ctx, it, end);
 4833|    592|               }
 4834|    592|               break;
 4835|  2.02M|            default: {
  ------------------
  |  Branch (4835:13): [True: 2.02M, False: 675k]
  ------------------
 4836|       |               // Not bool, string, object, or array so must be number or null
 4837|  2.02M|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4838|  2.02M|            }
 4839|  2.70M|            }
 4840|       |         }
 4841|       |         else {
 4842|       |            // For non-auto-deducible variants, try each type until one succeeds
 4843|       |            constexpr auto N = std::variant_size_v<T>;
 4844|       |            bool parsed = false;
 4845|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4846|       |
 4847|       |            for_each<N>([&]<size_t I>() {
 4848|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4849|       |
 4850|       |               auto copy_it = it;
 4851|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4852|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4853|       |               const auto copy_depth = ctx.depth;
 4854|       |
 4855|       |               // Try parsing as this type
 4856|       |               if (value.index() != I) {
 4857|       |                  emplace_runtime_variant(value, I);
 4858|       |               }
 4859|       |
 4860|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4861|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4862|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4863|       |               }
 4864|       |
 4865|       |               if (!bool(ctx.error)) {
 4866|       |                  parsed = true;
 4867|       |               }
 4868|       |               else if constexpr (not Options.null_terminated) {
 4869|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4870|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4871|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4872|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4873|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4874|       |                     parsed = true;
 4875|       |                     ctx.error = error_code::none;
 4876|       |                  }
 4877|       |                  else {
 4878|       |                     // Reset for next attempt (unless this is the last type)
 4879|       |                     it = copy_it;
 4880|       |                     rewind_depth<Options>(ctx, copy_depth);
 4881|       |                     if constexpr (I + 1 < N) {
 4882|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4883|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4884|       |                        }
 4885|       |                     }
 4886|       |                  }
 4887|       |               }
 4888|       |               else {
 4889|       |                  // Reset for next attempt (unless this is the last type)
 4890|       |                  it = copy_it;
 4891|       |                  rewind_depth<Options>(ctx, copy_depth);
 4892|       |                  if constexpr (I + 1 < N) {
 4893|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4894|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4895|       |                     }
 4896|       |                  }
 4897|       |               }
 4898|       |            });
 4899|       |         }
 4900|  2.70M|      }
_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_:
 3765|   645k|      {
 3766|   645k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3767|       |
 3768|       |         if constexpr (category_count == 0) {
 3769|       |            ctx.error = error_code::no_matching_variant_type;
 3770|       |         }
 3771|   645k|         else {
 3772|   645k|            constexpr auto N = std::variant_size_v<Variant>;
 3773|   645k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3774|   645k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3775|       |
 3776|   645k|            bool found_match{};
 3777|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3778|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3779|       |            // so the budget stops it and the failure already in hand is reported.
 3780|   645k|            bool exhausted{};
 3781|       |
 3782|       |            // First pass: const glaze types in this category
 3783|       |            if constexpr (const_count > 0) {
 3784|       |               for_each<N>([&]<size_t I>() {
 3785|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3786|       |                     return;
 3787|       |                  }
 3788|       |                  using V = std::variant_alternative_t<I, Variant>;
 3789|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3790|       |                     // run time substitute to compare to const value
 3791|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3792|       |                     auto copy_it{it};
 3793|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3794|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3795|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3796|       |                     const auto copy_depth{ctx.depth};
 3797|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3798|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3799|       |                     if (substitute == const_value) {
 3800|       |                        found_match = true;
 3801|       |                        if (!std::holds_alternative<V>(value)) {
 3802|       |                           value = V{};
 3803|       |                        }
 3804|       |                     }
 3805|       |                     else {
 3806|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3807|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3808|       |                           exhausted = true;
 3809|       |                        }
 3810|       |                        if constexpr (not Options.null_terminated) {
 3811|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3812|       |                              ctx.error = error_code::none;
 3813|       |                           }
 3814|       |                        }
 3815|       |                        it = copy_it;
 3816|       |                        rewind_depth<Options>(ctx, copy_depth);
 3817|       |                     }
 3818|       |                  }
 3819|       |               });
 3820|       |               if (found_match) {
 3821|       |                  return;
 3822|       |               }
 3823|       |            }
 3824|       |
 3825|       |            // Second pass: non-const types in this category
 3826|   645k|            if constexpr (non_const_count > 0) {
 3827|       |               // Track position within matching types for "is last" check.
 3828|       |               // We iterate over all variant indices but only process matching types,
 3829|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3830|       |               // the loop index directly corresponded to position in filtered set).
 3831|       |               // This has negligible cost: one increment per matching type.
 3832|   645k|               size_t non_const_idx = 0;
 3833|       |
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3836|   645k|                     return;
 3837|   645k|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|   645k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|   645k|                     auto copy_it{it};
 3841|   645k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|   645k|                     if (!std::holds_alternative<V>(value)) {
 3843|   645k|                        value = V{};
 3844|   645k|                     }
 3845|   645k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|   645k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|   645k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|   645k|                     }
 3849|   645k|                     if (!bool(ctx.error)) {
 3850|   645k|                        found_match = true;
 3851|   645k|                     }
 3852|   645k|                     else if constexpr (not Options.null_terminated) {
 3853|   645k|                        constexpr bool is_complete_type =
 3854|   645k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|   645k|                        if constexpr (is_complete_type) {
 3857|   645k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|   645k|                              found_match = true;
 3859|   645k|                              ctx.error = error_code::none;
 3860|   645k|                           }
 3861|   645k|                           else {
 3862|   645k|                              it = copy_it;
 3863|   645k|                              rewind_depth<Options>(ctx, copy_depth);
 3864|   645k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|   645k|                                  not variant_alternative_exhausted(ctx)) {
 3866|   645k|                                 ctx.error = error_code::none;
 3867|   645k|                              }
 3868|   645k|                           }
 3869|   645k|                        }
 3870|   645k|                        else {
 3871|   645k|                           it = copy_it;
 3872|   645k|                           rewind_depth<Options>(ctx, copy_depth);
 3873|   645k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|   645k|                               not variant_alternative_exhausted(ctx)) {
 3875|   645k|                              ctx.error = error_code::none;
 3876|   645k|                           }
 3877|   645k|                        }
 3878|   645k|                     }
 3879|   645k|                     else {
 3880|   645k|                        it = copy_it;
 3881|   645k|                        rewind_depth<Options>(ctx, copy_depth);
 3882|   645k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|   645k|                            not variant_alternative_exhausted(ctx)) {
 3884|   645k|                           ctx.error = error_code::none;
 3885|   645k|                        }
 3886|   645k|                     }
 3887|   645k|                     ++non_const_idx;
 3888|   645k|                  }
 3889|   645k|               });
 3890|   645k|               if (!found_match) {
  ------------------
  |  Branch (3890:20): [True: 13.3k, False: 631k]
  ------------------
 3891|  13.3k|                  if constexpr (non_const_count == 1) {
 3892|       |                     // Keep the specific error from the single type we tried
 3893|       |                  }
 3894|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3895|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3896|       |                     ctx.error = error_code::no_matching_variant_type;
 3897|       |                  }
 3898|  13.3k|               }
 3899|       |            }
 3900|       |            else {
 3901|       |               ctx.error = error_code::no_matching_variant_type;
 3902|       |            }
 3903|   645k|         }
 3904|   645k|      }
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|   645k|               });
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|   645k|               });
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|   645k|               });
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|   645k|               });
_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:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 645k]
  |  Branch (3835:38): [True: 0, False: 645k]
  |  Branch (3835:51): [True: 0, False: 645k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|   645k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|   645k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|   645k|                     auto copy_it{it};
 3841|   645k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|   645k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3842:26): [True: 481k, False: 163k]
  ------------------
 3843|   481k|                        value = V{};
 3844|   481k|                     }
 3845|   645k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|   645k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3846:26): [True: 13.3k, False: 631k]
  |  Branch (3846:45): [True: 0, False: 13.3k]
  ------------------
 3847|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|      0|                     }
 3849|   645k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3849:26): [True: 631k, False: 13.3k]
  ------------------
 3850|   631k|                        found_match = true;
 3851|   631k|                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|  13.3k|                     else {
 3880|  13.3k|                        it = copy_it;
 3881|  13.3k|                        rewind_depth<Options>(ctx, copy_depth);
 3882|  13.3k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3882:29): [True: 0, False: 13.3k]
  |  Branch (3882:68): [True: 0, False: 0]
  ------------------
 3883|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3883:29): [True: 0, False: 0]
  ------------------
 3884|      0|                           ctx.error = error_code::none;
 3885|      0|                        }
 3886|  13.3k|                     }
 3887|   645k|                     ++non_const_idx;
 3888|   645k|                  }
 3889|   645k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERNSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS4_9allocatorIS9_EEEETkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
   49|   645k|      {
   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|   645k|         else {
   60|   645k|            using V = std::remove_cvref_t<T>;
   61|   645k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|   645k|                                             end);
   63|   645k|         }
   64|   645k|      }
_ZN3glz4fromILj10ENSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS1_9allocatorIS6_EEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERS9_TkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
 2349|   645k|      {
 2350|   645k|         constexpr auto Opts = ws_handled_off<Options>();
 2351|       |         if constexpr (!check_ws_handled(Options)) {
 2352|       |            if (skip_ws<Opts>(ctx, it, end)) {
 2353|       |               return;
 2354|       |            }
 2355|       |         }
 2356|       |
 2357|   645k|         if (match_invalid_end<'[', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2357:14): [True: 0, False: 645k]
  ------------------
 2358|      0|            return;
 2359|      0|         }
 2360|       |         // one nesting level (see enter_depth): counted in both modes so the limit binds,
 2361|       |         // released at each syntactic close below
 2362|   645k|         if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (2362:14): [True: 11, False: 645k]
  ------------------
 2363|     11|            return;
 2364|     11|         }
 2365|       |
 2366|   645k|         const auto ws_start = it;
 2367|   645k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2367:14): [True: 0, False: 645k]
  ------------------
 2368|      0|            return;
 2369|      0|         }
 2370|       |
 2371|   645k|         if (*it == ']') {
  ------------------
  |  Branch (2371:14): [True: 4.70k, False: 640k]
  ------------------
 2372|  4.70k|            --ctx.depth;
 2373|  4.70k|            ++it;
 2374|  4.70k|            if constexpr ((resizable<T> || is_inplace_vector<T>) && not check_append_arrays(Opts)) {
 2375|  4.70k|               value.clear();
 2376|       |
 2377|       |               if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2378|       |                  value.shrink_to_fit();
 2379|       |               }
 2380|  4.70k|            }
 2381|  4.70k|            return;
 2382|  4.70k|         }
 2383|       |
 2384|   640k|         const size_t ws_size = size_t(it - ws_start);
 2385|       |
 2386|   640k|         static constexpr bool should_append = (resizable<T> || is_inplace_vector<T>) && check_append_arrays(Opts);
  ------------------
  |  Branch (2386:49): [True: 640k, Folded]
  |  Branch (2386:65): [Folded, False: 0]
  |  Branch (2386:90): [Folded, False: 0]
  ------------------
 2387|   640k|         if constexpr (not should_append) {
 2388|   640k|            const auto n = value.size();
 2389|       |
 2390|   640k|            auto value_it = value.begin();
 2391|       |
 2392|   648k|            for (size_t i = 0; i < n; ++i) {
  ------------------
  |  Branch (2392:32): [True: 168k, False: 480k]
  ------------------
 2393|   168k|               parse<JSON>::op<ws_handled<Opts>()>(*value_it++, ctx, it, end);
 2394|   168k|               if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2394:20): [True: 830, False: 167k]
  ------------------
 2395|    830|                  return;
 2396|   167k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2396:20): [True: 0, False: 167k]
  ------------------
 2397|      0|                  return;
 2398|      0|               }
 2399|   167k|               if (*it == ',') {
  ------------------
  |  Branch (2399:20): [True: 7.93k, False: 159k]
  ------------------
 2400|  7.93k|                  ++it;
 2401|       |
 2402|  7.93k|                  if constexpr (!Opts.minified && !Opts.comments) {
 2403|  7.93k|                     if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2403:26): [True: 5.18k, False: 2.74k]
  |  Branch (2403:37): [True: 4.75k, False: 438]
  ------------------
 2404|  4.75k|                        skip_matching_ws(ws_start, it, ws_size);
 2405|  4.75k|                     }
 2406|  7.93k|                  }
 2407|       |
 2408|  7.93k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2408:23): [True: 0, False: 7.93k]
  ------------------
 2409|      0|                     return;
 2410|      0|                  }
 2411|  7.93k|               }
 2412|   159k|               else if (*it == ']') {
  ------------------
  |  Branch (2412:25): [True: 159k, False: 93]
  ------------------
 2413|   159k|                  --ctx.depth;
 2414|   159k|                  ++it;
 2415|   159k|                  if constexpr (erasable<T>) {
 2416|   159k|                     value.erase(value_it,
 2417|   159k|                                 value.end()); // use erase rather than resize for non-default constructible elements
 2418|       |
 2419|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2420|       |                        value.shrink_to_fit();
 2421|       |                     }
 2422|   159k|                  }
 2423|   159k|                  return;
 2424|   159k|               }
 2425|     93|               else [[unlikely]] {
 2426|     93|                  ctx.error = error_code::expected_bracket;
 2427|     93|                  return;
 2428|     93|               }
 2429|   167k|            }
 2430|   640k|         }
 2431|       |
 2432|       |         if constexpr (Opts.partial_read) {
 2433|       |            // partial_read stops early on a success path, so give the level back like the
 2434|       |            // syntactic-close paths do; otherwise it accumulates across reads sharing a context.
 2435|       |            --ctx.depth;
 2436|       |            return;
 2437|       |         }
 2438|   640k|         else {
 2439|       |            // growing
 2440|   640k|            if constexpr (emplace_backable<T> || has_try_emplace_back<T>) {
 2441|  1.75M|               while (it < end) {
  ------------------
  |  Branch (2441:23): [True: 1.59M, False: 160k]
  ------------------
 2442|       |                  // Streaming refill point: at start of each iteration, ensure buffer has data
 2443|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2444|       |                     if (ctx.stream.enabled()) {
 2445|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2446|       |                        const size_t remaining = ctx.stream.size() - consumed;
 2447|       |                        // Refill when less than half of buffer remains to ensure space for next element
 2448|       |                        if (remaining <= ctx.stream.size() / 2 || it >= end) {
 2449|       |                           const char* new_it;
 2450|       |                           const char* new_end;
 2451|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2452|       |                           it = new_it;
 2453|       |                           end = new_end;
 2454|       |                           if (it >= end && ctx.stream.at_eof()) {
 2455|       |                              break; // No more data, exit loop normally
 2456|       |                           }
 2457|       |                        }
 2458|       |                     }
 2459|       |                  }
 2460|       |
 2461|       |                  if constexpr (has_try_emplace_back<T>) {
 2462|       |                     if (value.try_emplace_back())
 2463|       |                        parse<JSON>::op<ws_handled<Opts>()>(value.back(), ctx, it, end);
 2464|       |                     else
 2465|       |                        ctx.error = error_code::exceeded_static_array_size;
 2466|       |                  }
 2467|  1.59M|                  else {
 2468|  1.59M|                     parse<JSON>::op<ws_handled<Opts>()>(value.emplace_back(), ctx, it, end);
 2469|  1.59M|                  }
 2470|       |
 2471|  1.59M|                  if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2471:23): [True: 11.4k, False: 1.58M]
  ------------------
 2472|  11.4k|                     return;
 2473|       |
 2474|       |                  // Streaming refill point: after parsing each element, refill if buffer is low
 2475|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2476|       |                     if (ctx.stream.enabled()) {
 2477|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2478|       |                        // Refill when less than 25% of buffer remains to ensure enough space for next element
 2479|       |                        if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 2480|       |                           const char* new_it;
 2481|       |                           const char* new_end;
 2482|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2483|       |                           it = new_it;
 2484|       |                           end = new_end;
 2485|       |                           if (it >= end && ctx.stream.at_eof()) {
 2486|       |                              ctx.error = error_code::unexpected_end;
 2487|       |                              return;
 2488|       |                           }
 2489|       |                        }
 2490|       |                     }
 2491|       |                  }
 2492|       |
 2493|  1.58M|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2493:23): [True: 0, False: 1.58M]
  ------------------
 2494|      0|                     return;
 2495|      0|                  }
 2496|  1.58M|                  if (*it == ',') [[likely]] {
  ------------------
  |  Branch (2496:23): [True: 1.11M, False: 468k]
  ------------------
 2497|  1.11M|                     ++it;
 2498|       |
 2499|  1.11M|                     if constexpr (!Opts.minified && !Opts.comments) {
 2500|  1.11M|                        if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2500:29): [True: 27.4k, False: 1.09M]
  |  Branch (2500:40): [True: 26.9k, False: 519]
  ------------------
 2501|  26.9k|                           skip_matching_ws(ws_start, it, ws_size);
 2502|  26.9k|                        }
 2503|  1.11M|                     }
 2504|       |
 2505|  1.11M|                     if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2505:26): [True: 0, False: 1.11M]
  ------------------
 2506|      0|                        return;
 2507|      0|                     }
 2508|  1.11M|                  }
 2509|   468k|                  else if (*it == ']') {
  ------------------
  |  Branch (2509:28): [True: 467k, False: 1.01k]
  ------------------
 2510|   467k|                     --ctx.depth;
 2511|   467k|                     ++it;
 2512|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2513|       |                        value.shrink_to_fit();
 2514|       |                     }
 2515|   467k|                     return;
 2516|   467k|                  }
 2517|  1.01k|                  else [[unlikely]] {
 2518|  1.01k|                     ctx.error = error_code::expected_bracket;
 2519|  1.01k|                     return;
 2520|  1.01k|                  }
 2521|  1.58M|               }
 2522|       |
 2523|       |               // A valid array always returns from inside the loop upon reaching ']'.
 2524|       |               // For a null-terminated buffer the loop can only exit here by falling
 2525|       |               // through when `it` reaches the terminator without a closing bracket,
 2526|       |               // which means the input was truncated (e.g. "[", "[1," or "[1,2,").
 2527|       |               // Non-null-terminated buffers surface this through skip_ws/depth
 2528|       |               // tracking (or the streaming refill break), so this guard is limited
 2529|       |               // to the null-terminated case.
 2530|   160k|               if constexpr (Opts.null_terminated) {
 2531|   160k|                  ctx.error = error_code::unexpected_end;
 2532|   160k|               }
 2533|       |            }
 2534|       |            else {
 2535|       |               ctx.error = error_code::exceeded_static_array_size;
 2536|       |            }
 2537|   640k|         }
 2538|   640k|      }
_ZN3glz12rewind_depthITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEETkNS_10is_contextENS_7contextEEEvRT0_j:
 3737|  15.8k|   {
 3738|  15.8k|      if (ctx.error == error_code::exceeded_max_recursive_depth) [[unlikely]] {
  ------------------
  |  Branch (3738:11): [True: 1.36k, False: 14.4k]
  ------------------
 3739|  1.36k|         return;
 3740|  1.36k|      }
 3741|  14.4k|      if constexpr (Opts.null_terminated) {
 3742|  14.4k|         ctx.depth = depth;
 3743|       |      }
 3744|       |      else {
 3745|       |         if (ctx.error != error_code::end_reached && ctx.error != error_code::unexpected_end) {
 3746|       |            ctx.depth = depth;
 3747|       |         }
 3748|       |      }
 3749|  14.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_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3834|   645k|               for_each<N>([&]<size_t I>() {
 3835|   645k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 631k, False: 13.3k]
  |  Branch (3835:38): [True: 0, False: 13.3k]
  |  Branch (3835:51): [True: 1.36k, False: 12.0k]
  ------------------
 3836|   632k|                     return;
 3837|   632k|                  }
 3838|  12.0k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  12.0k|               });
_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_:
 3765|  6.89k|      {
 3766|  6.89k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3767|       |
 3768|       |         if constexpr (category_count == 0) {
 3769|       |            ctx.error = error_code::no_matching_variant_type;
 3770|       |         }
 3771|  6.89k|         else {
 3772|  6.89k|            constexpr auto N = std::variant_size_v<Variant>;
 3773|  6.89k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3774|  6.89k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3775|       |
 3776|  6.89k|            bool found_match{};
 3777|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3778|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3779|       |            // so the budget stops it and the failure already in hand is reported.
 3780|  6.89k|            bool exhausted{};
 3781|       |
 3782|       |            // First pass: const glaze types in this category
 3783|       |            if constexpr (const_count > 0) {
 3784|       |               for_each<N>([&]<size_t I>() {
 3785|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3786|       |                     return;
 3787|       |                  }
 3788|       |                  using V = std::variant_alternative_t<I, Variant>;
 3789|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3790|       |                     // run time substitute to compare to const value
 3791|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3792|       |                     auto copy_it{it};
 3793|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3794|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3795|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3796|       |                     const auto copy_depth{ctx.depth};
 3797|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3798|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3799|       |                     if (substitute == const_value) {
 3800|       |                        found_match = true;
 3801|       |                        if (!std::holds_alternative<V>(value)) {
 3802|       |                           value = V{};
 3803|       |                        }
 3804|       |                     }
 3805|       |                     else {
 3806|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3807|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3808|       |                           exhausted = true;
 3809|       |                        }
 3810|       |                        if constexpr (not Options.null_terminated) {
 3811|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3812|       |                              ctx.error = error_code::none;
 3813|       |                           }
 3814|       |                        }
 3815|       |                        it = copy_it;
 3816|       |                        rewind_depth<Options>(ctx, copy_depth);
 3817|       |                     }
 3818|       |                  }
 3819|       |               });
 3820|       |               if (found_match) {
 3821|       |                  return;
 3822|       |               }
 3823|       |            }
 3824|       |
 3825|       |            // Second pass: non-const types in this category
 3826|  6.89k|            if constexpr (non_const_count > 0) {
 3827|       |               // Track position within matching types for "is last" check.
 3828|       |               // We iterate over all variant indices but only process matching types,
 3829|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3830|       |               // the loop index directly corresponded to position in filtered set).
 3831|       |               // This has negligible cost: one increment per matching type.
 3832|  6.89k|               size_t non_const_idx = 0;
 3833|       |
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3836|  6.89k|                     return;
 3837|  6.89k|                  }
 3838|  6.89k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  6.89k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  6.89k|                     auto copy_it{it};
 3841|  6.89k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  6.89k|                     if (!std::holds_alternative<V>(value)) {
 3843|  6.89k|                        value = V{};
 3844|  6.89k|                     }
 3845|  6.89k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  6.89k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|  6.89k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|  6.89k|                     }
 3849|  6.89k|                     if (!bool(ctx.error)) {
 3850|  6.89k|                        found_match = true;
 3851|  6.89k|                     }
 3852|  6.89k|                     else if constexpr (not Options.null_terminated) {
 3853|  6.89k|                        constexpr bool is_complete_type =
 3854|  6.89k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|  6.89k|                        if constexpr (is_complete_type) {
 3857|  6.89k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|  6.89k|                              found_match = true;
 3859|  6.89k|                              ctx.error = error_code::none;
 3860|  6.89k|                           }
 3861|  6.89k|                           else {
 3862|  6.89k|                              it = copy_it;
 3863|  6.89k|                              rewind_depth<Options>(ctx, copy_depth);
 3864|  6.89k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|  6.89k|                                  not variant_alternative_exhausted(ctx)) {
 3866|  6.89k|                                 ctx.error = error_code::none;
 3867|  6.89k|                              }
 3868|  6.89k|                           }
 3869|  6.89k|                        }
 3870|  6.89k|                        else {
 3871|  6.89k|                           it = copy_it;
 3872|  6.89k|                           rewind_depth<Options>(ctx, copy_depth);
 3873|  6.89k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|  6.89k|                               not variant_alternative_exhausted(ctx)) {
 3875|  6.89k|                              ctx.error = error_code::none;
 3876|  6.89k|                           }
 3877|  6.89k|                        }
 3878|  6.89k|                     }
 3879|  6.89k|                     else {
 3880|  6.89k|                        it = copy_it;
 3881|  6.89k|                        rewind_depth<Options>(ctx, copy_depth);
 3882|  6.89k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|  6.89k|                            not variant_alternative_exhausted(ctx)) {
 3884|  6.89k|                           ctx.error = error_code::none;
 3885|  6.89k|                        }
 3886|  6.89k|                     }
 3887|  6.89k|                     ++non_const_idx;
 3888|  6.89k|                  }
 3889|  6.89k|               });
 3890|  6.89k|               if (!found_match) {
  ------------------
  |  Branch (3890:20): [True: 824, False: 6.07k]
  ------------------
 3891|    824|                  if constexpr (non_const_count == 1) {
 3892|       |                     // Keep the specific error from the single type we tried
 3893|       |                  }
 3894|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3895|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3896|       |                     ctx.error = error_code::no_matching_variant_type;
 3897|       |                  }
 3898|    824|               }
 3899|       |            }
 3900|       |            else {
 3901|       |               ctx.error = error_code::no_matching_variant_type;
 3902|       |            }
 3903|  6.89k|         }
 3904|  6.89k|      }
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 6.89k]
  |  Branch (3835:38): [True: 0, False: 6.89k]
  |  Branch (3835:51): [True: 0, False: 6.89k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  6.89k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  6.89k|               });
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 6.89k]
  |  Branch (3835:38): [True: 0, False: 6.89k]
  |  Branch (3835:51): [True: 0, False: 6.89k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  6.89k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  6.89k|               });
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 6.89k]
  |  Branch (3835:38): [True: 0, False: 6.89k]
  |  Branch (3835:51): [True: 0, False: 6.89k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  6.89k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  6.89k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  6.89k|                     auto copy_it{it};
 3841|  6.89k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  6.89k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3842:26): [True: 5.49k, False: 1.40k]
  ------------------
 3843|  5.49k|                        value = V{};
 3844|  5.49k|                     }
 3845|  6.89k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  6.89k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3846:26): [True: 824, False: 6.07k]
  |  Branch (3846:45): [True: 0, False: 824]
  ------------------
 3847|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|      0|                     }
 3849|  6.89k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3849:26): [True: 6.07k, False: 824]
  ------------------
 3850|  6.07k|                        found_match = true;
 3851|  6.07k|                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|    824|                     else {
 3880|    824|                        it = copy_it;
 3881|    824|                        rewind_depth<Options>(ctx, copy_depth);
 3882|    824|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3882:29): [True: 0, False: 824]
  |  Branch (3882:68): [True: 0, False: 0]
  ------------------
 3883|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3883:29): [True: 0, False: 0]
  ------------------
 3884|      0|                           ctx.error = error_code::none;
 3885|      0|                        }
 3886|    824|                     }
 3887|  6.89k|                     ++non_const_idx;
 3888|  6.89k|                  }
 3889|  6.89k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|  6.89k|      {
   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.89k|         else {
   60|  6.89k|            using V = std::remove_cvref_t<T>;
   61|  6.89k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  6.89k|                                             end);
   63|  6.89k|         }
   64|  6.89k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEQcl15check_is_paddedTL0__EEEvRT2_OT3_OT0_T1_:
  933|  6.89k|      {
  934|       |         if constexpr (check_string_as_number(Opts)) {
  935|       |            auto start = it;
  936|       |            skip_number<Opts>(ctx, it, end);
  937|       |            if (bool(ctx.error)) [[unlikely]] {
  938|       |               return;
  939|       |            }
  940|       |            value.append(start, size_t(it - start));
  941|       |         }
  942|  6.89k|         else {
  943|  6.89k|            if constexpr (!check_opening_handled(Opts)) {
  944|       |               if constexpr (!check_ws_handled(Opts)) {
  945|       |                  if (skip_ws<Opts>(ctx, it, end)) {
  946|       |                     return;
  947|       |                  }
  948|       |               }
  949|       |
  950|  6.89k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (950:20): [True: 0, False: 6.89k]
  ------------------
  951|      0|                  return;
  952|      0|               }
  953|  6.89k|            }
  954|       |
  955|  6.89k|            if constexpr (not check_raw_string(Opts)) {
  956|  6.89k|               static constexpr auto string_padding_bytes = 8;
  957|       |
  958|  6.89k|               auto start = it;
  959|  6.89k|               uint64_t ascii_acc{};
  960|  1.61M|               while (true) {
  ------------------
  |  Branch (960:23): [True: 1.61M, Folded]
  ------------------
  961|  1.61M|                  if (it >= end) [[unlikely]] {
  ------------------
  |  Branch (961:23): [True: 275, False: 1.61M]
  ------------------
  962|    275|                     ctx.error = error_code::unexpected_end;
  963|    275|                     return;
  964|    275|                  }
  965|       |
  966|  1.61M|                  uint64_t chunk;
  967|  1.61M|                  std::memcpy(&chunk, it, 8);
  968|       |                  if constexpr (std::endian::native == std::endian::big) {
  969|       |                     chunk = std::byteswap(chunk);
  970|       |                  }
  971|  1.61M|                  ascii_acc |= chunk;
  972|  1.61M|                  const uint64_t test_chars = has_quote(chunk);
  973|  1.61M|                  if (test_chars) {
  ------------------
  |  Branch (973:23): [True: 8.69k, False: 1.60M]
  ------------------
  974|  8.69k|                     it += (countr_zero(test_chars) >> 3);
  975|       |
  976|  8.69k|                     auto* prev = it - 1;
  977|  12.3k|                     while (*prev == '\\') {
  ------------------
  |  Branch (977:29): [True: 3.60k, False: 8.69k]
  ------------------
  978|  3.60k|                        --prev;
  979|  3.60k|                     }
  980|  8.69k|                     if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (980:26): [True: 6.62k, False: 2.07k]
  ------------------
  981|  6.62k|                        break;
  982|  6.62k|                     }
  983|  2.07k|                     ++it; // skip the escaped quote
  984|  2.07k|                  }
  985|  1.60M|                  else {
  986|  1.60M|                     it += 8;
  987|  1.60M|                  }
  988|  1.61M|               }
  989|       |
  990|  6.62k|               if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (990:20): [True: 255, False: 6.36k]
  ------------------
  991|    255|                  return;
  992|    255|               }
  993|       |
  994|  6.36k|               auto n = size_t(it - start);
  995|  6.36k|               value.resize(n + string_padding_bytes);
  996|       |
  997|  6.36k|               auto* p = value.data();
  998|       |
  999|   133k|               while (true) {
  ------------------
  |  Branch (999:23): [True: 133k, Folded]
  ------------------
 1000|   133k|                  if (start >= it) {
  ------------------
  |  Branch (1000:23): [True: 5.58k, False: 127k]
  ------------------
 1001|  5.58k|                     break;
 1002|  5.58k|                  }
 1003|       |
 1004|   127k|                  std::memcpy(p, start, 8);
 1005|   127k|                  uint64_t swar;
 1006|   127k|                  std::memcpy(&swar, p, 8);
 1007|       |                  if constexpr (std::endian::native == std::endian::big) {
 1008|       |                     swar = std::byteswap(swar);
 1009|       |                  }
 1010|       |
 1011|   127k|                  constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1012|   127k|                  const uint64_t lo7 = swar & lo7_mask;
 1013|   127k|                  const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1014|   127k|                  const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1015|   127k|                  uint64_t next = ~((backslash & less_32) | swar);
 1016|       |
 1017|   127k|                  next &= repeat_byte8(0b10000000);
 1018|   127k|                  if (next == 0) {
  ------------------
  |  Branch (1018:23): [True: 123k, False: 4.44k]
  ------------------
 1019|   123k|                     start += 8;
 1020|   123k|                     p += 8;
 1021|   123k|                     continue;
 1022|   123k|                  }
 1023|       |
 1024|  4.44k|                  next = countr_zero(next) >> 3;
 1025|  4.44k|                  start += next;
 1026|  4.44k|                  if (start >= it) {
  ------------------
  |  Branch (1026:23): [True: 488, False: 3.96k]
  ------------------
 1027|    488|                     break;
 1028|    488|                  }
 1029|       |
 1030|  3.96k|                  if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1030:23): [True: 97, False: 3.86k]
  ------------------
 1031|     97|                     ctx.error = error_code::syntax_error;
 1032|     97|                     return;
 1033|     97|                  }
 1034|  3.86k|                  ++start; // skip the escape
 1035|  3.86k|                  if (*start == 'u') {
  ------------------
  |  Branch (1035:23): [True: 2.41k, False: 1.44k]
  ------------------
 1036|  2.41k|                     ++start;
 1037|  2.41k|                     p += next;
 1038|  2.41k|                     const auto mark = start;
 1039|  2.41k|                     const auto offset = handle_unicode_code_point(start, p, end);
 1040|  2.41k|                     if (offset == 0) [[unlikely]] {
  ------------------
  |  Branch (1040:26): [True: 162, False: 2.25k]
  ------------------
 1041|    162|                        ctx.error = error_code::unicode_escape_conversion_failure;
 1042|    162|                        return;
 1043|    162|                     }
 1044|  2.25k|                     n += offset;
 1045|       |                     // escape + u + unicode code points
 1046|  2.25k|                     n -= 2 + uint32_t(start - mark);
 1047|  2.25k|                  }
 1048|  1.44k|                  else {
 1049|  1.44k|                     p += next;
 1050|  1.44k|                     *p = char_unescape_table[uint8_t(*start)];
 1051|  1.44k|                     if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1051:26): [True: 35, False: 1.41k]
  ------------------
 1052|     35|                        ctx.error = error_code::invalid_escape;
 1053|     35|                        return;
 1054|     35|                     }
 1055|  1.41k|                     ++p;
 1056|  1.41k|                     ++start;
 1057|  1.41k|                     --n;
 1058|  1.41k|                  }
 1059|  3.86k|               }
 1060|       |
 1061|  6.07k|               value.resize(n);
 1062|  6.07k|               ++it;
 1063|       |            }
 1064|       |            else {
 1065|       |               // raw_string
 1066|       |               auto start = it;
 1067|       |               skip_string_view(ctx, it, end);
 1068|       |               if (bool(ctx.error)) [[unlikely]]
 1069|       |                  return;
 1070|       |
 1071|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1072|       |                  return;
 1073|       |               }
 1074|       |
 1075|       |               value.assign(start, size_t(it - start));
 1076|       |               ++it;
 1077|       |            }
 1078|  6.89k|         }
 1079|  6.89k|      }
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 6.07k, False: 824]
  |  Branch (3835:38): [True: 0, False: 824]
  |  Branch (3835:51): [True: 0, False: 824]
  ------------------
 3836|  6.07k|                     return;
 3837|  6.07k|                  }
 3838|    824|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    824|               });
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 6.07k, False: 824]
  |  Branch (3835:38): [True: 0, False: 824]
  |  Branch (3835:51): [True: 0, False: 824]
  ------------------
 3836|  6.07k|                     return;
 3837|  6.07k|                  }
 3838|    824|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    824|               });
_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:
 3834|  6.89k|               for_each<N>([&]<size_t I>() {
 3835|  6.89k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 6.07k, False: 824]
  |  Branch (3835:38): [True: 0, False: 824]
  |  Branch (3835:51): [True: 0, False: 824]
  ------------------
 3836|  6.07k|                     return;
 3837|  6.07k|                  }
 3838|    824|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    824|               });
_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_:
 3765|  1.34k|      {
 3766|  1.34k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3767|       |
 3768|       |         if constexpr (category_count == 0) {
 3769|       |            ctx.error = error_code::no_matching_variant_type;
 3770|       |         }
 3771|  1.34k|         else {
 3772|  1.34k|            constexpr auto N = std::variant_size_v<Variant>;
 3773|  1.34k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3774|  1.34k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3775|       |
 3776|  1.34k|            bool found_match{};
 3777|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3778|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3779|       |            // so the budget stops it and the failure already in hand is reported.
 3780|  1.34k|            bool exhausted{};
 3781|       |
 3782|       |            // First pass: const glaze types in this category
 3783|       |            if constexpr (const_count > 0) {
 3784|       |               for_each<N>([&]<size_t I>() {
 3785|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3786|       |                     return;
 3787|       |                  }
 3788|       |                  using V = std::variant_alternative_t<I, Variant>;
 3789|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3790|       |                     // run time substitute to compare to const value
 3791|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3792|       |                     auto copy_it{it};
 3793|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3794|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3795|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3796|       |                     const auto copy_depth{ctx.depth};
 3797|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3798|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3799|       |                     if (substitute == const_value) {
 3800|       |                        found_match = true;
 3801|       |                        if (!std::holds_alternative<V>(value)) {
 3802|       |                           value = V{};
 3803|       |                        }
 3804|       |                     }
 3805|       |                     else {
 3806|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3807|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3808|       |                           exhausted = true;
 3809|       |                        }
 3810|       |                        if constexpr (not Options.null_terminated) {
 3811|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3812|       |                              ctx.error = error_code::none;
 3813|       |                           }
 3814|       |                        }
 3815|       |                        it = copy_it;
 3816|       |                        rewind_depth<Options>(ctx, copy_depth);
 3817|       |                     }
 3818|       |                  }
 3819|       |               });
 3820|       |               if (found_match) {
 3821|       |                  return;
 3822|       |               }
 3823|       |            }
 3824|       |
 3825|       |            // Second pass: non-const types in this category
 3826|  1.34k|            if constexpr (non_const_count > 0) {
 3827|       |               // Track position within matching types for "is last" check.
 3828|       |               // We iterate over all variant indices but only process matching types,
 3829|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3830|       |               // the loop index directly corresponded to position in filtered set).
 3831|       |               // This has negligible cost: one increment per matching type.
 3832|  1.34k|               size_t non_const_idx = 0;
 3833|       |
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3836|  1.34k|                     return;
 3837|  1.34k|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  1.34k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  1.34k|                     auto copy_it{it};
 3841|  1.34k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  1.34k|                     if (!std::holds_alternative<V>(value)) {
 3843|  1.34k|                        value = V{};
 3844|  1.34k|                     }
 3845|  1.34k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  1.34k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|  1.34k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|  1.34k|                     }
 3849|  1.34k|                     if (!bool(ctx.error)) {
 3850|  1.34k|                        found_match = true;
 3851|  1.34k|                     }
 3852|  1.34k|                     else if constexpr (not Options.null_terminated) {
 3853|  1.34k|                        constexpr bool is_complete_type =
 3854|  1.34k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|  1.34k|                        if constexpr (is_complete_type) {
 3857|  1.34k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|  1.34k|                              found_match = true;
 3859|  1.34k|                              ctx.error = error_code::none;
 3860|  1.34k|                           }
 3861|  1.34k|                           else {
 3862|  1.34k|                              it = copy_it;
 3863|  1.34k|                              rewind_depth<Options>(ctx, copy_depth);
 3864|  1.34k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|  1.34k|                                  not variant_alternative_exhausted(ctx)) {
 3866|  1.34k|                                 ctx.error = error_code::none;
 3867|  1.34k|                              }
 3868|  1.34k|                           }
 3869|  1.34k|                        }
 3870|  1.34k|                        else {
 3871|  1.34k|                           it = copy_it;
 3872|  1.34k|                           rewind_depth<Options>(ctx, copy_depth);
 3873|  1.34k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|  1.34k|                               not variant_alternative_exhausted(ctx)) {
 3875|  1.34k|                              ctx.error = error_code::none;
 3876|  1.34k|                           }
 3877|  1.34k|                        }
 3878|  1.34k|                     }
 3879|  1.34k|                     else {
 3880|  1.34k|                        it = copy_it;
 3881|  1.34k|                        rewind_depth<Options>(ctx, copy_depth);
 3882|  1.34k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|  1.34k|                            not variant_alternative_exhausted(ctx)) {
 3884|  1.34k|                           ctx.error = error_code::none;
 3885|  1.34k|                        }
 3886|  1.34k|                     }
 3887|  1.34k|                     ++non_const_idx;
 3888|  1.34k|                  }
 3889|  1.34k|               });
 3890|  1.34k|               if (!found_match) {
  ------------------
  |  Branch (3890:20): [True: 235, False: 1.10k]
  ------------------
 3891|    235|                  if constexpr (non_const_count == 1) {
 3892|       |                     // Keep the specific error from the single type we tried
 3893|       |                  }
 3894|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3895|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3896|       |                     ctx.error = error_code::no_matching_variant_type;
 3897|       |                  }
 3898|    235|               }
 3899|       |            }
 3900|       |            else {
 3901|       |               ctx.error = error_code::no_matching_variant_type;
 3902|       |            }
 3903|  1.34k|         }
 3904|  1.34k|      }
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  1.34k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  1.34k|                     auto copy_it{it};
 3841|  1.34k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  1.34k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3842:26): [True: 1.13k, False: 209]
  ------------------
 3843|  1.13k|                        value = V{};
 3844|  1.13k|                     }
 3845|  1.34k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  1.34k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3846:26): [True: 235, False: 1.10k]
  |  Branch (3846:45): [True: 0, False: 235]
  ------------------
 3847|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|      0|                     }
 3849|  1.34k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3849:26): [True: 1.10k, False: 235]
  ------------------
 3850|  1.10k|                        found_match = true;
 3851|  1.10k|                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|    235|                     else {
 3880|    235|                        it = copy_it;
 3881|    235|                        rewind_depth<Options>(ctx, copy_depth);
 3882|    235|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3882:29): [True: 0, False: 235]
  |  Branch (3882:68): [True: 0, False: 0]
  ------------------
 3883|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3883:29): [True: 0, False: 0]
  ------------------
 3884|      0|                           ctx.error = error_code::none;
 3885|      0|                        }
 3886|    235|                     }
 3887|  1.34k|                     ++non_const_idx;
 3888|  1.34k|                  }
 3889|  1.34k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  1.34k|      {
   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.34k|         else {
   60|  1.34k|            using V = std::remove_cvref_t<T>;
   61|  1.34k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  1.34k|                                             end);
   63|  1.34k|         }
   64|  1.34k|      }
_ZN3glz4fromILj10EbE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEETkNS_6bool_tERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
  710|  1.34k|      {
  711|       |         if constexpr (check_quoted_num(Opts)) {
  712|       |            if (skip_ws<Opts>(ctx, it, end)) {
  713|       |               return;
  714|       |            }
  715|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  716|       |               return;
  717|       |            }
  718|       |         }
  719|       |
  720|       |         if constexpr (!check_ws_handled(Opts)) {
  721|       |            if (skip_ws<Opts>(ctx, it, end)) {
  722|       |               return;
  723|       |            }
  724|       |         }
  725|       |
  726|       |         if constexpr (check_bools_as_numbers(Opts)) {
  727|       |            if (*it == '1') {
  728|       |               value = true;
  729|       |               ++it;
  730|       |            }
  731|       |            else if (*it == '0') {
  732|       |               value = false;
  733|       |               ++it;
  734|       |            }
  735|       |            else {
  736|       |               ctx.error = error_code::syntax_error;
  737|       |               return;
  738|       |            }
  739|       |         }
  740|  1.34k|         else {
  741|       |            if constexpr (not check_is_padded(Opts)) {
  742|       |               if (size_t(end - it) < 4) [[unlikely]] {
  743|       |                  ctx.error = error_code::expected_true_or_false;
  744|       |                  return;
  745|       |               }
  746|       |            }
  747|       |
  748|  1.34k|            uint32_t c;
  749|  1.34k|            static constexpr uint32_t u_true = 0b01100101'01110101'01110010'01110100;
  750|  1.34k|            static constexpr uint32_t u_fals = 0b01110011'01101100'01100001'01100110;
  751|  1.34k|            std::memcpy(&c, it, 4);
  752|       |            if constexpr (std::endian::native == std::endian::big) {
  753|       |               c = std::byteswap(c);
  754|       |            }
  755|  1.34k|            it += 4;
  756|  1.34k|            if (c == u_true) {
  ------------------
  |  Branch (756:17): [True: 847, False: 493]
  ------------------
  757|    847|               value = true;
  758|    847|            }
  759|    493|            else if (it == end) [[unlikely]] {
  ------------------
  |  Branch (759:22): [True: 26, False: 467]
  ------------------
  760|     26|               ctx.error = error_code::unexpected_end;
  761|     26|               return;
  762|     26|            }
  763|    467|            else {
  764|    467|               if (c == u_fals && (*it == 'e')) [[likely]] {
  ------------------
  |  Branch (764:20): [True: 275, False: 192]
  |  Branch (764:35): [True: 258, False: 17]
  ------------------
  765|    258|                  value = false;
  766|    258|                  ++it;
  767|    258|               }
  768|    209|               else [[unlikely]] {
  769|    209|                  ctx.error = error_code::expected_true_or_false;
  770|    209|                  return;
  771|    209|               }
  772|    467|            }
  773|  1.34k|         }
  774|       |
  775|       |         if constexpr (check_quoted_num(Opts)) {
  776|       |            if constexpr (not Opts.null_terminated) {
  777|       |               if (it == end) [[unlikely]] {
  778|       |                  ctx.error = error_code::unexpected_end;
  779|       |                  return;
  780|       |               }
  781|       |            }
  782|       |            if (match<'"'>(ctx, it)) {
  783|       |               return;
  784|       |            }
  785|       |            if constexpr (not Opts.null_terminated) {
  786|       |               if (it == end) {
  787|       |                  ctx.error = error_code::end_reached;
  788|       |                  return;
  789|       |               }
  790|       |            }
  791|       |         }
  792|  1.34k|         else {
  793|       |            if constexpr (not Opts.null_terminated) {
  794|       |               if (it == end) {
  795|       |                  ctx.error = error_code::end_reached;
  796|       |                  return;
  797|       |               }
  798|       |            }
  799|  1.34k|         }
  800|  1.34k|      }
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 1.10k, False: 235]
  |  Branch (3835:38): [True: 0, False: 235]
  |  Branch (3835:51): [True: 0, False: 235]
  ------------------
 3836|  1.10k|                     return;
 3837|  1.10k|                  }
 3838|    235|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    235|               });
_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:
 3834|  1.34k|               for_each<N>([&]<size_t I>() {
 3835|  1.34k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 1.10k, False: 235]
  |  Branch (3835:38): [True: 0, False: 235]
  |  Branch (3835:51): [True: 0, False: 235]
  ------------------
 3836|  1.10k|                     return;
 3837|  1.10k|                  }
 3838|    235|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|    235|               });
_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_:
 3765|  2.02M|      {
 3766|  2.02M|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3767|       |
 3768|       |         if constexpr (category_count == 0) {
 3769|       |            ctx.error = error_code::no_matching_variant_type;
 3770|       |         }
 3771|  2.02M|         else {
 3772|  2.02M|            constexpr auto N = std::variant_size_v<Variant>;
 3773|  2.02M|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3774|  2.02M|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3775|       |
 3776|  2.02M|            bool found_match{};
 3777|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3778|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3779|       |            // so the budget stops it and the failure already in hand is reported.
 3780|  2.02M|            bool exhausted{};
 3781|       |
 3782|       |            // First pass: const glaze types in this category
 3783|       |            if constexpr (const_count > 0) {
 3784|       |               for_each<N>([&]<size_t I>() {
 3785|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3786|       |                     return;
 3787|       |                  }
 3788|       |                  using V = std::variant_alternative_t<I, Variant>;
 3789|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3790|       |                     // run time substitute to compare to const value
 3791|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3792|       |                     auto copy_it{it};
 3793|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3794|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3795|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3796|       |                     const auto copy_depth{ctx.depth};
 3797|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3798|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3799|       |                     if (substitute == const_value) {
 3800|       |                        found_match = true;
 3801|       |                        if (!std::holds_alternative<V>(value)) {
 3802|       |                           value = V{};
 3803|       |                        }
 3804|       |                     }
 3805|       |                     else {
 3806|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3807|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3808|       |                           exhausted = true;
 3809|       |                        }
 3810|       |                        if constexpr (not Options.null_terminated) {
 3811|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3812|       |                              ctx.error = error_code::none;
 3813|       |                           }
 3814|       |                        }
 3815|       |                        it = copy_it;
 3816|       |                        rewind_depth<Options>(ctx, copy_depth);
 3817|       |                     }
 3818|       |                  }
 3819|       |               });
 3820|       |               if (found_match) {
 3821|       |                  return;
 3822|       |               }
 3823|       |            }
 3824|       |
 3825|       |            // Second pass: non-const types in this category
 3826|  2.02M|            if constexpr (non_const_count > 0) {
 3827|       |               // Track position within matching types for "is last" check.
 3828|       |               // We iterate over all variant indices but only process matching types,
 3829|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3830|       |               // the loop index directly corresponded to position in filtered set).
 3831|       |               // This has negligible cost: one increment per matching type.
 3832|  2.02M|               size_t non_const_idx = 0;
 3833|       |
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  2.02M|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  2.02M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  2.02M|                     auto copy_it{it};
 3841|  2.02M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  2.02M|                     if (!std::holds_alternative<V>(value)) {
 3843|  2.02M|                        value = V{};
 3844|  2.02M|                     }
 3845|  2.02M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  2.02M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|  2.02M|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|  2.02M|                     }
 3849|  2.02M|                     if (!bool(ctx.error)) {
 3850|  2.02M|                        found_match = true;
 3851|  2.02M|                     }
 3852|  2.02M|                     else if constexpr (not Options.null_terminated) {
 3853|  2.02M|                        constexpr bool is_complete_type =
 3854|  2.02M|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|  2.02M|                        if constexpr (is_complete_type) {
 3857|  2.02M|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|  2.02M|                              found_match = true;
 3859|  2.02M|                              ctx.error = error_code::none;
 3860|  2.02M|                           }
 3861|  2.02M|                           else {
 3862|  2.02M|                              it = copy_it;
 3863|  2.02M|                              rewind_depth<Options>(ctx, copy_depth);
 3864|  2.02M|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|  2.02M|                                  not variant_alternative_exhausted(ctx)) {
 3866|  2.02M|                                 ctx.error = error_code::none;
 3867|  2.02M|                              }
 3868|  2.02M|                           }
 3869|  2.02M|                        }
 3870|  2.02M|                        else {
 3871|  2.02M|                           it = copy_it;
 3872|  2.02M|                           rewind_depth<Options>(ctx, copy_depth);
 3873|  2.02M|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|  2.02M|                               not variant_alternative_exhausted(ctx)) {
 3875|  2.02M|                              ctx.error = error_code::none;
 3876|  2.02M|                           }
 3877|  2.02M|                        }
 3878|  2.02M|                     }
 3879|  2.02M|                     else {
 3880|  2.02M|                        it = copy_it;
 3881|  2.02M|                        rewind_depth<Options>(ctx, copy_depth);
 3882|  2.02M|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|  2.02M|                            not variant_alternative_exhausted(ctx)) {
 3884|  2.02M|                           ctx.error = error_code::none;
 3885|  2.02M|                        }
 3886|  2.02M|                     }
 3887|  2.02M|                     ++non_const_idx;
 3888|  2.02M|                  }
 3889|  2.02M|               });
 3890|  2.02M|               if (!found_match) {
  ------------------
  |  Branch (3890:20): [True: 1.34k, False: 2.02M]
  ------------------
 3891|  1.34k|                  if constexpr (non_const_count == 1) {
 3892|       |                     // Keep the specific error from the single type we tried
 3893|       |                  }
 3894|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3895|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3896|       |                     ctx.error = error_code::no_matching_variant_type;
 3897|       |                  }
 3898|  1.34k|               }
 3899|       |            }
 3900|       |            else {
 3901|       |               ctx.error = error_code::no_matching_variant_type;
 3902|       |            }
 3903|  2.02M|         }
 3904|  2.02M|      }
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 2.02M]
  |  Branch (3835:38): [True: 0, False: 2.02M]
  |  Branch (3835:51): [True: 0, False: 2.02M]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  2.02M|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  2.02M|               });
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 0, False: 2.02M]
  |  Branch (3835:38): [True: 0, False: 2.02M]
  |  Branch (3835:51): [True: 0, False: 2.02M]
  ------------------
 3836|      0|                     return;
 3837|      0|                  }
 3838|  2.02M|                  using V = std::variant_alternative_t<I, Variant>;
 3839|  2.02M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|  2.02M|                     auto copy_it{it};
 3841|  2.02M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|  2.02M|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3842:26): [True: 1.78M, False: 242k]
  ------------------
 3843|  1.78M|                        value = V{};
 3844|  1.78M|                     }
 3845|  2.02M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|  2.02M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3846:26): [True: 1.34k, False: 2.02M]
  |  Branch (3846:45): [True: 0, False: 1.34k]
  ------------------
 3847|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|      0|                     }
 3849|  2.02M|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3849:26): [True: 2.02M, False: 1.34k]
  ------------------
 3850|  2.02M|                        found_match = true;
 3851|  2.02M|                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|  1.34k|                     else {
 3880|  1.34k|                        it = copy_it;
 3881|  1.34k|                        rewind_depth<Options>(ctx, copy_depth);
 3882|  1.34k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3882:29): [True: 0, False: 1.34k]
  |  Branch (3882:68): [True: 0, False: 0]
  ------------------
 3883|      0|                            not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3883:29): [True: 0, False: 0]
  ------------------
 3884|      0|                           ctx.error = error_code::none;
 3885|      0|                        }
 3886|  1.34k|                     }
 3887|  2.02M|                     ++non_const_idx;
 3888|  2.02M|                  }
 3889|  2.02M|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERdTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  2.02M|      {
   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.02M|         else {
   60|  2.02M|            using V = std::remove_cvref_t<T>;
   61|  2.02M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  2.02M|                                             end);
   63|  2.02M|         }
   64|  2.02M|      }
_ZN3glz4fromILj10EdE2opITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEERPKcRdTkNS_10is_contextERNS_7contextES5_EEvOT1_OT2_OT0_T3_:
  808|  2.02M|      {
  809|       |         if constexpr (check_quoted_num(Opts)) {
  810|       |            if (skip_ws<Opts>(ctx, it, end)) {
  811|       |               return;
  812|       |            }
  813|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  814|       |               return;
  815|       |            }
  816|       |         }
  817|       |
  818|       |         if constexpr (!check_ws_handled(Opts)) {
  819|       |            if (skip_ws<Opts>(ctx, it, end)) {
  820|       |               return;
  821|       |            }
  822|       |         }
  823|       |
  824|  2.02M|         using V = std::decay_t<decltype(value)>;
  825|       |         if constexpr (int_t<V>) {
  826|       |            static_assert(sizeof(*it) == sizeof(char));
  827|       |
  828|       |            if constexpr (Opts.null_terminated) {
  829|       |               if (not glz::atoi(value, it)) [[unlikely]] {
  830|       |                  ctx.error = error_code::parse_number_failure;
  831|       |                  return;
  832|       |               }
  833|       |            }
  834|       |            else {
  835|       |               if (not glz::atoi(value, it, end)) [[unlikely]] {
  836|       |                  ctx.error = error_code::parse_number_failure;
  837|       |                  return;
  838|       |               }
  839|       |            }
  840|       |         }
  841|  2.02M|         else {
  842|       |// float128_t requires std::from_chars for floating-point, unavailable on older Apple platforms (iOS < 16.3)
  843|  2.02M|#if !defined(_LIBCPP_VERSION) || defined(_LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT)
  844|       |            if constexpr (is_float128<V>) {
  845|       |               auto [ptr, ec] = std::from_chars(it, end, value);
  846|       |               if (ec != std::errc()) {
  847|       |                  ctx.error = error_code::parse_number_failure;
  848|       |                  return;
  849|       |               }
  850|       |               it = ptr;
  851|       |            }
  852|       |            else
  853|       |#endif
  854|  2.02M|            {
  855|       |               if constexpr (std::is_volatile_v<std::remove_reference_t<decltype(value)>>) {
  856|       |                  // Hardware may interact with value changes, so we parse into a temporary and assign in one
  857|       |                  // place
  858|       |                  V temp;
  859|       |                  if constexpr (is_size_optimized(Opts)) {
  860|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, temp);
  861|       |                     if (ec != std::errc{}) [[unlikely]] {
  862|       |                        ctx.error = error_code::parse_number_failure;
  863|       |                        return;
  864|       |                     }
  865|       |                     it = ptr;
  866|       |                  }
  867|       |                  else {
  868|       |                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, temp);
  869|       |                     if (ec != std::errc()) [[unlikely]] {
  870|       |                        ctx.error = error_code::parse_number_failure;
  871|       |                        return;
  872|       |                     }
  873|       |                     it = ptr;
  874|       |                  }
  875|       |                  value = temp;
  876|       |               }
  877|  2.02M|               else {
  878|       |                  if constexpr (is_size_optimized(Opts)) {
  879|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, value);
  880|       |                     if (ec != std::errc{}) [[unlikely]] {
  881|       |                        ctx.error = error_code::parse_number_failure;
  882|       |                        return;
  883|       |                     }
  884|       |                     it = ptr;
  885|       |                  }
  886|  2.02M|                  else {
  887|  2.02M|                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, value);
  888|  2.02M|                     if (ec != std::errc()) [[unlikely]] {
  ------------------
  |  Branch (888:26): [True: 1.34k, False: 2.02M]
  ------------------
  889|  1.34k|                        ctx.error = error_code::parse_number_failure;
  890|  1.34k|                        return;
  891|  1.34k|                     }
  892|  2.02M|                     it = ptr;
  893|  2.02M|                  }
  894|  2.02M|               }
  895|  2.02M|            }
  896|  2.02M|         }
  897|       |
  898|       |         if constexpr (check_quoted_num(Opts)) {
  899|       |            if constexpr (not Opts.null_terminated) {
  900|       |               if (it == end) [[unlikely]] {
  901|       |                  ctx.error = error_code::unexpected_end;
  902|       |                  return;
  903|       |               }
  904|       |            }
  905|       |            if (match<'"'>(ctx, it)) {
  906|       |               return;
  907|       |            }
  908|       |            if constexpr (not Opts.null_terminated) {
  909|       |               if (it == end) {
  910|       |                  ctx.error = error_code::end_reached;
  911|       |                  return;
  912|       |               }
  913|       |            }
  914|       |         }
  915|  2.02M|         else {
  916|       |            if constexpr (not Opts.null_terminated) {
  917|       |               if (it == end) {
  918|       |                  ctx.error = error_code::end_reached;
  919|       |                  return;
  920|       |               }
  921|       |            }
  922|  2.02M|         }
  923|  2.02M|      }
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 2.02M, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 2.02M, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 2.02M, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });
_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:
 3834|  2.02M|               for_each<N>([&]<size_t I>() {
 3835|  2.02M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3835:23): [True: 2.02M, False: 1.34k]
  |  Branch (3835:38): [True: 0, False: 1.34k]
  |  Branch (3835:51): [True: 0, False: 1.34k]
  ------------------
 3836|  2.02M|                     return;
 3837|  2.02M|                  }
 3838|  1.34k|                  using V = std::variant_alternative_t<I, Variant>;
 3839|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3840|       |                     auto copy_it{it};
 3841|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3842|       |                     if (!std::holds_alternative<V>(value)) {
 3843|       |                        value = V{};
 3844|       |                     }
 3845|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3846|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3847|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3848|       |                     }
 3849|       |                     if (!bool(ctx.error)) {
 3850|       |                        found_match = true;
 3851|       |                     }
 3852|       |                     else if constexpr (not Options.null_terminated) {
 3853|       |                        constexpr bool is_complete_type =
 3854|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3855|       |
 3856|       |                        if constexpr (is_complete_type) {
 3857|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3858|       |                              found_match = true;
 3859|       |                              ctx.error = error_code::none;
 3860|       |                           }
 3861|       |                           else {
 3862|       |                              it = copy_it;
 3863|       |                              rewind_depth<Options>(ctx, copy_depth);
 3864|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3865|       |                                  not variant_alternative_exhausted(ctx)) {
 3866|       |                                 ctx.error = error_code::none;
 3867|       |                              }
 3868|       |                           }
 3869|       |                        }
 3870|       |                        else {
 3871|       |                           it = copy_it;
 3872|       |                           rewind_depth<Options>(ctx, copy_depth);
 3873|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3874|       |                               not variant_alternative_exhausted(ctx)) {
 3875|       |                              ctx.error = error_code::none;
 3876|       |                           }
 3877|       |                        }
 3878|       |                     }
 3879|       |                     else {
 3880|       |                        it = copy_it;
 3881|       |                        rewind_depth<Options>(ctx, copy_depth);
 3882|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3883|       |                            not variant_alternative_exhausted(ctx)) {
 3884|       |                           ctx.error = error_code::none;
 3885|       |                        }
 3886|       |                     }
 3887|       |                     ++non_const_idx;
 3888|       |                  }
 3889|  1.34k|               });

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

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

_ZN3glz10fast_float4spanIKcEC2Ev:
  438|  12.1M|  constexpr span() : ptr(nullptr), length(0) {}
_ZN3glz10fast_float10is_integerIcEEbT_:
 1481|  9.64k|fastfloat_really_inline constexpr bool is_integer(UC c) noexcept {
 1482|  9.64k|  return !(c > UC('9') || c < UC('0'));
  ------------------
  |  Branch (1482:12): [True: 6, False: 9.63k]
  |  Branch (1482:27): [True: 56, False: 9.57k]
  ------------------
 1483|  9.64k|}
_ZN3glz10fast_float11digit_valueIcEEmT_:
 1489|  38.0M|fastfloat_really_inline constexpr uint64_t digit_value(UC c) noexcept {
 1490|  38.0M|  return uint64_t(uint8_t(c) - uint8_t('0'));
 1491|  38.0M|}
_ZN3glz10fast_float4spanIKcEC2EPS2_m:
  436|  6.13M|  constexpr span(T const *_ptr, size_t _length) : ptr(_ptr), length(_length) {}
_ZN3glz10fast_float26loop_parse_if_eight_digitsERPKcS2_Rm:
 1679|  46.2k|                           uint64_t &i) {
 1680|       |  // optimizes better than parse_if_eight_digits_unrolled() for UC = char.
 1681|  3.03M|  while ((std::distance(p, pend) >= 8) &&
  ------------------
  |  Branch (1681:10): [True: 3.02M, False: 3.09k]
  ------------------
 1682|  3.02M|         is_made_of_eight_digits_fast(read8_to_u64(p))) {
  ------------------
  |  Branch (1682:10): [True: 2.98M, False: 43.1k]
  ------------------
 1683|  2.98M|    i = i * 100000000 +
 1684|  2.98M|        parse_eight_digits_unrolled(read8_to_u64(
 1685|  2.98M|            p)); // in rare cases, this will overflow, but that's ok
 1686|  2.98M|    p += 8;
 1687|  2.98M|  }
 1688|  46.2k|}
_ZN3glz10fast_float28is_made_of_eight_digits_fastEm:
 1597|  3.02M|is_made_of_eight_digits_fast(uint64_t val) noexcept {
 1598|  3.02M|  return !((((val + 0x4646464646464646) | (val - 0x3030303030303030)) &
 1599|  3.02M|            0x8080808080808080));
 1600|  3.02M|}
_ZN3glz10fast_float12read8_to_u64IcEEmPKT_:
 1503|  7.86M|read8_to_u64(UC const *chars) {
 1504|  7.86M|  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|  7.86M|  uint64_t val;
 1513|  7.86M|  ::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|  7.86M|  return val;
 1519|  7.86M|}
_ZN3glz10fast_float27parse_eight_digits_unrolledEm:
 1575|  4.84M|parse_eight_digits_unrolled(uint64_t val) {
 1576|  4.84M|  uint64_t const mask = 0x000000FF000000FF;
 1577|  4.84M|  uint64_t const mul1 = 0x000F424000000064; // 100 + (1000000ULL << 32)
 1578|  4.84M|  uint64_t const mul2 = 0x0000271000000001; // 1 + (10000ULL << 32)
 1579|  4.84M|  val -= 0x3030303030303030;
 1580|  4.84M|  val = (val * 10) + (val >> 8); // val = (val * 2561) >> 8;
 1581|  4.84M|  val = (((val & mask) * mul1) + (((val >> 16) & mask) * mul2)) >> 32;
 1582|  4.84M|  return uint32_t(val);
 1583|  4.84M|}
_ZNK3glz10fast_float4spanIKcE3lenEv:
  440|   186k|  constexpr size_t len() const noexcept { return length; }
_ZN3glz10fast_float19from_chars_advancedIdcEENS0_19from_chars_result_tIT0_EERNS0_22parsed_number_string_tIS3_EERT_:
 4249|  6.08M|from_chars_advanced(parsed_number_string_t<UC> &pns, T &value) noexcept {
 4250|       |
 4251|  6.08M|  static_assert(is_supported_float_type<T>::value,
 4252|  6.08M|                "only some floating-point types are supported");
 4253|  6.08M|  static_assert(is_supported_char_type<UC>::value,
 4254|  6.08M|                "only char, wchar_t, char16_t and char32_t are supported");
 4255|       |
 4256|  6.08M|  from_chars_result_t<UC> answer;
 4257|       |
 4258|  6.08M|  answer.ec = std::errc(); // be optimistic
 4259|  6.08M|  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|  6.08M|  if (binary_format<T>::min_exponent_fast_path() <= pns.exponent &&
  ------------------
  |  Branch (4265:7): [True: 6.06M, False: 12.2k]
  ------------------
 4266|  6.06M|      pns.exponent <= binary_format<T>::max_exponent_fast_path() &&
  ------------------
  |  Branch (4266:7): [True: 6.04M, False: 28.0k]
  ------------------
 4267|  6.04M|      !pns.too_many_digits) {
  ------------------
  |  Branch (4267:7): [True: 6.00M, False: 37.8k]
  ------------------
 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|  6.00M|    if (!cpp20_and_in_constexpr() && detail::rounds_to_nearest()) {
  ------------------
  |  Branch (4275:9): [True: 6.00M, Folded]
  |  Branch (4275:38): [True: 6.00M, False: 0]
  ------------------
 4276|       |      // We have that fegetround() == FE_TONEAREST.
 4277|       |      // Next is Clinger's fast path.
 4278|  6.00M|      if (pns.mantissa <= binary_format<T>::max_mantissa_fast_path()) {
  ------------------
  |  Branch (4278:11): [True: 6.00M, False: 3.05k]
  ------------------
 4279|  6.00M|        value = T(pns.mantissa);
 4280|  6.00M|        if (pns.exponent < 0) {
  ------------------
  |  Branch (4280:13): [True: 6.02k, False: 5.99M]
  ------------------
 4281|  6.02k|          value = value / binary_format<T>::exact_power_of_ten(-pns.exponent);
 4282|  5.99M|        } else {
 4283|  5.99M|          value = value * binary_format<T>::exact_power_of_ten(pns.exponent);
 4284|  5.99M|        }
 4285|  6.00M|        if (pns.negative) {
  ------------------
  |  Branch (4285:13): [True: 6.23k, False: 5.99M]
  ------------------
 4286|  6.23k|          value = -value;
 4287|  6.23k|        }
 4288|  6.00M|        return answer;
 4289|  6.00M|      }
 4290|  6.00M|    } 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|  6.00M|  }
 4313|  81.1k|  adjusted_mantissa am =
 4314|  81.1k|      compute_float<binary_format<T>>(pns.exponent, pns.mantissa);
 4315|  81.1k|  if (pns.too_many_digits && am.power2 >= 0) {
  ------------------
  |  Branch (4315:7): [True: 68.7k, False: 12.3k]
  |  Branch (4315:30): [True: 68.7k, False: 0]
  ------------------
 4316|  68.7k|    if (am != compute_float<binary_format<T>>(pns.exponent, pns.mantissa + 1)) {
  ------------------
  |  Branch (4316:9): [True: 58.5k, False: 10.2k]
  ------------------
 4317|  58.5k|      am = compute_error<binary_format<T>>(pns.exponent, pns.mantissa);
 4318|  58.5k|    }
 4319|  68.7k|  }
 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|  81.1k|  if (am.power2 < 0) {
  ------------------
  |  Branch (4323:7): [True: 58.5k, False: 22.6k]
  ------------------
 4324|  58.5k|    am = digit_comp<T>(pns, am);
 4325|  58.5k|  }
 4326|  81.1k|  to_float(pns.negative, am, value);
 4327|       |  // Test for over/underflow.
 4328|  81.1k|  if ((pns.mantissa != 0 && am.mantissa == 0 && am.power2 == 0) ||
  ------------------
  |  Branch (4328:8): [True: 79.9k, False: 1.25k]
  |  Branch (4328:29): [True: 7.16k, False: 72.7k]
  |  Branch (4328:49): [True: 279, False: 6.88k]
  ------------------
 4329|  80.8k|      am.power2 == binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (4329:7): [True: 354, False: 80.5k]
  ------------------
 4330|    633|    answer.ec = std::errc::result_out_of_range;
 4331|    633|  }
 4332|  81.1k|  return answer;
 4333|  6.08M|}
_ZN3glz10fast_float13binary_formatIdE22min_exponent_fast_pathEv:
  695|  6.08M|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|  6.08M|  return -22;
  700|  6.08M|#endif
  701|  6.08M|}
_ZN3glz10fast_float13binary_formatIdE22max_exponent_fast_pathEv:
  767|  6.06M|inline constexpr int binary_format<double>::max_exponent_fast_path() {
  768|  6.06M|  return 22;
  769|  6.06M|}
_ZN3glz10fast_float6detail17rounds_to_nearestEv:
 4129|  6.00M|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|  6.00M|  static float volatile fmin = (std::numeric_limits<float>::min)();
 4151|  6.00M|  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|  6.00M|#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|  6.00M|  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|  6.00M|}
_ZN3glz10fast_float13binary_formatIdE22max_mantissa_fast_pathEv:
  777|  6.00M|inline constexpr uint64_t binary_format<double>::max_mantissa_fast_path() {
  778|  6.00M|  return uint64_t(2) << mantissa_explicit_bits();
  779|  6.00M|}
_ZN3glz10fast_float13binary_formatIdE22mantissa_explicit_bitsEv:
  713|  7.01M|inline constexpr int binary_format<double>::mantissa_explicit_bits() {
  714|  7.01M|  return 52;
  715|  7.01M|}
_ZN3glz10fast_float13binary_formatIdE18exact_power_of_tenEl:
 1057|  6.00M|binary_format<double>::exact_power_of_ten(int64_t power) {
 1058|       |  // Work around clang bug https://godbolt.org/z/zedh7rrhc
 1059|  6.00M|  return (void)powers_of_ten[0], powers_of_ten[power];
 1060|  6.00M|}
_ZN3glz10fast_float13compute_floatINS0_13binary_formatIdEEEENS0_17adjusted_mantissaElm:
 2852|   149k|compute_float(int64_t q, uint64_t w) noexcept {
 2853|   149k|  adjusted_mantissa answer;
 2854|   149k|  if ((w == 0) || (q < binary::smallest_power_of_ten())) {
  ------------------
  |  Branch (2854:7): [True: 1.25k, False: 148k]
  |  Branch (2854:19): [True: 306, False: 148k]
  ------------------
 2855|  1.55k|    answer.power2 = 0;
 2856|  1.55k|    answer.mantissa = 0;
 2857|       |    // result should be zero
 2858|  1.55k|    return answer;
 2859|  1.55k|  }
 2860|   148k|  if (q > binary::largest_power_of_ten()) {
  ------------------
  |  Branch (2860:7): [True: 417, False: 147k]
  ------------------
 2861|       |    // we want to get infinity:
 2862|    417|    answer.power2 = binary::infinite_power();
 2863|    417|    answer.mantissa = 0;
 2864|    417|    return answer;
 2865|    417|  }
 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|   147k|  int lz = leading_zeroes(w);
 2871|   147k|  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|   147k|  value128 product =
 2880|   147k|      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|   147k|  int upperbit = int(product.high >> 63);
 2891|   147k|  int shift = upperbit + 64 - binary::mantissa_explicit_bits() - 3;
 2892|       |
 2893|   147k|  answer.mantissa = product.high >> shift;
 2894|       |
 2895|   147k|  answer.power2 = int32_t(detail::power(int32_t(q)) + upperbit - lz -
 2896|   147k|                          binary::minimum_exponent());
 2897|   147k|  if (answer.power2 <= 0) { // we have a subnormal?
  ------------------
  |  Branch (2897:7): [True: 10.9k, False: 137k]
  ------------------
 2898|       |    // Here have that answer.power2 <= 0 so -answer.power2 >= 0
 2899|  10.9k|    if (-answer.power2 + 1 >=
  ------------------
  |  Branch (2899:9): [True: 12, False: 10.9k]
  ------------------
 2900|  10.9k|        64) { // if we have more than 64 bits below the minimum exponent, you
 2901|       |              // have a zero for sure.
 2902|     12|      answer.power2 = 0;
 2903|     12|      answer.mantissa = 0;
 2904|       |      // result should be zero
 2905|     12|      return answer;
 2906|     12|    }
 2907|       |    // next line is safe because -answer.power2 + 1 < 64
 2908|  10.9k|    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|  10.9k|    answer.mantissa += (answer.mantissa & 1); // round up
 2913|  10.9k|    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|  10.9k|    answer.power2 =
 2922|  10.9k|        (answer.mantissa < (uint64_t(1) << binary::mantissa_explicit_bits()))
  ------------------
  |  Branch (2922:9): [True: 10.9k, False: 12]
  ------------------
 2923|  10.9k|            ? 0
 2924|  10.9k|            : 1;
 2925|  10.9k|    return answer;
 2926|  10.9k|  }
 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|   137k|  if ((product.low <= 1) && (q >= binary::min_exponent_round_to_even()) &&
  ------------------
  |  Branch (2931:7): [True: 29.6k, False: 107k]
  |  Branch (2931:29): [True: 27.3k, False: 2.28k]
  ------------------
 2932|  27.3k|      (q <= binary::max_exponent_round_to_even()) &&
  ------------------
  |  Branch (2932:7): [True: 25.5k, False: 1.86k]
  ------------------
 2933|  25.5k|      ((answer.mantissa & 3) == 1)) { // we may fall between two floats!
  ------------------
  |  Branch (2933:7): [True: 13.4k, False: 12.0k]
  ------------------
 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|  13.4k|    if ((answer.mantissa << shift) == product.high) {
  ------------------
  |  Branch (2939:9): [True: 9.53k, False: 3.94k]
  ------------------
 2940|  9.53k|      answer.mantissa &= ~uint64_t(1); // flip it so that we do not round up
 2941|  9.53k|    }
 2942|  13.4k|  }
 2943|       |
 2944|   137k|  answer.mantissa += (answer.mantissa & 1); // round up
 2945|   137k|  answer.mantissa >>= 1;
 2946|   137k|  if (answer.mantissa >= (uint64_t(2) << binary::mantissa_explicit_bits())) {
  ------------------
  |  Branch (2946:7): [True: 6.48k, False: 130k]
  ------------------
 2947|  6.48k|    answer.mantissa = (uint64_t(1) << binary::mantissa_explicit_bits());
 2948|  6.48k|    answer.power2++; // undo previous addition
 2949|  6.48k|  }
 2950|       |
 2951|   137k|  answer.mantissa &= ~(uint64_t(1) << binary::mantissa_explicit_bits());
 2952|   137k|  if (answer.power2 >= binary::infinite_power()) { // infinity
  ------------------
  |  Branch (2952:7): [True: 33, False: 136k]
  ------------------
 2953|     33|    answer.power2 = binary::infinite_power();
 2954|     33|    answer.mantissa = 0;
 2955|     33|  }
 2956|   137k|  return answer;
 2957|   147k|}
_ZN3glz10fast_float17adjusted_mantissaC2Ev:
  568|   267k|  adjusted_mantissa() = default;
_ZN3glz10fast_float13binary_formatIdE21smallest_power_of_tenEv:
 1077|   148k|inline constexpr int binary_format<double>::smallest_power_of_ten() {
 1078|   148k|  return -342;
 1079|   148k|}
_ZN3glz10fast_float13binary_formatIdE20largest_power_of_tenEv:
 1068|   148k|template <> inline constexpr int binary_format<double>::largest_power_of_ten() {
 1069|   148k|  return 308;
 1070|   148k|}
_ZN3glz10fast_float14leading_zeroesEm:
  488|   242k|leading_zeroes(uint64_t input_num) {
  489|   242k|  assert(input_num > 0);
  ------------------
  |  Branch (489:3): [True: 242k, False: 0]
  ------------------
  490|   242k|  if (cpp20_and_in_constexpr()) {
  ------------------
  |  Branch (490:7): [Folded, False: 242k]
  ------------------
  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|   242k|  return __builtin_clzll(input_num);
  505|   242k|#endif
  506|   242k|}
_ZN3glz10fast_float29compute_product_approximationILi55EEENS0_8value128Elm:
 2771|   206k|compute_product_approximation(int64_t q, uint64_t w) {
 2772|   206k|  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|   206k|  value128 firstproduct =
 2777|   206k|      full_multiplication(w, powers::power_of_five_128[index]);
 2778|   206k|  static_assert((bit_precision >= 0) && (bit_precision <= 64),
 2779|   206k|                " precision should  be in (0,64]");
 2780|   206k|  constexpr uint64_t precision_mask =
 2781|   206k|      (bit_precision < 64) ? (uint64_t(0xFFFFFFFFFFFFFFFF) >> bit_precision)
  ------------------
  |  Branch (2781:7): [True: 0, Folded]
  ------------------
 2782|   206k|                           : uint64_t(0xFFFFFFFFFFFFFFFF);
 2783|   206k|  if ((firstproduct.high & precision_mask) ==
  ------------------
  |  Branch (2783:7): [True: 48.7k, False: 157k]
  ------------------
 2784|   206k|      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.7k|    value128 secondproduct =
 2789|  48.7k|        full_multiplication(w, powers::power_of_five_128[index + 1]);
 2790|  48.7k|    firstproduct.low += secondproduct.high;
 2791|  48.7k|    if (secondproduct.high > firstproduct.low) {
  ------------------
  |  Branch (2791:9): [True: 12.7k, False: 36.0k]
  ------------------
 2792|  12.7k|      firstproduct.high++;
 2793|  12.7k|    }
 2794|  48.7k|  }
 2795|   206k|  return firstproduct;
 2796|   206k|}
_ZN3glz10fast_float19full_multiplicationEmm:
  540|   255k|full_multiplication(uint64_t a, uint64_t b) {
  541|   255k|  if (cpp20_and_in_constexpr()) {
  ------------------
  |  Branch (541:7): [Folded, False: 255k]
  ------------------
  542|      0|    value128 answer;
  543|      0|    answer.low = umul128_generic(a, b, &answer.high);
  544|      0|    return answer;
  545|      0|  }
  546|   255k|  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|   255k|  answer.low = uint64_t(r);
  558|   255k|  answer.high = uint64_t(r >> 64);
  559|       |#else
  560|       |  answer.low = umul128_generic(a, b, &answer.high);
  561|       |#endif
  562|   255k|  return answer;
  563|   255k|}
_ZN3glz10fast_float8value128C2Ev:
  454|   255k|  constexpr value128() : low(0), high(0) {}
_ZN3glz10fast_float6detail5powerEi:
 2814|   206k|constexpr fastfloat_really_inline int32_t power(int32_t q) noexcept {
 2815|   206k|  return (((152170 + 65536) * q) >> 16) + 63;
 2816|   206k|}
_ZN3glz10fast_float13binary_formatIdE16minimum_exponentEv:
  742|   265k|template <> inline constexpr int binary_format<double>::minimum_exponent() {
  743|   265k|  return -1023;
  744|   265k|}
_ZN3glz10fast_float13binary_formatIdE26min_exponent_round_to_evenEv:
  733|  29.6k|inline constexpr int binary_format<double>::min_exponent_round_to_even() {
  734|  29.6k|  return -4;
  735|  29.6k|}
_ZN3glz10fast_float13binary_formatIdE26max_exponent_round_to_evenEv:
  723|  27.3k|inline constexpr int binary_format<double>::max_exponent_round_to_even() {
  724|  27.3k|  return 23;
  725|  27.3k|}
_ZNK3glz10fast_float17adjusted_mantissaneERKS1_:
  574|  68.7k|  constexpr bool operator!=(adjusted_mantissa const &o) const {
  575|  68.7k|    return mantissa != o.mantissa || power2 != o.power2;
  ------------------
  |  Branch (575:12): [True: 58.5k, False: 10.2k]
  |  Branch (575:38): [True: 0, False: 10.2k]
  ------------------
  576|  68.7k|  }
_ZN3glz10fast_float13compute_errorINS0_13binary_formatIdEEEENS0_17adjusted_mantissaElm:
 2837|  58.5k|compute_error(int64_t q, uint64_t w) noexcept {
 2838|  58.5k|  int lz = leading_zeroes(w);
 2839|  58.5k|  w <<= lz;
 2840|  58.5k|  value128 product =
 2841|  58.5k|      compute_product_approximation<binary::mantissa_explicit_bits() + 3>(q, w);
 2842|  58.5k|  return compute_error_scaled<binary>(q, product.high, lz);
 2843|  58.5k|}
_ZN3glz10fast_float20compute_error_scaledINS0_13binary_formatIdEEEENS0_17adjusted_mantissaElmi:
 2823|  58.5k|compute_error_scaled(int64_t q, uint64_t w, int lz) noexcept {
 2824|  58.5k|  int hilz = int(w >> 63) ^ 1;
 2825|  58.5k|  adjusted_mantissa answer;
 2826|  58.5k|  answer.mantissa = w << hilz;
 2827|  58.5k|  int bias = binary::mantissa_explicit_bits() - binary::minimum_exponent();
 2828|  58.5k|  answer.power2 = int32_t(detail::power(int32_t(q)) + bias - hilz - lz - 62 +
 2829|  58.5k|                          invalid_am_bias);
 2830|  58.5k|  return answer;
 2831|  58.5k|}
_ZN3glz10fast_float10digit_compIdcEENS0_17adjusted_mantissaERNS0_22parsed_number_string_tIT0_EES2_:
 4034|  58.5k|digit_comp(parsed_number_string_t<UC> &num, adjusted_mantissa am) noexcept {
 4035|       |  // remove the invalid exponent bias
 4036|  58.5k|  am.power2 -= invalid_am_bias;
 4037|       |
 4038|  58.5k|  int32_t sci_exp = scientific_exponent(num);
 4039|  58.5k|  size_t max_digits = binary_format<T>::max_digits();
 4040|  58.5k|  size_t digits = 0;
 4041|  58.5k|  bigint bigmant;
 4042|  58.5k|  parse_mantissa(bigmant, num, max_digits, digits);
 4043|       |  // can't underflow, since digits is at most max_digits.
 4044|  58.5k|  int32_t exponent = sci_exp + 1 - int32_t(digits);
 4045|  58.5k|  if (exponent >= 0) {
  ------------------
  |  Branch (4045:7): [True: 17.7k, False: 40.7k]
  ------------------
 4046|  17.7k|    return positive_digit_comp<T>(bigmant, exponent);
 4047|  40.7k|  } else {
 4048|  40.7k|    return negative_digit_comp<T>(bigmant, am, exponent);
 4049|  40.7k|  }
 4050|  58.5k|}
_ZN3glz10fast_float19scientific_exponentIcEEiRNS0_22parsed_number_string_tIT_EE:
 3640|  58.5k|scientific_exponent(parsed_number_string_t<UC> &num) noexcept {
 3641|  58.5k|  uint64_t mantissa = num.mantissa;
 3642|  58.5k|  int32_t exponent = int32_t(num.exponent);
 3643|   292k|  while (mantissa >= 10000) {
  ------------------
  |  Branch (3643:10): [True: 234k, False: 58.5k]
  ------------------
 3644|   234k|    mantissa /= 10000;
 3645|   234k|    exponent += 4;
 3646|   234k|  }
 3647|   117k|  while (mantissa >= 100) {
  ------------------
  |  Branch (3647:10): [True: 58.5k, False: 58.5k]
  ------------------
 3648|  58.5k|    mantissa /= 100;
 3649|  58.5k|    exponent += 2;
 3650|  58.5k|  }
 3651|  58.5k|  while (mantissa >= 10) {
  ------------------
  |  Branch (3651:10): [True: 0, False: 58.5k]
  ------------------
 3652|      0|    mantissa /= 10;
 3653|      0|    exponent += 1;
 3654|      0|  }
 3655|  58.5k|  return exponent;
 3656|  58.5k|}
_ZN3glz10fast_float13binary_formatIdE10max_digitsEv:
 1085|  58.5k|template <> inline constexpr size_t binary_format<double>::max_digits() {
 1086|  58.5k|  return 769;
 1087|  58.5k|}
_ZN3glz10fast_float6bigintC2Ev:
 3399|  58.5k|  GLZ_FASTFLOAT_CONSTEXPR20 bigint() : vec() {}
_ZN3glz10fast_float8stackvecILt62EEC2Ev:
 3006|   574k|  stackvec() = default;
_ZN3glz10fast_float14parse_mantissaIcEEvRNS0_6bigintERNS0_22parsed_number_string_tIT_EEmRm:
 3859|  58.5k|               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|  58.5k|  size_t counter = 0;
 3864|  58.5k|  digits = 0;
 3865|  58.5k|  limb value = 0;
 3866|  58.5k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3867|  58.5k|  size_t step = 19;
 3868|       |#else
 3869|       |  size_t step = 9;
 3870|       |#endif
 3871|       |
 3872|       |  // process all integer digits.
 3873|  58.5k|  UC const *p = num.integer.ptr;
 3874|  58.5k|  UC const *pend = p + num.integer.len();
 3875|  58.5k|  skip_zeros(p, pend);
 3876|       |  // process all digits, in increments of step per loop
 3877|   581k|  while (p != pend) {
  ------------------
  |  Branch (3877:10): [True: 534k, False: 47.2k]
  ------------------
 3878|  1.52M|    while ((std::distance(p, pend) >= 8) && (step - counter >= 8) &&
  ------------------
  |  Branch (3878:12): [True: 1.45M, False: 65.7k]
  |  Branch (3878:45): [True: 998k, False: 460k]
  ------------------
 3879|   998k|           (max_digits - digits >= 8)) {
  ------------------
  |  Branch (3879:12): [True: 991k, False: 7.67k]
  ------------------
 3880|   991k|      parse_eight_digits(p, value, counter, digits);
 3881|   991k|    }
 3882|  2.05M|    while (counter < step && p != pend && digits < max_digits) {
  ------------------
  |  Branch (3882:12): [True: 1.57M, False: 480k]
  |  Branch (3882:30): [True: 1.52M, False: 45.9k]
  |  Branch (3882:43): [True: 1.51M, False: 8.07k]
  ------------------
 3883|  1.51M|      parse_one_digit(p, value, counter, digits);
 3884|  1.51M|    }
 3885|   534k|    if (digits == max_digits) {
  ------------------
  |  Branch (3885:9): [True: 11.2k, False: 522k]
  ------------------
 3886|       |      // add the temporary value, then check if we've truncated any digits
 3887|  11.2k|      add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3888|  11.2k|      bool truncated = is_truncated(p, pend);
 3889|  11.2k|      if (num.fraction.ptr != nullptr) {
  ------------------
  |  Branch (3889:11): [True: 8.70k, False: 2.54k]
  ------------------
 3890|  8.70k|        truncated |= is_truncated(num.fraction);
 3891|  8.70k|      }
 3892|  11.2k|      if (truncated) {
  ------------------
  |  Branch (3892:11): [True: 6.33k, False: 4.91k]
  ------------------
 3893|  6.33k|        round_up_bigint(result, digits);
 3894|  6.33k|      }
 3895|  11.2k|      return;
 3896|   522k|    } else {
 3897|   522k|      add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3898|   522k|      counter = 0;
 3899|   522k|      value = 0;
 3900|   522k|    }
 3901|   534k|  }
 3902|       |
 3903|       |  // add our fraction digits, if they're available.
 3904|  47.2k|  if (num.fraction.ptr != nullptr) {
  ------------------
  |  Branch (3904:7): [True: 27.3k, False: 19.9k]
  ------------------
 3905|  27.3k|    p = num.fraction.ptr;
 3906|  27.3k|    pend = p + num.fraction.len();
 3907|  27.3k|    if (digits == 0) {
  ------------------
  |  Branch (3907:9): [True: 4.49k, False: 22.8k]
  ------------------
 3908|  4.49k|      skip_zeros(p, pend);
 3909|  4.49k|    }
 3910|       |    // process all digits, in increments of step per loop
 3911|   468k|    while (p != pend) {
  ------------------
  |  Branch (3911:12): [True: 451k, False: 17.0k]
  ------------------
 3912|  1.31M|      while ((std::distance(p, pend) >= 8) && (step - counter >= 8) &&
  ------------------
  |  Branch (3912:14): [True: 1.28M, False: 26.3k]
  |  Branch (3912:47): [True: 867k, False: 420k]
  ------------------
 3913|   867k|             (max_digits - digits >= 8)) {
  ------------------
  |  Branch (3913:14): [True: 863k, False: 4.26k]
  ------------------
 3914|   863k|        parse_eight_digits(p, value, counter, digits);
 3915|   863k|      }
 3916|  1.79M|      while (counter < step && p != pend && digits < max_digits) {
  ------------------
  |  Branch (3916:14): [True: 1.36M, False: 428k]
  |  Branch (3916:32): [True: 1.35M, False: 16.2k]
  |  Branch (3916:45): [True: 1.34M, False: 7.00k]
  ------------------
 3917|  1.34M|        parse_one_digit(p, value, counter, digits);
 3918|  1.34M|      }
 3919|   451k|      if (digits == max_digits) {
  ------------------
  |  Branch (3919:11): [True: 10.2k, False: 441k]
  ------------------
 3920|       |        // add the temporary value, then check if we've truncated any digits
 3921|  10.2k|        add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3922|  10.2k|        bool truncated = is_truncated(p, pend);
 3923|  10.2k|        if (truncated) {
  ------------------
  |  Branch (3923:13): [True: 6.01k, False: 4.26k]
  ------------------
 3924|  6.01k|          round_up_bigint(result, digits);
 3925|  6.01k|        }
 3926|  10.2k|        return;
 3927|   441k|      } else {
 3928|   441k|        add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3929|   441k|        counter = 0;
 3930|   441k|        value = 0;
 3931|   441k|      }
 3932|   451k|    }
 3933|  27.3k|  }
 3934|       |
 3935|  37.0k|  if (counter != 0) {
  ------------------
  |  Branch (3935:7): [True: 0, False: 37.0k]
  ------------------
 3936|      0|    add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3937|      0|  }
 3938|  37.0k|}
_ZN3glz10fast_float10skip_zerosIcEEvRPKT_S4_:
 3773|  63.0k|skip_zeros(UC const *&first, UC const *last) noexcept {
 3774|  63.0k|  uint64_t val;
 3775|  64.2k|  while (!cpp20_and_in_constexpr() &&
  ------------------
  |  Branch (3775:10): [True: 64.2k, Folded]
  ------------------
 3776|  64.2k|         std::distance(first, last) >= int_cmp_len<UC>()) {
  ------------------
  |  Branch (3776:10): [True: 52.8k, False: 11.3k]
  ------------------
 3777|  52.8k|    ::memcpy(&val, first, sizeof(uint64_t));
 3778|  52.8k|    if (val != int_cmp_zeros<UC>()) {
  ------------------
  |  Branch (3778:9): [True: 51.6k, False: 1.19k]
  ------------------
 3779|  51.6k|      break;
 3780|  51.6k|    }
 3781|  1.19k|    first += int_cmp_len<UC>();
 3782|  1.19k|  }
 3783|  74.3k|  while (first != last) {
  ------------------
  |  Branch (3783:10): [True: 69.8k, False: 4.49k]
  ------------------
 3784|  69.8k|    if (*first != UC('0')) {
  ------------------
  |  Branch (3784:9): [True: 58.5k, False: 11.2k]
  ------------------
 3785|  58.5k|      break;
 3786|  58.5k|    }
 3787|  11.2k|    first++;
 3788|  11.2k|  }
 3789|  63.0k|}
_ZN3glz10fast_float11int_cmp_lenIcEEiv:
 1180|   467k|template <typename UC> constexpr int int_cmp_len() {
 1181|   467k|  return sizeof(uint64_t) / sizeof(UC);
 1182|   467k|}
_ZN3glz10fast_float13int_cmp_zerosIcEEmv:
 1170|   243k|template <typename UC> constexpr uint64_t int_cmp_zeros() {
 1171|   243k|  static_assert((sizeof(UC) == 1) || (sizeof(UC) == 2) || (sizeof(UC) == 4),
 1172|   243k|                "Unsupported character size");
 1173|   243k|  return (sizeof(UC) == 1) ? 0x3030303030303030
  ------------------
  |  Branch (1173:10): [True: 243k, Folded]
  ------------------
 1174|   243k|         : (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|   243k|}
_ZN3glz10fast_float18parse_eight_digitsIcEEvRPKT_RmS6_S6_:
 3824|  1.85M|                   size_t &count) noexcept {
 3825|  1.85M|  value = value * 100000000 + parse_eight_digits_unrolled(p);
 3826|  1.85M|  p += 8;
 3827|  1.85M|  counter += 8;
 3828|  1.85M|  count += 8;
 3829|  1.85M|}
_ZN3glz10fast_float27parse_eight_digits_unrolledIcEEjPKT_:
 1588|  1.85M|parse_eight_digits_unrolled(UC const *chars) noexcept {
 1589|  1.85M|  if (cpp20_and_in_constexpr() || !has_simd_opt<UC>()) {
  ------------------
  |  Branch (1589:7): [Folded, False: 0]
  |  Branch (1589:35): [True: 0, Folded]
  ------------------
 1590|  1.85M|    return parse_eight_digits_unrolled(read8_to_u64(chars)); // truncation okay
 1591|  1.85M|  }
 1592|      0|  return parse_eight_digits_unrolled(simd_read8_to_u64(chars));
 1593|  1.85M|}
_ZN3glz10fast_float15parse_one_digitIcEEvRPKT_RmS6_S6_:
 3834|  2.86M|                size_t &count) noexcept {
 3835|  2.86M|  value = value * 10 + limb(*p - UC('0'));
 3836|  2.86M|  p++;
 3837|  2.86M|  counter++;
 3838|  2.86M|  count++;
 3839|  2.86M|}
_ZN3glz10fast_float10add_nativeERNS0_6bigintEmm:
 3842|   997k|add_native(bigint &big, limb power, limb value) noexcept {
 3843|   997k|  big.mul(power);
 3844|   997k|  big.add(value);
 3845|   997k|}
_ZN3glz10fast_float6bigint3mulEm:
 3552|   997k|  GLZ_FASTFLOAT_CONSTEXPR20 bool mul(limb y) noexcept { return small_mul(vec, y); }
_ZN3glz10fast_float9small_mulILt62EEEbRNS0_8stackvecIXT_EEEm:
 3249|  1.70M|                                            limb y) noexcept {
 3250|  1.70M|  limb carry = 0;
 3251|  27.9M|  for (size_t index = 0; index < vec.len(); index++) {
  ------------------
  |  Branch (3251:26): [True: 26.2M, False: 1.70M]
  ------------------
 3252|  26.2M|    vec[index] = scalar_mul(vec[index], y, carry);
 3253|  26.2M|  }
 3254|  1.70M|  if (carry != 0) {
  ------------------
  |  Branch (3254:7): [True: 1.53M, False: 172k]
  ------------------
 3255|  1.53M|    GLZ_FASTFLOAT_TRY(vec.try_push(carry));
  ------------------
  |  |  354|  1.53M|  {                                                                            \
  |  |  355|  1.53M|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 1.53M]
  |  |  ------------------
  |  |  356|  1.53M|      return false;                                                            \
  |  |  357|  1.53M|  }
  ------------------
 3256|  1.53M|  }
 3257|  1.70M|  return true;
 3258|  1.70M|}
_ZNK3glz10fast_float8stackvecILt62EE3lenEv:
 3039|  35.4M|  constexpr size_t len() const noexcept { return length; }
_ZN3glz10fast_float10scalar_mulEmmRm:
 3196|  26.2M|scalar_mul(limb x, limb y, limb &carry) noexcept {
 3197|  26.2M|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3198|  26.2M|#if defined(__SIZEOF_INT128__)
 3199|       |  // GCC and clang both define it as an extension.
 3200|  26.2M|  __uint128_t z = __uint128_t(x) * __uint128_t(y) + __uint128_t(carry);
 3201|  26.2M|  carry = limb(z >> limb_bits);
 3202|  26.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|  26.2M|}
_ZN3glz10fast_float8stackvecILt62EEixEm:
 3017|  64.6M|  GLZ_FASTFLOAT_CONSTEXPR14 limb &operator[](size_t index) noexcept {
 3018|  64.6M|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|  64.6M|  { ((void)(x)); }
  ------------------
 3019|  64.6M|    return data[index];
 3020|  64.6M|  }
_ZN3glz10fast_float8stackvecILt62EE8try_pushEm:
 3052|  1.61M|  GLZ_FASTFLOAT_CONSTEXPR14 bool try_push(limb value) noexcept {
 3053|  1.61M|    if (len() < capacity()) {
  ------------------
  |  Branch (3053:9): [True: 1.61M, False: 0]
  ------------------
 3054|  1.61M|      push_unchecked(value);
 3055|  1.61M|      return true;
 3056|  1.61M|    } else {
 3057|      0|      return false;
 3058|      0|    }
 3059|  1.61M|  }
_ZNK3glz10fast_float8stackvecILt62EE8capacityEv:
 3043|  2.71M|  constexpr size_t capacity() const noexcept { return size; }
_ZN3glz10fast_float8stackvecILt62EE14push_uncheckedEm:
 3046|  1.65M|  GLZ_FASTFLOAT_CONSTEXPR14 void push_unchecked(limb value) noexcept {
 3047|  1.65M|    data[length] = value;
 3048|  1.65M|    length++;
 3049|  1.65M|  }
_ZN3glz10fast_float6bigint3addEm:
 3554|   997k|  GLZ_FASTFLOAT_CONSTEXPR20 bool add(limb y) noexcept { return small_add(vec, y); }
_ZN3glz10fast_float9small_addILt62EEEbRNS0_8stackvecIXT_EEEm:
 3242|   997k|small_add(stackvec<size> &vec, limb y) noexcept {
 3243|   997k|  return small_add_from(vec, y, 0);
 3244|   997k|}
_ZN3glz10fast_float14small_add_fromILt62EEEbRNS0_8stackvecIXT_EEEmm:
 3224|   997k|                                                 size_t start) noexcept {
 3225|   997k|  size_t index = start;
 3226|   997k|  limb carry = y;
 3227|   997k|  bool overflow;
 3228|  1.31M|  while (carry != 0 && index < vec.len()) {
  ------------------
  |  Branch (3228:10): [True: 383k, False: 933k]
  |  Branch (3228:24): [True: 319k, False: 63.9k]
  ------------------
 3229|   319k|    vec[index] = scalar_add(vec[index], carry, overflow);
 3230|   319k|    carry = limb(overflow);
 3231|   319k|    index += 1;
 3232|   319k|  }
 3233|   997k|  if (carry != 0) {
  ------------------
  |  Branch (3233:7): [True: 63.9k, False: 933k]
  ------------------
 3234|  63.9k|    GLZ_FASTFLOAT_TRY(vec.try_push(carry));
  ------------------
  |  |  354|  63.9k|  {                                                                            \
  |  |  355|  63.9k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 63.9k]
  |  |  ------------------
  |  |  356|  63.9k|      return false;                                                            \
  |  |  357|  63.9k|  }
  ------------------
 3235|  63.9k|  }
 3236|   997k|  return true;
 3237|   997k|}
_ZN3glz10fast_float10scalar_addEmmRb:
 3176|  7.52M|scalar_add(limb x, limb y, bool &overflow) noexcept {
 3177|  7.52M|  limb z;
 3178|       |// gcc and clang
 3179|  7.52M|#if defined(__has_builtin)
 3180|  7.52M|#if __has_builtin(__builtin_add_overflow)
 3181|  7.52M|  if (!cpp20_and_in_constexpr()) {
  ------------------
  |  Branch (3181:7): [True: 7.52M, Folded]
  ------------------
 3182|  7.52M|    overflow = __builtin_add_overflow(x, y, &z);
 3183|  7.52M|    return z;
 3184|  7.52M|  }
 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.52M|}
_ZN3glz10fast_float12is_truncatedIcEEbPKT_S4_:
 3795|  30.2k|is_truncated(UC const *first, UC const *last) noexcept {
 3796|       |  // do 8-bit optimizations, can just compare to 8 literal 0s.
 3797|  30.2k|  uint64_t val;
 3798|   215k|  while (!cpp20_and_in_constexpr() &&
  ------------------
  |  Branch (3798:10): [True: 215k, Folded]
  ------------------
 3799|   215k|         std::distance(first, last) >= int_cmp_len<UC>()) {
  ------------------
  |  Branch (3799:10): [True: 190k, False: 25.2k]
  ------------------
 3800|   190k|    ::memcpy(&val, first, sizeof(uint64_t));
 3801|   190k|    if (val != int_cmp_zeros<UC>()) {
  ------------------
  |  Branch (3801:9): [True: 4.99k, False: 185k]
  ------------------
 3802|  4.99k|      return true;
 3803|  4.99k|    }
 3804|   185k|    first += int_cmp_len<UC>();
 3805|   185k|  }
 3806|  62.7k|  while (first != last) {
  ------------------
  |  Branch (3806:10): [True: 48.1k, False: 14.5k]
  ------------------
 3807|  48.1k|    if (*first != UC('0')) {
  ------------------
  |  Branch (3807:9): [True: 10.6k, False: 37.4k]
  ------------------
 3808|  10.6k|      return true;
 3809|  10.6k|    }
 3810|  37.4k|    ++first;
 3811|  37.4k|  }
 3812|  14.5k|  return false;
 3813|  25.2k|}
_ZN3glz10fast_float12is_truncatedIcEEbNS0_4spanIKT_EE:
 3817|  8.70k|is_truncated(span<UC const> s) noexcept {
 3818|  8.70k|  return is_truncated(s.ptr, s.ptr + s.len());
 3819|  8.70k|}
_ZN3glz10fast_float15round_up_bigintERNS0_6bigintERm:
 3848|  12.3k|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|  12.3k|  add_native(big, 10, 1);
 3852|  12.3k|  count++;
 3853|  12.3k|}
_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|  58.5k|  GLZ_FASTFLOAT_CONSTEXPR20 bool pow5(uint32_t exp) noexcept {
 3561|       |    // multiply by a power of 5
 3562|  58.5k|    size_t large_length = sizeof(large_power_of_5) / sizeof(limb);
 3563|  58.5k|    limb_span large = limb_span(large_power_of_5, large_length);
 3564|   177k|    while (exp >= large_step) {
  ------------------
  |  Branch (3564:12): [True: 118k, False: 58.5k]
  ------------------
 3565|   118k|      GLZ_FASTFLOAT_TRY(large_mul(vec, large));
  ------------------
  |  |  354|   118k|  {                                                                            \
  |  |  355|   118k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 118k]
  |  |  ------------------
  |  |  356|   118k|      return false;                                                            \
  |  |  357|   118k|  }
  ------------------
 3566|   118k|      exp -= large_step;
 3567|   118k|    }
 3568|  58.5k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3569|  58.5k|    uint32_t small_step = 27;
 3570|  58.5k|    limb max_native = 7450580596923828125UL;
 3571|       |#else
 3572|       |    uint32_t small_step = 13;
 3573|       |    limb max_native = 1220703125U;
 3574|       |#endif
 3575|   123k|    while (exp >= small_step) {
  ------------------
  |  Branch (3575:12): [True: 65.3k, False: 58.5k]
  ------------------
 3576|  65.3k|      GLZ_FASTFLOAT_TRY(small_mul(vec, max_native));
  ------------------
  |  |  354|  65.3k|  {                                                                            \
  |  |  355|  65.3k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 65.3k]
  |  |  ------------------
  |  |  356|  65.3k|      return false;                                                            \
  |  |  357|  65.3k|  }
  ------------------
 3577|  65.3k|      exp -= small_step;
 3578|  65.3k|    }
 3579|  58.5k|    if (exp != 0) {
  ------------------
  |  Branch (3579:9): [True: 50.3k, False: 8.21k]
  ------------------
 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|  50.3k|      GLZ_FASTFLOAT_TRY(small_mul(
  ------------------
  |  |  354|  50.3k|  {                                                                            \
  |  |  355|  50.3k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 50.3k]
  |  |  ------------------
  |  |  356|  50.3k|      return false;                                                            \
  |  |  357|  50.3k|  }
  ------------------
 3584|  50.3k|          vec, limb(((void)small_power_of_5[0], small_power_of_5[exp]))));
 3585|  50.3k|    }
 3586|       |
 3587|  58.5k|    return true;
 3588|  58.5k|  }
_ZN3glz10fast_float4spanImEC2EPKmm:
  436|   771k|  constexpr span(T const *_ptr, size_t _length) : ptr(_ptr), length(_length) {}
_ZN3glz10fast_float9large_mulILt62EEEbRNS0_8stackvecIXT_EEENS0_4spanImEE:
 3329|   118k|GLZ_FASTFLOAT_CONSTEXPR20 bool large_mul(stackvec<size> &x, limb_span y) noexcept {
 3330|   118k|  if (y.len() == 1) {
  ------------------
  |  Branch (3330:7): [True: 0, False: 118k]
  ------------------
 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|   118k|  } else {
 3333|   118k|    GLZ_FASTFLOAT_TRY(long_mul(x, y));
  ------------------
  |  |  354|   118k|  {                                                                            \
  |  |  355|   118k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 118k]
  |  |  ------------------
  |  |  356|   118k|      return false;                                                            \
  |  |  357|   118k|  }
  ------------------
 3334|   118k|  }
 3335|   118k|  return true;
 3336|   118k|}
_ZNK3glz10fast_float4spanImE3lenEv:
  440|  9.15M|  constexpr size_t len() const noexcept { return length; }
_ZNK3glz10fast_float4spanImEixEm:
  442|  5.71M|  GLZ_FASTFLOAT_CONSTEXPR14 const T &operator[](size_t index) const noexcept {
  443|  5.71M|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|  5.71M|  { ((void)(x)); }
  ------------------
  444|  5.71M|    return ptr[index];
  445|  5.71M|  }
_ZN3glz10fast_float8long_mulILt62EEEbRNS0_8stackvecIXT_EEENS0_4spanImEE:
 3301|   118k|GLZ_FASTFLOAT_CONSTEXPR20 bool long_mul(stackvec<size> &x, limb_span y) noexcept {
 3302|   118k|  limb_span xs = limb_span(x.data, x.len());
 3303|   118k|  stackvec<size> z(xs);
 3304|   118k|  limb_span zs = limb_span(z.data, z.len());
 3305|       |
 3306|   118k|  if (y.len() != 0) {
  ------------------
  |  Branch (3306:7): [True: 118k, False: 0]
  ------------------
 3307|   118k|    limb y0 = y[0];
 3308|   118k|    GLZ_FASTFLOAT_TRY(small_mul(x, y0));
  ------------------
  |  |  354|   118k|  {                                                                            \
  |  |  355|   118k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 118k]
  |  |  ------------------
  |  |  356|   118k|      return false;                                                            \
  |  |  357|   118k|  }
  ------------------
 3309|   593k|    for (size_t index = 1; index < y.len(); index++) {
  ------------------
  |  Branch (3309:28): [True: 475k, False: 118k]
  ------------------
 3310|   475k|      limb yi = y[index];
 3311|   475k|      stackvec<size> zi;
 3312|   475k|      if (yi != 0) {
  ------------------
  |  Branch (3312:11): [True: 475k, False: 0]
  ------------------
 3313|       |        // re-use the same buffer throughout
 3314|   475k|        zi.set_len(0);
 3315|   475k|        GLZ_FASTFLOAT_TRY(zi.try_extend(zs));
  ------------------
  |  |  354|   475k|  {                                                                            \
  |  |  355|   475k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 475k]
  |  |  ------------------
  |  |  356|   475k|      return false;                                                            \
  |  |  357|   475k|  }
  ------------------
 3316|   475k|        GLZ_FASTFLOAT_TRY(small_mul(zi, yi));
  ------------------
  |  |  354|   475k|  {                                                                            \
  |  |  355|   475k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 475k]
  |  |  ------------------
  |  |  356|   475k|      return false;                                                            \
  |  |  357|   475k|  }
  ------------------
 3317|   475k|        limb_span zis = limb_span(zi.data, zi.len());
 3318|   475k|        GLZ_FASTFLOAT_TRY(large_add_from(x, zis, index));
  ------------------
  |  |  354|   475k|  {                                                                            \
  |  |  355|   475k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 475k]
  |  |  ------------------
  |  |  356|   475k|      return false;                                                            \
  |  |  357|   475k|  }
  ------------------
 3319|   475k|      }
 3320|   475k|    }
 3321|   118k|  }
 3322|       |
 3323|   118k|  x.normalize();
 3324|   118k|  return true;
 3325|   118k|}
_ZN3glz10fast_float8stackvecILt62EEC2ENS0_4spanImEE:
 3013|   118k|  GLZ_FASTFLOAT_CONSTEXPR20 stackvec(limb_span s) {
 3014|   118k|    GLZ_FASTFLOAT_ASSERT(try_extend(s));
  ------------------
  |  |  344|   118k|  { ((void)(x)); }
  ------------------
 3015|   118k|  }
_ZN3glz10fast_float8stackvecILt62EE7set_lenEm:
 3035|  1.57M|  GLZ_FASTFLOAT_CONSTEXPR14 void set_len(size_t len) noexcept {
 3036|  1.57M|    length = uint16_t(len);
 3037|  1.57M|  }
_ZN3glz10fast_float8stackvecILt62EE10try_extendENS0_4spanImEE:
 3069|   593k|  GLZ_FASTFLOAT_CONSTEXPR20 bool try_extend(limb_span s) noexcept {
 3070|   593k|    if (len() + s.len() <= capacity()) {
  ------------------
  |  Branch (3070:9): [True: 593k, False: 0]
  ------------------
 3071|   593k|      extend_unchecked(s);
 3072|   593k|      return true;
 3073|   593k|    } else {
 3074|      0|      return false;
 3075|      0|    }
 3076|   593k|  }
_ZN3glz10fast_float8stackvecILt62EE16extend_uncheckedENS0_4spanImEE:
 3062|   593k|  GLZ_FASTFLOAT_CONSTEXPR20 void extend_unchecked(limb_span s) noexcept {
 3063|   593k|    limb *ptr = data + length;
 3064|   593k|    std::copy_n(s.ptr, s.len(), ptr);
 3065|   593k|    set_len(len() + s.len());
 3066|   593k|  }
_ZN3glz10fast_float14large_add_fromILt62EEEbRNS0_8stackvecIXT_EEENS0_4spanImEEm:
 3264|   475k|                                          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|   475k|  if (x.len() < start || y.len() > x.len() - start) {
  ------------------
  |  Branch (3267:7): [True: 0, False: 475k]
  |  Branch (3267:26): [True: 470k, False: 4.38k]
  ------------------
 3268|   470k|    GLZ_FASTFLOAT_TRY(x.try_resize(y.len() + start, 0));
  ------------------
  |  |  354|   470k|  {                                                                            \
  |  |  355|   470k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 470k]
  |  |  ------------------
  |  |  356|   470k|      return false;                                                            \
  |  |  357|   470k|  }
  ------------------
 3269|   470k|  }
 3270|       |
 3271|   475k|  bool carry = false;
 3272|  5.59M|  for (size_t index = 0; index < y.len(); index++) {
  ------------------
  |  Branch (3272:26): [True: 5.11M, False: 475k]
  ------------------
 3273|  5.11M|    limb xi = x[index + start];
 3274|  5.11M|    limb yi = y[index];
 3275|  5.11M|    bool c1 = false;
 3276|  5.11M|    bool c2 = false;
 3277|  5.11M|    xi = scalar_add(xi, yi, c1);
 3278|  5.11M|    if (carry) {
  ------------------
  |  Branch (3278:9): [True: 2.08M, False: 3.02M]
  ------------------
 3279|  2.08M|      xi = scalar_add(xi, 1, c2);
 3280|  2.08M|    }
 3281|  5.11M|    x[index + start] = xi;
 3282|  5.11M|    carry = c1 | c2;
 3283|  5.11M|  }
 3284|       |
 3285|       |  // handle overflow
 3286|   475k|  if (carry) {
  ------------------
  |  Branch (3286:7): [True: 0, False: 475k]
  ------------------
 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|   475k|  return true;
 3290|   475k|}
_ZN3glz10fast_float8stackvecILt62EE10try_resizeEmm:
 3095|   470k|  GLZ_FASTFLOAT_CONSTEXPR20 bool try_resize(size_t new_len, limb value) noexcept {
 3096|   470k|    if (new_len > capacity()) {
  ------------------
  |  Branch (3096:9): [True: 0, False: 470k]
  ------------------
 3097|      0|      return false;
 3098|   470k|    } else {
 3099|   470k|      resize_unchecked(new_len, value);
 3100|   470k|      return true;
 3101|   470k|    }
 3102|   470k|  }
_ZN3glz10fast_float8stackvecILt62EE16resize_uncheckedEmm:
 3082|   470k|  void resize_unchecked(size_t new_len, limb value) noexcept {
 3083|   470k|    if (new_len > len()) {
  ------------------
  |  Branch (3083:9): [True: 470k, False: 0]
  ------------------
 3084|   470k|      size_t count = new_len - len();
 3085|   470k|      limb *first = data + len();
 3086|   470k|      limb *last = first + count;
 3087|   470k|      ::std::fill(first, last, value);
 3088|   470k|      set_len(new_len);
 3089|   470k|    } else {
 3090|      0|      set_len(new_len);
 3091|      0|    }
 3092|   470k|  }
_ZN3glz10fast_float8stackvecILt62EE9normalizeEv:
 3118|   159k|  GLZ_FASTFLOAT_CONSTEXPR14 void normalize() noexcept {
 3119|   159k|    while (len() > 0 && rindex(0) == 0) {
  ------------------
  |  Branch (3119:12): [True: 159k, False: 0]
  |  Branch (3119:25): [True: 0, False: 159k]
  ------------------
 3120|      0|      length--;
 3121|      0|    }
 3122|   159k|  }
_ZNK3glz10fast_float8stackvecILt62EE6rindexEm:
 3028|   219k|  GLZ_FASTFLOAT_CONSTEXPR14 const limb &rindex(size_t index) const noexcept {
 3029|   219k|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|   219k|  { ((void)(x)); }
  ------------------
 3030|   219k|    size_t rindex = length - index - 1;
 3031|   219k|    return data[rindex];
 3032|   219k|  }
_ZN3glz10fast_float6bigint4pow2Ej:
 3557|  57.5k|  GLZ_FASTFLOAT_CONSTEXPR20 bool pow2(uint32_t exp) noexcept { return shl(exp); }
_ZN3glz10fast_float6bigint3shlEm:
 3519|  57.5k|  GLZ_FASTFLOAT_CONSTEXPR20 bool shl(size_t n) noexcept {
 3520|  57.5k|    size_t rem = n % limb_bits;
 3521|  57.5k|    size_t div = n / limb_bits;
 3522|  57.5k|    if (rem != 0) {
  ------------------
  |  Branch (3522:9): [True: 46.6k, False: 10.8k]
  ------------------
 3523|  46.6k|      GLZ_FASTFLOAT_TRY(shl_bits(rem));
  ------------------
  |  |  354|  46.6k|  {                                                                            \
  |  |  355|  46.6k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 46.6k]
  |  |  ------------------
  |  |  356|  46.6k|      return false;                                                            \
  |  |  357|  46.6k|  }
  ------------------
 3524|  46.6k|    }
 3525|  57.5k|    if (div != 0) {
  ------------------
  |  Branch (3525:9): [True: 34.4k, False: 23.0k]
  ------------------
 3526|  34.4k|      GLZ_FASTFLOAT_TRY(shl_limbs(div));
  ------------------
  |  |  354|  34.4k|  {                                                                            \
  |  |  355|  34.4k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 34.4k]
  |  |  ------------------
  |  |  356|  34.4k|      return false;                                                            \
  |  |  357|  34.4k|  }
  ------------------
 3527|  34.4k|    }
 3528|  57.5k|    return true;
 3529|  57.5k|  }
_ZN3glz10fast_float6bigint8shl_bitsEm:
 3472|  46.6k|  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|  46.6k|    GLZ_FASTFLOAT_DEBUG_ASSERT(n != 0);
  ------------------
  |  |  349|  46.6k|  { ((void)(x)); }
  ------------------
 3479|  46.6k|    GLZ_FASTFLOAT_DEBUG_ASSERT(n < sizeof(limb) * 8);
  ------------------
  |  |  349|  46.6k|  { ((void)(x)); }
  ------------------
 3480|       |
 3481|  46.6k|    size_t shl = n;
 3482|  46.6k|    size_t shr = limb_bits - shl;
 3483|  46.6k|    limb prev = 0;
 3484|   714k|    for (size_t index = 0; index < vec.len(); index++) {
  ------------------
  |  Branch (3484:28): [True: 667k, False: 46.6k]
  ------------------
 3485|   667k|      limb xi = vec[index];
 3486|   667k|      vec[index] = (xi << shl) | (prev >> shr);
 3487|   667k|      prev = xi;
 3488|   667k|    }
 3489|       |
 3490|  46.6k|    limb carry = prev >> shr;
 3491|  46.6k|    if (carry != 0) {
  ------------------
  |  Branch (3491:9): [True: 12.5k, False: 34.1k]
  ------------------
 3492|  12.5k|      return vec.try_push(carry);
 3493|  12.5k|    }
 3494|  34.1k|    return true;
 3495|  46.6k|  }
_ZN3glz10fast_float6bigint9shl_limbsEm:
 3498|  34.4k|  GLZ_FASTFLOAT_CONSTEXPR20 bool shl_limbs(size_t n) noexcept {
 3499|  34.4k|    GLZ_FASTFLOAT_DEBUG_ASSERT(n != 0);
  ------------------
  |  |  349|  34.4k|  { ((void)(x)); }
  ------------------
 3500|  34.4k|    if (n + vec.len() > vec.capacity()) {
  ------------------
  |  Branch (3500:9): [True: 0, False: 34.4k]
  ------------------
 3501|      0|      return false;
 3502|  34.4k|    } else if (!vec.is_empty()) {
  ------------------
  |  Branch (3502:16): [True: 34.4k, False: 0]
  ------------------
 3503|       |      // move limbs
 3504|  34.4k|      limb *dst = vec.data + n;
 3505|  34.4k|      limb const *src = vec.data;
 3506|  34.4k|      std::copy_backward(src, src + vec.len(), dst + vec.len());
 3507|       |      // fill in empty limbs
 3508|  34.4k|      limb *first = vec.data;
 3509|  34.4k|      limb *last = first + n;
 3510|  34.4k|      ::std::fill(first, last, 0);
 3511|  34.4k|      vec.set_len(n + vec.len());
 3512|  34.4k|      return true;
 3513|  34.4k|    } else {
 3514|      0|      return true;
 3515|      0|    }
 3516|  34.4k|  }
_ZNK3glz10fast_float8stackvecILt62EE8is_emptyEv:
 3041|  52.2k|  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.56k, False: 13.2k]
  ------------------
 3423|  4.56k|      return uint64_hi64(vec.rindex(0), truncated);
 3424|  13.2k|    } else {
 3425|  13.2k|      uint64_t result = uint64_hi64(vec.rindex(0), vec.rindex(1), truncated);
 3426|  13.2k|      truncated |= vec.nonzero(2);
 3427|  13.2k|      return result;
 3428|  13.2k|    }
 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.56k|uint64_hi64(uint64_t r0, bool &truncated) noexcept {
 3133|  4.56k|  truncated = false;
 3134|  4.56k|  int shl = leading_zeroes(r0);
 3135|  4.56k|  return r0 << shl;
 3136|  4.56k|}
_ZN3glz10fast_float11uint64_hi64EmmRb:
 3139|  13.2k|uint64_hi64(uint64_t r0, uint64_t r1, bool &truncated) noexcept {
 3140|  13.2k|  int shl = leading_zeroes(r0);
 3141|  13.2k|  if (shl == 0) {
  ------------------
  |  Branch (3141:7): [True: 1.48k, False: 11.7k]
  ------------------
 3142|  1.48k|    truncated = r1 != 0;
 3143|  1.48k|    return r0;
 3144|  11.7k|  } else {
 3145|  11.7k|    int shr = 64 - shl;
 3146|  11.7k|    truncated = (r1 << shl) != 0;
 3147|  11.7k|    return (r0 << shl) | (r1 >> shr);
 3148|  11.7k|  }
 3149|  13.2k|}
_ZNK3glz10fast_float8stackvecILt62EE7nonzeroEm:
 3107|  13.2k|  GLZ_FASTFLOAT_CONSTEXPR14 bool nonzero(size_t index) const noexcept {
 3108|  18.0k|    while (index < len()) {
  ------------------
  |  Branch (3108:12): [True: 10.8k, False: 7.15k]
  ------------------
 3109|  10.8k|      if (rindex(index) != 0) {
  ------------------
  |  Branch (3109:11): [True: 6.06k, False: 4.82k]
  ------------------
 3110|  6.06k|        return true;
 3111|  6.06k|      }
 3112|  4.82k|      index++;
 3113|  4.82k|    }
 3114|  7.15k|    return false;
 3115|  13.2k|  }
_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.2k]
  ------------------
 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: 4.00k, False: 13.7k]
  |  Branch (3955:31): [True: 9.95k, False: 3.81k]
  |  Branch (3955:45): [True: 4.65k, False: 5.30k]
  ------------------
 3956|  9.12k|                 (is_odd && is_halfway);
  ------------------
  |  Branch (3956:19): [True: 2.77k, False: 6.34k]
  |  Branch (3956:29): [True: 42, False: 2.73k]
  ------------------
 3957|  17.7k|        });
_ZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_i:
 3970|  40.7k|    bigint &bigmant, adjusted_mantissa am, int32_t exponent) noexcept {
 3971|  40.7k|  bigint &real_digits = bigmant;
 3972|  40.7k|  int32_t real_exp = exponent;
 3973|       |
 3974|       |  // get the value of `b`, rounded down, and get a bigint representation of b+h
 3975|  40.7k|  adjusted_mantissa am_b = am;
 3976|       |  // gcc7 buf: use a lambda to remove the noexcept qualifier bug with
 3977|       |  // -Wnoexcept-type.
 3978|  40.7k|  round<T>(am_b,
 3979|  40.7k|           [](adjusted_mantissa &a, int32_t shift) { round_down(a, shift); });
 3980|  40.7k|  T b;
 3981|  40.7k|  to_float(false, am_b, b);
 3982|  40.7k|  adjusted_mantissa theor = to_extended_halfway(b);
 3983|  40.7k|  bigint theor_digits(theor.mantissa);
 3984|  40.7k|  int32_t theor_exp = theor.power2;
 3985|       |
 3986|       |  // scale real digits and theor digits to be same power.
 3987|  40.7k|  int32_t pow2_exp = theor_exp - real_exp;
 3988|  40.7k|  uint32_t pow5_exp = uint32_t(-real_exp);
 3989|  40.7k|  if (pow5_exp != 0) {
  ------------------
  |  Branch (3989:7): [True: 40.7k, False: 0]
  ------------------
 3990|  40.7k|    GLZ_FASTFLOAT_ASSERT(theor_digits.pow5(pow5_exp));
  ------------------
  |  |  344|  40.7k|  { ((void)(x)); }
  ------------------
 3991|  40.7k|  }
 3992|  40.7k|  if (pow2_exp > 0) {
  ------------------
  |  Branch (3992:7): [True: 28.2k, False: 12.5k]
  ------------------
 3993|  28.2k|    GLZ_FASTFLOAT_ASSERT(theor_digits.pow2(uint32_t(pow2_exp)));
  ------------------
  |  |  344|  28.2k|  { ((void)(x)); }
  ------------------
 3994|  28.2k|  } else if (pow2_exp < 0) {
  ------------------
  |  Branch (3994:14): [True: 11.5k, False: 984]
  ------------------
 3995|  11.5k|    GLZ_FASTFLOAT_ASSERT(real_digits.pow2(uint32_t(-pow2_exp)));
  ------------------
  |  |  344|  11.5k|  { ((void)(x)); }
  ------------------
 3996|  11.5k|  }
 3997|       |
 3998|       |  // compare digits, and use it to director rounding
 3999|  40.7k|  int ord = real_digits.compare(theor_digits);
 4000|  40.7k|  adjusted_mantissa answer = am;
 4001|  40.7k|  round<T>(answer, [ord](adjusted_mantissa &a, int32_t shift) {
 4002|  40.7k|    round_nearest_tie_even(
 4003|  40.7k|        a, shift, [ord](bool is_odd, bool _, bool __) -> bool {
 4004|  40.7k|          (void)_;  // not needed, since we've done our comparison
 4005|  40.7k|          (void)__; // not needed, since we've done our comparison
 4006|  40.7k|          if (ord > 0) {
 4007|  40.7k|            return true;
 4008|  40.7k|          } else if (ord < 0) {
 4009|  40.7k|            return false;
 4010|  40.7k|          } else {
 4011|  40.7k|            return is_odd;
 4012|  40.7k|          }
 4013|  40.7k|        });
 4014|  40.7k|  });
 4015|       |
 4016|  40.7k|  return answer;
 4017|  40.7k|}
_ZN3glz10fast_float5roundIdZNS0_19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES3_iEUlRS3_iE_EEvS6_T0_:
 3707|  40.7k|                                                         callback cb) noexcept {
 3708|  40.7k|  int32_t mantissa_shift = 64 - binary_format<T>::mantissa_explicit_bits() - 1;
 3709|  40.7k|  if (-am.power2 >= mantissa_shift) {
  ------------------
  |  Branch (3709:7): [True: 4.63k, False: 36.1k]
  ------------------
 3710|       |    // have a denormal float
 3711|  4.63k|    int32_t shift = -am.power2 + 1;
 3712|  4.63k|    cb(am, (std::min<int32_t>)(shift, 64));
 3713|       |    // check for round-up: if rounding-nearest carried us to the hidden bit.
 3714|  4.63k|    am.power2 = (am.mantissa <
  ------------------
  |  Branch (3714:17): [True: 4.63k, False: 0]
  ------------------
 3715|  4.63k|                 (uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))
 3716|  4.63k|                    ? 0
 3717|  4.63k|                    : 1;
 3718|  4.63k|    return;
 3719|  4.63k|  }
 3720|       |
 3721|       |  // have a normal float, use the default shift.
 3722|  36.1k|  cb(am, mantissa_shift);
 3723|       |
 3724|       |  // check for carry
 3725|  36.1k|  if (am.mantissa >=
  ------------------
  |  Branch (3725:7): [True: 0, False: 36.1k]
  ------------------
 3726|  36.1k|      (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.1k|  am.mantissa &= ~(uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3733|  36.1k|  if (am.power2 >= binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (3733:7): [True: 0, False: 36.1k]
  ------------------
 3734|      0|    am.power2 = binary_format<T>::infinite_power();
 3735|      0|    am.mantissa = 0;
 3736|      0|  }
 3737|  36.1k|}
_ZZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_iENKUlRS2_iE_clES5_i:
 3979|  40.7k|           [](adjusted_mantissa &a, int32_t shift) { round_down(a, shift); });
_ZN3glz10fast_float10round_downERNS0_17adjusted_mantissaEi:
 3762|  40.7k|round_down(adjusted_mantissa &am, int32_t shift) noexcept {
 3763|  40.7k|  if (shift == 64) {
  ------------------
  |  Branch (3763:7): [True: 1.07k, False: 39.6k]
  ------------------
 3764|  1.07k|    am.mantissa = 0;
 3765|  39.6k|  } else {
 3766|  39.6k|    am.mantissa >>= shift;
 3767|  39.6k|  }
 3768|  40.7k|  am.power2 += shift;
 3769|  40.7k|}
_ZN3glz10fast_float19to_extended_halfwayIdEENS0_17adjusted_mantissaET_:
 3696|  40.7k|to_extended_halfway(T value) noexcept {
 3697|  40.7k|  adjusted_mantissa am = to_extended(value);
 3698|  40.7k|  am.mantissa <<= 1;
 3699|  40.7k|  am.mantissa += 1;
 3700|  40.7k|  am.power2 -= 1;
 3701|  40.7k|  return am;
 3702|  40.7k|}
_ZN3glz10fast_float11to_extendedIdEENS0_17adjusted_mantissaET_:
 3661|  40.7k|to_extended(T value) noexcept {
 3662|  40.7k|  using equiv_uint = equiv_uint_t<T>;
 3663|  40.7k|  constexpr equiv_uint exponent_mask = binary_format<T>::exponent_mask();
 3664|  40.7k|  constexpr equiv_uint mantissa_mask = binary_format<T>::mantissa_mask();
 3665|  40.7k|  constexpr equiv_uint hidden_bit_mask = binary_format<T>::hidden_bit_mask();
 3666|       |
 3667|  40.7k|  adjusted_mantissa am;
 3668|  40.7k|  int32_t bias = binary_format<T>::mantissa_explicit_bits() -
 3669|  40.7k|                 binary_format<T>::minimum_exponent();
 3670|  40.7k|  equiv_uint bits;
 3671|  40.7k|#if GLZ_FASTFLOAT_HAS_BIT_CAST
 3672|  40.7k|  bits = std::bit_cast<equiv_uint>(value);
 3673|       |#else
 3674|       |  ::memcpy(&bits, &value, sizeof(T));
 3675|       |#endif
 3676|  40.7k|  if ((bits & exponent_mask) == 0) {
  ------------------
  |  Branch (3676:7): [True: 4.63k, False: 36.1k]
  ------------------
 3677|       |    // denormal
 3678|  4.63k|    am.power2 = 1 - bias;
 3679|  4.63k|    am.mantissa = bits & mantissa_mask;
 3680|  36.1k|  } else {
 3681|       |    // normal
 3682|  36.1k|    am.power2 = int32_t((bits & exponent_mask) >>
 3683|  36.1k|                        binary_format<T>::mantissa_explicit_bits());
 3684|  36.1k|    am.power2 -= bias;
 3685|  36.1k|    am.mantissa = (bits & mantissa_mask) | hidden_bit_mask;
 3686|  36.1k|  }
 3687|       |
 3688|  40.7k|  return am;
 3689|  40.7k|}
_ZN3glz10fast_float6bigintC2Em:
 3406|  40.7k|  GLZ_FASTFLOAT_CONSTEXPR20 bigint(uint64_t value) : vec() {
 3407|  40.7k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3408|  40.7k|    vec.push_unchecked(value);
 3409|       |#else
 3410|       |    vec.push_unchecked(uint32_t(value));
 3411|       |    vec.push_unchecked(uint32_t(value >> 32));
 3412|       |#endif
 3413|  40.7k|    vec.normalize();
 3414|  40.7k|  }
_ZNK3glz10fast_float6bigint7compareERKS1_:
 3451|  40.7k|  GLZ_FASTFLOAT_CONSTEXPR20 int compare(bigint const &other) const noexcept {
 3452|  40.7k|    if (vec.len() > other.vec.len()) {
  ------------------
  |  Branch (3452:9): [True: 0, False: 40.7k]
  ------------------
 3453|      0|      return 1;
 3454|  40.7k|    } else if (vec.len() < other.vec.len()) {
  ------------------
  |  Branch (3454:16): [True: 0, False: 40.7k]
  ------------------
 3455|      0|      return -1;
 3456|  40.7k|    } else {
 3457|  84.3k|      for (size_t index = vec.len(); index > 0; index--) {
  ------------------
  |  Branch (3457:38): [True: 81.2k, False: 3.10k]
  ------------------
 3458|  81.2k|        limb xi = vec[index - 1];
 3459|  81.2k|        limb yi = other.vec[index - 1];
 3460|  81.2k|        if (xi > yi) {
  ------------------
  |  Branch (3460:13): [True: 14.1k, False: 67.0k]
  ------------------
 3461|  14.1k|          return 1;
 3462|  67.0k|        } else if (xi < yi) {
  ------------------
  |  Branch (3462:20): [True: 23.5k, False: 43.5k]
  ------------------
 3463|  23.5k|          return -1;
 3464|  23.5k|        }
 3465|  81.2k|      }
 3466|  3.10k|      return 0;
 3467|  40.7k|    }
 3468|  40.7k|  }
_ZNK3glz10fast_float8stackvecILt62EEixEm:
 3022|   162k|  GLZ_FASTFLOAT_CONSTEXPR14 const limb &operator[](size_t index) const noexcept {
 3023|   162k|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|   162k|  { ((void)(x)); }
  ------------------
 3024|   162k|    return data[index];
 3025|   162k|  }
_ZN3glz10fast_float5roundIdZNS0_19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES3_iEUlRS3_iE0_EEvS6_T0_:
 3707|  40.7k|                                                         callback cb) noexcept {
 3708|  40.7k|  int32_t mantissa_shift = 64 - binary_format<T>::mantissa_explicit_bits() - 1;
 3709|  40.7k|  if (-am.power2 >= mantissa_shift) {
  ------------------
  |  Branch (3709:7): [True: 4.63k, False: 36.1k]
  ------------------
 3710|       |    // have a denormal float
 3711|  4.63k|    int32_t shift = -am.power2 + 1;
 3712|  4.63k|    cb(am, (std::min<int32_t>)(shift, 64));
 3713|       |    // check for round-up: if rounding-nearest carried us to the hidden bit.
 3714|  4.63k|    am.power2 = (am.mantissa <
  ------------------
  |  Branch (3714:17): [True: 4.62k, False: 6]
  ------------------
 3715|  4.63k|                 (uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))
 3716|  4.63k|                    ? 0
 3717|  4.63k|                    : 1;
 3718|  4.63k|    return;
 3719|  4.63k|  }
 3720|       |
 3721|       |  // have a normal float, use the default shift.
 3722|  36.1k|  cb(am, mantissa_shift);
 3723|       |
 3724|       |  // check for carry
 3725|  36.1k|  if (am.mantissa >=
  ------------------
  |  Branch (3725:7): [True: 1.83k, False: 34.2k]
  ------------------
 3726|  36.1k|      (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.1k|  am.mantissa &= ~(uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3733|  36.1k|  if (am.power2 >= binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (3733:7): [True: 0, False: 36.1k]
  ------------------
 3734|      0|    am.power2 = binary_format<T>::infinite_power();
 3735|      0|    am.mantissa = 0;
 3736|      0|  }
 3737|  36.1k|}
_ZZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_iENKUlRS2_iE0_clES5_i:
 4001|  40.7k|  round<T>(answer, [ord](adjusted_mantissa &a, int32_t shift) {
 4002|  40.7k|    round_nearest_tie_even(
 4003|  40.7k|        a, shift, [ord](bool is_odd, bool _, bool __) -> bool {
 4004|  40.7k|          (void)_;  // not needed, since we've done our comparison
 4005|  40.7k|          (void)__; // not needed, since we've done our comparison
 4006|  40.7k|          if (ord > 0) {
 4007|  40.7k|            return true;
 4008|  40.7k|          } else if (ord < 0) {
 4009|  40.7k|            return false;
 4010|  40.7k|          } else {
 4011|  40.7k|            return is_odd;
 4012|  40.7k|          }
 4013|  40.7k|        });
 4014|  40.7k|  });
_ZN3glz10fast_float22round_nearest_tie_evenIZZNS0_19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES3_iENKUlRS3_iE0_clES6_iEUlbbbE_EEvS6_iT_:
 3742|  40.7k|                       callback cb) noexcept {
 3743|  40.7k|  uint64_t const mask = (shift == 64) ? UINT64_MAX : (uint64_t(1) << shift) - 1;
  ------------------
  |  Branch (3743:25): [True: 1.07k, False: 39.6k]
  ------------------
 3744|  40.7k|  uint64_t const halfway = (shift == 0) ? 0 : uint64_t(1) << (shift - 1);
  ------------------
  |  Branch (3744:28): [True: 0, False: 40.7k]
  ------------------
 3745|  40.7k|  uint64_t truncated_bits = am.mantissa & mask;
 3746|  40.7k|  bool is_above = truncated_bits > halfway;
 3747|  40.7k|  bool is_halfway = truncated_bits == halfway;
 3748|       |
 3749|       |  // shift digits into position
 3750|  40.7k|  if (shift == 64) {
  ------------------
  |  Branch (3750:7): [True: 1.07k, False: 39.6k]
  ------------------
 3751|  1.07k|    am.mantissa = 0;
 3752|  39.6k|  } else {
 3753|  39.6k|    am.mantissa >>= shift;
 3754|  39.6k|  }
 3755|  40.7k|  am.power2 += shift;
 3756|       |
 3757|  40.7k|  bool is_odd = (am.mantissa & 1) == 1;
 3758|  40.7k|  am.mantissa += uint64_t(cb(is_odd, is_halfway, is_above));
 3759|  40.7k|}
_ZZZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_iENKUlRS2_iE0_clES5_iENKUlbbbE_clEbbb:
 4003|  40.7k|        a, shift, [ord](bool is_odd, bool _, bool __) -> bool {
 4004|  40.7k|          (void)_;  // not needed, since we've done our comparison
 4005|  40.7k|          (void)__; // not needed, since we've done our comparison
 4006|  40.7k|          if (ord > 0) {
  ------------------
  |  Branch (4006:15): [True: 14.1k, False: 26.6k]
  ------------------
 4007|  14.1k|            return true;
 4008|  26.6k|          } else if (ord < 0) {
  ------------------
  |  Branch (4008:22): [True: 23.5k, False: 3.10k]
  ------------------
 4009|  23.5k|            return false;
 4010|  23.5k|          } else {
 4011|  3.10k|            return is_odd;
 4012|  3.10k|          }
 4013|  40.7k|        });
_ZN3glz10fast_float8to_floatIdEEvbNS0_17adjusted_mantissaERT_:
 1131|   121k|to_float(bool negative, adjusted_mantissa am, T &value) {
 1132|   121k|  using equiv_uint = equiv_uint_t<T>;
 1133|   121k|  equiv_uint word = equiv_uint(am.mantissa);
 1134|   121k|  word = equiv_uint(word | equiv_uint(am.power2)
 1135|   121k|                               << binary_format<T>::mantissa_explicit_bits());
 1136|   121k|  word =
 1137|   121k|      equiv_uint(word | equiv_uint(negative) << binary_format<T>::sign_index());
 1138|   121k|#if GLZ_FASTFLOAT_HAS_BIT_CAST
 1139|   121k|  value = std::bit_cast<T>(word);
 1140|       |#else
 1141|       |  ::memcpy(&value, &word, sizeof(T));
 1142|       |#endif
 1143|   121k|}
_ZN3glz10fast_float13binary_formatIdE10sign_indexEv:
  758|   121k|template <> inline constexpr int binary_format<double>::sign_index() {
  759|   121k|  return 63;
  760|   121k|}
_ZN3glz10fast_float13binary_formatIdE14infinite_powerEv:
  750|   308k|template <> inline constexpr int binary_format<double>::infinite_power() {
  751|   308k|  return 0x7FF;
  752|   308k|}

_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|   645k|   {
   25|   645k|      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|   645k|         else {
   47|   645k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|   645k|               (void)(lambda.template operator()<I>(), ...);
   49|   645k|            }(std::make_index_sequence<N>{});
   50|   645k|         }
   51|   645k|      }
   52|   645k|   }
_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|   645k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|   645k|               (void)(lambda.template operator()<I>(), ...);
   49|   645k|            }(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.89k|   {
   25|  6.89k|      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.89k|         else {
   47|  6.89k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  6.89k|               (void)(lambda.template operator()<I>(), ...);
   49|  6.89k|            }(std::make_index_sequence<N>{});
   50|  6.89k|         }
   51|  6.89k|      }
   52|  6.89k|   }
_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.89k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  6.89k|               (void)(lambda.template operator()<I>(), ...);
   49|  6.89k|            }(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.34k|   {
   25|  1.34k|      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.34k|         else {
   47|  1.34k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.34k|               (void)(lambda.template operator()<I>(), ...);
   49|  1.34k|            }(std::make_index_sequence<N>{});
   50|  1.34k|         }
   51|  1.34k|      }
   52|  1.34k|   }
_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.34k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.34k|               (void)(lambda.template operator()<I>(), ...);
   49|  1.34k|            }(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|  2.02M|   {
   25|  2.02M|      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|  2.02M|         else {
   47|  2.02M|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  2.02M|               (void)(lambda.template operator()<I>(), ...);
   49|  2.02M|            }(std::make_index_sequence<N>{});
   50|  2.02M|         }
   51|  2.02M|      }
   52|  2.02M|   }
_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|  2.02M|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  2.02M|               (void)(lambda.template operator()<I>(), ...);
   49|  2.02M|            }(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|   645k|   {
   25|   645k|      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|   645k|         else {
   47|   645k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|   645k|               (void)(lambda.template operator()<I>(), ...);
   49|   645k|            }(std::make_index_sequence<N>{});
   50|   645k|         }
   51|   645k|      }
   52|   645k|   }
_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|   645k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|   645k|               (void)(lambda.template operator()<I>(), ...);
   49|   645k|            }(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.89k|   {
   25|  6.89k|      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.89k|         else {
   47|  6.89k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  6.89k|               (void)(lambda.template operator()<I>(), ...);
   49|  6.89k|            }(std::make_index_sequence<N>{});
   50|  6.89k|         }
   51|  6.89k|      }
   52|  6.89k|   }
_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.89k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  6.89k|               (void)(lambda.template operator()<I>(), ...);
   49|  6.89k|            }(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.34k|   {
   25|  1.34k|      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.34k|         else {
   47|  1.34k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.34k|               (void)(lambda.template operator()<I>(), ...);
   49|  1.34k|            }(std::make_index_sequence<N>{});
   50|  1.34k|         }
   51|  1.34k|      }
   52|  1.34k|   }
_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.34k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.34k|               (void)(lambda.template operator()<I>(), ...);
   49|  1.34k|            }(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|  2.02M|   {
   25|  2.02M|      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|  2.02M|         else {
   47|  2.02M|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  2.02M|               (void)(lambda.template operator()<I>(), ...);
   49|  2.02M|            }(std::make_index_sequence<N>{});
   50|  2.02M|         }
   51|  2.02M|      }
   52|  2.02M|   }
_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|  2.02M|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  2.02M|               (void)(lambda.template operator()<I>(), ...);
   49|  2.02M|            }(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|   645k|   {
   25|   645k|      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|   645k|         else {
   47|   645k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|   645k|               (void)(lambda.template operator()<I>(), ...);
   49|   645k|            }(std::make_index_sequence<N>{});
   50|   645k|         }
   51|   645k|      }
   52|   645k|   }
_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|   645k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|   645k|               (void)(lambda.template operator()<I>(), ...);
   49|   645k|            }(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.89k|   {
   25|  6.89k|      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.89k|         else {
   47|  6.89k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  6.89k|               (void)(lambda.template operator()<I>(), ...);
   49|  6.89k|            }(std::make_index_sequence<N>{});
   50|  6.89k|         }
   51|  6.89k|      }
   52|  6.89k|   }
_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.89k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  6.89k|               (void)(lambda.template operator()<I>(), ...);
   49|  6.89k|            }(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.34k|   {
   25|  1.34k|      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.34k|         else {
   47|  1.34k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.34k|               (void)(lambda.template operator()<I>(), ...);
   49|  1.34k|            }(std::make_index_sequence<N>{});
   50|  1.34k|         }
   51|  1.34k|      }
   52|  1.34k|   }
_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.34k|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  1.34k|               (void)(lambda.template operator()<I>(), ...);
   49|  1.34k|            }(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|  2.02M|   {
   25|  2.02M|      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|  2.02M|         else {
   47|  2.02M|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  2.02M|               (void)(lambda.template operator()<I>(), ...);
   49|  2.02M|            }(std::make_index_sequence<N>{});
   50|  2.02M|         }
   51|  2.02M|      }
   52|  2.02M|   }
_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|  2.02M|            [&]<size_t... I>(std::index_sequence<I...>) {
   48|  2.02M|               (void)(lambda.template operator()<I>(), ...);
   49|  2.02M|            }(std::make_index_sequence<N>{});

_ZN3glz10from_charsILb0EdcEENS_10fast_float19from_chars_result_tIT1_EEPKS3_S6_RT0_:
  236|  2.02M|   {
  237|  2.02M|      using namespace glz::fast_float;
  238|  2.02M|      static_assert(is_supported_float_type<T>(), "only some floating-point types are supported");
  239|  2.02M|      static_assert(is_supported_char_type<UC>(), "only char, wchar_t, char16_t and char32_t are supported");
  240|       |
  241|  2.02M|      parsed_number_string_t<UC> pns = glz::parse_number_string<null_terminated, UC>(first, last);
  242|  2.02M|      if (!pns.valid) [[unlikely]] {
  ------------------
  |  Branch (242:11): [True: 1.13k, False: 2.02M]
  ------------------
  243|  1.13k|         return {.ptr = first, .ec = std::errc::invalid_argument};
  244|  1.13k|      }
  245|       |
  246|  2.02M|      return from_chars_advanced(pns, value);
  247|  2.02M|   }
_ZN3glz19parse_number_stringILb0EcEENS_10fast_float22parsed_number_string_tIT0_EEPKS3_S6_:
   18|  2.02M|   {
   19|  2.02M|      using namespace glz::fast_float;
   20|  2.02M|      static constexpr UC decimal_point = '.';
   21|       |
   22|  2.02M|      parsed_number_string_t<UC> answer;
   23|  2.02M|      answer.valid = false;
   24|  2.02M|      answer.too_many_digits = false;
   25|  2.02M|      answer.negative = (*p == UC('-'));
   26|  2.02M|      if (*p == UC('-')) { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here
  ------------------
  |  Branch (26:11): [True: 3.21k, False: 2.02M]
  ------------------
   27|  3.21k|         ++p;
   28|       |
   29|  3.21k|         if constexpr (not null_terminated) {
   30|  3.21k|            if (p == pend) [[unlikely]] {
  ------------------
  |  Branch (30:17): [True: 4, False: 3.21k]
  ------------------
   31|      4|               return answer;
   32|      4|            }
   33|  3.21k|         }
   34|       |
   35|  3.21k|         if (!glz::fast_float::is_integer(*p)) [[unlikely]] { // a sign must be followed by an integer
  ------------------
  |  Branch (35:14): [True: 18, False: 3.19k]
  ------------------
   36|     18|            return answer;
   37|     18|         }
   38|  3.21k|      }
   39|  2.02M|      UC const* const start_digits = p;
   40|       |
   41|  2.02M|      uint64_t i = 0; // an unsigned int avoids signed overflows (which are bad)
   42|       |
   43|  2.02M|      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|  2.02M|      else {
   53|  12.5M|         while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9) {
  ------------------
  |  Branch (53:17): [True: 12.5M, False: 807]
  |  Branch (53:32): [True: 10.5M, False: 2.02M]
  ------------------
   54|       |            // a multiplication by 10 is cheaper than an arbitrary integer
   55|       |            // multiplication
   56|  10.5M|            i = 10 * i + digit; // might overflow, we will handle the overflow later
   57|  10.5M|            ++p;
   58|  10.5M|         }
   59|  2.02M|      }
   60|       |
   61|  2.02M|      UC const* const end_of_integer_part = p;
   62|  2.02M|      int64_t digit_count = int64_t(end_of_integer_part - start_digits);
   63|  2.02M|      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|  2.02M|      if (digit_count == 0 || (start_digits[0] == UC('0') && digit_count > 1)) {
  ------------------
  |  Branch (66:11): [True: 1.02k, False: 2.02M]
  |  Branch (66:32): [True: 849k, False: 1.17M]
  |  Branch (66:62): [True: 64, False: 849k]
  ------------------
   67|  1.08k|         return answer;
   68|  1.08k|      }
   69|       |
   70|  2.02M|      int64_t exponent = 0;
   71|  2.02M|      const bool has_decimal_point = [&] {
   72|  2.02M|         if constexpr (null_terminated) {
   73|  2.02M|            return (*p == decimal_point);
   74|  2.02M|         }
   75|  2.02M|         else {
   76|  2.02M|            return (p != pend) && (*p == decimal_point);
   77|  2.02M|         }
   78|  2.02M|      }();
   79|  2.02M|      if (has_decimal_point) {
  ------------------
  |  Branch (79:11): [True: 15.4k, False: 2.01M]
  ------------------
   80|  15.4k|         ++p;
   81|  15.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|  15.4k|         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.4k|         else {
   93|  60.9k|            while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9) {
  ------------------
  |  Branch (93:20): [True: 59.9k, False: 987]
  |  Branch (93:35): [True: 45.4k, False: 14.4k]
  ------------------
   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.4k|         }
   98|  15.4k|         exponent = before - p;
   99|  15.4k|         answer.fraction = glz::fast_float::span<const UC>(before, size_t(p - before));
  100|  15.4k|         digit_count -= exponent;
  101|  15.4k|      }
  102|       |      // at least 1 digit in fractional part
  103|  2.02M|      if (has_decimal_point && exponent == 0) {
  ------------------
  |  Branch (103:11): [True: 15.4k, False: 2.01M]
  |  Branch (103:32): [True: 27, False: 15.3k]
  ------------------
  104|     27|         return answer;
  105|     27|      }
  106|       |
  107|  2.02M|      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|  2.02M|      else {
  140|  2.02M|         if ((p != pend) && ((UC('e') == *p) || (UC('E') == *p))) {
  ------------------
  |  Branch (140:14): [True: 2.02M, False: 1.76k]
  |  Branch (140:30): [True: 6.61k, False: 2.01M]
  |  Branch (140:49): [True: 7.59k, False: 2.01M]
  ------------------
  141|  14.2k|            UC const* location_of_e = p;
  142|  14.2k|            ++p;
  143|  14.2k|            bool neg_exp = false;
  144|  14.2k|            if ((p != pend) && (UC('-') == *p)) {
  ------------------
  |  Branch (144:17): [True: 14.1k, False: 17]
  |  Branch (144:32): [True: 7.89k, False: 6.29k]
  ------------------
  145|  7.89k|               neg_exp = true;
  146|  7.89k|               ++p;
  147|  7.89k|            }
  148|  6.31k|            else if ((p != pend) && (UC('+') == *p)) { // '+' on exponent is allowed by C++17 20.19.3.(7.1)
  ------------------
  |  Branch (148:22): [True: 6.29k, False: 17]
  |  Branch (148:37): [True: 258, False: 6.04k]
  ------------------
  149|    258|               ++p;
  150|    258|            }
  151|  14.2k|            if ((p == pend) || (digit = glz::fast_float::digit_value(*p)) > 9) {
  ------------------
  |  Branch (151:17): [True: 32, False: 14.1k]
  |  Branch (151:32): [True: 28, False: 14.1k]
  ------------------
  152|       |               // Otherwise, we will be ignoring the 'e'.
  153|     60|               p = location_of_e;
  154|     60|            }
  155|  14.1k|            else {
  156|  37.5k|               do {
  157|  37.5k|                  if (exp_number < 0x10000000) {
  ------------------
  |  Branch (157:23): [True: 37.0k, False: 443]
  ------------------
  158|  37.0k|                     exp_number = 10 * exp_number + digit;
  159|  37.0k|                  }
  160|  37.5k|                  ++p;
  161|  37.5k|               } while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9);
  ------------------
  |  Branch (161:25): [True: 36.3k, False: 1.17k]
  |  Branch (161:40): [True: 23.3k, False: 12.9k]
  ------------------
  162|  14.1k|               if (neg_exp) {
  ------------------
  |  Branch (162:20): [True: 7.88k, False: 6.26k]
  ------------------
  163|  7.88k|                  exp_number = -exp_number;
  164|  7.88k|               }
  165|  14.1k|               exponent += exp_number;
  166|  14.1k|            }
  167|  14.2k|         }
  168|  2.02M|      }
  169|       |
  170|  2.02M|      answer.lastmatch = p;
  171|  2.02M|      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|  2.02M|      if (digit_count > 19) { // this is uncommon
  ------------------
  |  Branch (178:11): [True: 23.2k, False: 2.00M]
  ------------------
  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.2k|         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.2k|         else {
  193|  1.34M|            while ((start != pend) && (*start == UC('0') || *start == decimal_point)) {
  ------------------
  |  Branch (193:20): [True: 1.34M, False: 27]
  |  Branch (193:40): [True: 1.31M, False: 30.2k]
  |  Branch (193:61): [True: 7.04k, False: 23.2k]
  ------------------
  194|  1.32M|               if (*start == UC('0')) {
  ------------------
  |  Branch (194:20): [True: 1.31M, False: 7.04k]
  ------------------
  195|  1.31M|                  --digit_count;
  196|  1.31M|               }
  197|  1.32M|               ++start;
  198|  1.32M|            }
  199|  23.2k|         }
  200|       |
  201|  23.2k|         if (digit_count > 19) {
  ------------------
  |  Branch (201:14): [True: 22.9k, False: 318]
  ------------------
  202|  22.9k|            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|  22.9k|            i = 0;
  207|  22.9k|            p = answer.integer.ptr;
  208|  22.9k|            UC const* int_end = p + answer.integer.len();
  209|  22.9k|            const uint64_t minimal_nineteen_digit_integer{1000000000000000000};
  210|   364k|            while ((i < minimal_nineteen_digit_integer) && (p != int_end)) {
  ------------------
  |  Branch (210:20): [True: 349k, False: 15.1k]
  |  Branch (210:60): [True: 342k, False: 7.74k]
  ------------------
  211|   342k|               i = i * 10 + uint64_t(*p - UC('0'));
  212|   342k|               ++p;
  213|   342k|            }
  214|  22.9k|            if (i >= minimal_nineteen_digit_integer) { // We have a big integers
  ------------------
  |  Branch (214:17): [True: 15.1k, False: 7.74k]
  ------------------
  215|  15.1k|               exponent = end_of_integer_part - p + exp_number;
  216|  15.1k|            }
  217|  7.74k|            else { // We have a value with a fractional component.
  218|  7.74k|               p = answer.fraction.ptr;
  219|  7.74k|               UC const* frac_end = p + answer.fraction.len();
  220|   108k|               while ((i < minimal_nineteen_digit_integer) && (p != frac_end)) {
  ------------------
  |  Branch (220:23): [True: 100k, False: 7.74k]
  |  Branch (220:63): [True: 100k, False: 0]
  ------------------
  221|   100k|                  i = i * 10 + uint64_t(*p - UC('0'));
  222|   100k|                  ++p;
  223|   100k|               }
  224|  7.74k|               exponent = answer.fraction.ptr - p + exp_number;
  225|  7.74k|            }
  226|       |            // We have now corrected both exponent and i, to a truncated value
  227|  22.9k|         }
  228|  23.2k|      }
  229|  2.02M|      answer.exponent = exponent;
  230|  2.02M|      answer.mantissa = i;
  231|  2.02M|      return answer;
  232|  2.02M|   }
_ZZN3glz19parse_number_stringILb0EcEENS_10fast_float22parsed_number_string_tIT0_EEPKS3_S6_ENKUlvE_clEv:
   71|  2.02M|      const bool has_decimal_point = [&] {
   72|       |         if constexpr (null_terminated) {
   73|       |            return (*p == decimal_point);
   74|       |         }
   75|  2.02M|         else {
   76|  2.02M|            return (p != pend) && (*p == decimal_point);
  ------------------
  |  Branch (76:20): [True: 2.02M, False: 780]
  |  Branch (76:35): [True: 15.4k, False: 2.01M]
  ------------------
   77|  2.02M|         }
   78|  2.02M|      }();
_ZN3glz10from_charsILb1EdcEENS_10fast_float19from_chars_result_tIT1_EEPKS3_S6_RT0_:
  236|  4.05M|   {
  237|  4.05M|      using namespace glz::fast_float;
  238|  4.05M|      static_assert(is_supported_float_type<T>(), "only some floating-point types are supported");
  239|  4.05M|      static_assert(is_supported_char_type<UC>(), "only char, wchar_t, char16_t and char32_t are supported");
  240|       |
  241|  4.05M|      parsed_number_string_t<UC> pns = glz::parse_number_string<null_terminated, UC>(first, last);
  242|  4.05M|      if (!pns.valid) [[unlikely]] {
  ------------------
  |  Branch (242:11): [True: 2.27k, False: 4.05M]
  ------------------
  243|  2.27k|         return {.ptr = first, .ec = std::errc::invalid_argument};
  244|  2.27k|      }
  245|       |
  246|  4.05M|      return from_chars_advanced(pns, value);
  247|  4.05M|   }
_ZN3glz19parse_number_stringILb1EcEENS_10fast_float22parsed_number_string_tIT0_EEPKS3_S6_:
   18|  4.05M|   {
   19|  4.05M|      using namespace glz::fast_float;
   20|  4.05M|      static constexpr UC decimal_point = '.';
   21|       |
   22|  4.05M|      parsed_number_string_t<UC> answer;
   23|  4.05M|      answer.valid = false;
   24|  4.05M|      answer.too_many_digits = false;
   25|  4.05M|      answer.negative = (*p == UC('-'));
   26|  4.05M|      if (*p == UC('-')) { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here
  ------------------
  |  Branch (26:11): [True: 6.43k, False: 4.05M]
  ------------------
   27|  6.43k|         ++p;
   28|       |
   29|       |         if constexpr (not null_terminated) {
   30|       |            if (p == pend) [[unlikely]] {
   31|       |               return answer;
   32|       |            }
   33|       |         }
   34|       |
   35|  6.43k|         if (!glz::fast_float::is_integer(*p)) [[unlikely]] { // a sign must be followed by an integer
  ------------------
  |  Branch (35:14): [True: 44, False: 6.38k]
  ------------------
   36|     44|            return answer;
   37|     44|         }
   38|  6.43k|      }
   39|  4.05M|      UC const* const start_digits = p;
   40|       |
   41|  4.05M|      uint64_t i = 0; // an unsigned int avoids signed overflows (which are bad)
   42|       |
   43|  4.05M|      uint64_t digit;
   44|  4.05M|      if constexpr (null_terminated) {
   45|  25.1M|         while ((digit = glz::fast_float::digit_value(*p)) <= 9) {
  ------------------
  |  Branch (45:17): [True: 21.0M, False: 4.05M]
  ------------------
   46|       |            // a multiplication by 10 is cheaper than an arbitrary integer
   47|       |            // multiplication
   48|  21.0M|            i = 10 * i + digit; // might overflow, we will handle the overflow later
   49|  21.0M|            ++p;
   50|  21.0M|         }
   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|  4.05M|      UC const* const end_of_integer_part = p;
   62|  4.05M|      int64_t digit_count = int64_t(end_of_integer_part - start_digits);
   63|  4.05M|      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|  4.05M|      if (digit_count == 0 || (start_digits[0] == UC('0') && digit_count > 1)) {
  ------------------
  |  Branch (66:11): [True: 2.04k, False: 4.05M]
  |  Branch (66:32): [True: 1.69M, False: 2.35M]
  |  Branch (66:62): [True: 128, False: 1.69M]
  ------------------
   67|  2.17k|         return answer;
   68|  2.17k|      }
   69|       |
   70|  4.05M|      int64_t exponent = 0;
   71|  4.05M|      const bool has_decimal_point = [&] {
   72|  4.05M|         if constexpr (null_terminated) {
   73|  4.05M|            return (*p == decimal_point);
   74|  4.05M|         }
   75|  4.05M|         else {
   76|  4.05M|            return (p != pend) && (*p == decimal_point);
   77|  4.05M|         }
   78|  4.05M|      }();
   79|  4.05M|      if (has_decimal_point) {
  ------------------
  |  Branch (79:11): [True: 30.8k, False: 4.02M]
  ------------------
   80|  30.8k|         ++p;
   81|  30.8k|         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|  30.8k|         loop_parse_if_eight_digits(p, pend, i);
   85|       |
   86|  30.8k|         if constexpr (null_terminated) {
   87|   121k|            while ((digit = glz::fast_float::digit_value(*p)) <= 9) {
  ------------------
  |  Branch (87:20): [True: 90.9k, False: 30.8k]
  ------------------
   88|  90.9k|               ++p;
   89|  90.9k|               i = i * 10 + digit; // in rare cases, this will overflow, but that's ok
   90|  90.9k|            }
   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|  30.8k|         exponent = before - p;
   99|  30.8k|         answer.fraction = glz::fast_float::span<const UC>(before, size_t(p - before));
  100|  30.8k|         digit_count -= exponent;
  101|  30.8k|      }
  102|       |      // at least 1 digit in fractional part
  103|  4.05M|      if (has_decimal_point && exponent == 0) {
  ------------------
  |  Branch (103:11): [True: 30.8k, False: 4.02M]
  |  Branch (103:32): [True: 54, False: 30.7k]
  ------------------
  104|     54|         return answer;
  105|     54|      }
  106|       |
  107|  4.05M|      int64_t exp_number = 0; // explicit exponential part
  108|       |
  109|  4.05M|      if constexpr (null_terminated) {
  110|  4.05M|         if ((UC('e') == *p) || (UC('E') == *p)) {
  ------------------
  |  Branch (110:14): [True: 13.2k, False: 4.04M]
  |  Branch (110:33): [True: 15.1k, False: 4.02M]
  ------------------
  111|  28.4k|            UC const* location_of_e = p;
  112|  28.4k|            ++p;
  113|  28.4k|            bool neg_exp = false;
  114|  28.4k|            if (UC('-') == *p) {
  ------------------
  |  Branch (114:17): [True: 15.7k, False: 12.6k]
  ------------------
  115|  15.7k|               neg_exp = true;
  116|  15.7k|               ++p;
  117|  15.7k|            }
  118|  12.6k|            else if (UC('+') == *p) { // '+' on exponent is allowed by C++17 20.19.3.(7.1)
  ------------------
  |  Branch (118:22): [True: 516, False: 12.1k]
  ------------------
  119|    516|               ++p;
  120|    516|            }
  121|  28.4k|            if ((digit = glz::fast_float::digit_value(*p)) > 9) {
  ------------------
  |  Branch (121:17): [True: 120, False: 28.2k]
  ------------------
  122|       |               // Otherwise, we will be ignoring the 'e'.
  123|    120|               p = location_of_e;
  124|    120|            }
  125|  28.2k|            else {
  126|  75.0k|               do {
  127|  75.0k|                  if (exp_number < 0x10000000) {
  ------------------
  |  Branch (127:23): [True: 74.1k, False: 886]
  ------------------
  128|  74.1k|                     exp_number = 10 * exp_number + digit;
  129|  74.1k|                  }
  130|  75.0k|                  ++p;
  131|  75.0k|               } while ((digit = glz::fast_float::digit_value(*p)) <= 9);
  ------------------
  |  Branch (131:25): [True: 46.7k, False: 28.2k]
  ------------------
  132|  28.2k|               if (neg_exp) {
  ------------------
  |  Branch (132:20): [True: 15.7k, False: 12.5k]
  ------------------
  133|  15.7k|                  exp_number = -exp_number;
  134|  15.7k|               }
  135|  28.2k|               exponent += exp_number;
  136|  28.2k|            }
  137|  28.4k|         }
  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|  4.05M|      answer.lastmatch = p;
  171|  4.05M|      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|  4.05M|      if (digit_count > 19) { // this is uncommon
  ------------------
  |  Branch (178:11): [True: 46.4k, False: 4.00M]
  ------------------
  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|  46.4k|         UC const* start = start_digits;
  184|  46.4k|         if constexpr (null_terminated) {
  185|  2.68M|            while ((*start == UC('0') || *start == decimal_point)) {
  ------------------
  |  Branch (185:21): [True: 2.62M, False: 60.5k]
  |  Branch (185:42): [True: 14.0k, False: 46.4k]
  ------------------
  186|  2.64M|               if (*start == UC('0')) {
  ------------------
  |  Branch (186:20): [True: 2.62M, False: 14.0k]
  ------------------
  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|  46.4k|         if (digit_count > 19) {
  ------------------
  |  Branch (201:14): [True: 45.8k, False: 636]
  ------------------
  202|  45.8k|            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|  45.8k|            i = 0;
  207|  45.8k|            p = answer.integer.ptr;
  208|  45.8k|            UC const* int_end = p + answer.integer.len();
  209|  45.8k|            const uint64_t minimal_nineteen_digit_integer{1000000000000000000};
  210|   729k|            while ((i < minimal_nineteen_digit_integer) && (p != int_end)) {
  ------------------
  |  Branch (210:20): [True: 699k, False: 30.3k]
  |  Branch (210:60): [True: 684k, False: 15.4k]
  ------------------
  211|   684k|               i = i * 10 + uint64_t(*p - UC('0'));
  212|   684k|               ++p;
  213|   684k|            }
  214|  45.8k|            if (i >= minimal_nineteen_digit_integer) { // We have a big integers
  ------------------
  |  Branch (214:17): [True: 30.3k, False: 15.4k]
  ------------------
  215|  30.3k|               exponent = end_of_integer_part - p + exp_number;
  216|  30.3k|            }
  217|  15.4k|            else { // We have a value with a fractional component.
  218|  15.4k|               p = answer.fraction.ptr;
  219|  15.4k|               UC const* frac_end = p + answer.fraction.len();
  220|   217k|               while ((i < minimal_nineteen_digit_integer) && (p != frac_end)) {
  ------------------
  |  Branch (220:23): [True: 201k, False: 15.4k]
  |  Branch (220:63): [True: 201k, False: 0]
  ------------------
  221|   201k|                  i = i * 10 + uint64_t(*p - UC('0'));
  222|   201k|                  ++p;
  223|   201k|               }
  224|  15.4k|               exponent = answer.fraction.ptr - p + exp_number;
  225|  15.4k|            }
  226|       |            // We have now corrected both exponent and i, to a truncated value
  227|  45.8k|         }
  228|  46.4k|      }
  229|  4.05M|      answer.exponent = exponent;
  230|  4.05M|      answer.mantissa = i;
  231|  4.05M|      return answer;
  232|  4.05M|   }
_ZZN3glz19parse_number_stringILb1EcEENS_10fast_float22parsed_number_string_tIT0_EEPKS3_S6_ENKUlvE_clEv:
   71|  4.05M|      const bool has_decimal_point = [&] {
   72|  4.05M|         if constexpr (null_terminated) {
   73|  4.05M|            return (*p == decimal_point);
   74|       |         }
   75|       |         else {
   76|       |            return (p != pend) && (*p == decimal_point);
   77|       |         }
   78|  4.05M|      }();

_ZN3glz7skip_wsIXtlNS_7ws_optsEEETkNS_10is_contextERNS_7contextERPKcS5_EEbOT0_OT1_T2_:
  622|  8.19M|   {
  623|  8.19M|      using namespace glz::detail;
  624|       |
  625|  8.19M|      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|  8.19M|         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|  8.19M|            else {
  665|  24.4M|               while (it < end && whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (665:23): [True: 24.4M, False: 1.33k]
  |  Branch (665:35): [True: 16.2M, False: 8.19M]
  ------------------
  666|  16.2M|                  ++it;
  667|  16.2M|               }
  668|  8.19M|               if (it == end) [[unlikely]] {
  ------------------
  |  Branch (668:20): [True: 1.33k, False: 8.19M]
  ------------------
  669|  1.33k|                  ctx.error = error_code::end_reached;
  670|  1.33k|                  return true;
  671|  1.33k|               }
  672|  8.19M|            }
  673|  8.19M|         }
  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|  8.19M|      return false;
  686|  8.19M|   }
_ZN3glz17match_invalid_endILc44EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|   911k|   {
  412|   911k|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 323, False: 911k]
  ------------------
  413|       |         if constexpr (C == '"') {
  414|       |            ctx.error = error_code::expected_quote;
  415|       |         }
  416|    323|         else if constexpr (C == ',') {
  417|    323|            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|    323|         return true;
  432|    323|      }
  433|   911k|      else [[likely]] {
  434|   911k|         ++it;
  435|   911k|      }
  436|   911k|      if constexpr (not Opts.null_terminated) {
  437|   911k|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (437:14): [True: 25, False: 911k]
  ------------------
  438|     25|            ctx.error = error_code::unexpected_end;
  439|     25|            return true;
  440|     25|         }
  441|   911k|      }
  442|   911k|      return false;
  443|   911k|   }
_ZN3glz17match_invalid_endILc34EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|   944k|   {
  412|   944k|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 218, False: 943k]
  ------------------
  413|    218|         if constexpr (C == '"') {
  414|    218|            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|    218|         return true;
  432|    218|      }
  433|   943k|      else [[likely]] {
  434|   943k|         ++it;
  435|   943k|      }
  436|   943k|      if constexpr (not Opts.null_terminated) {
  437|   943k|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (437:14): [True: 69, False: 943k]
  ------------------
  438|     69|            ctx.error = error_code::unexpected_end;
  439|     69|            return true;
  440|     69|         }
  441|   943k|      }
  442|   943k|      return false;
  443|   944k|   }
_ZN3glz9has_quoteEm:
  534|  20.7M|   {
  535|  20.7M|      return has_zero(chunk ^ repeat_byte8('"'));
  536|  20.7M|   }
_ZN3glz8has_zeroEm:
  529|  20.7M|   {
  530|  20.7M|      return (((chunk - 0x0101010101010101u) & ~chunk) & 0x8080808080808080u);
  531|  20.7M|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  832|   936k|   {
  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|   936k|      else {
  840|   936k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (840:14): [True: 924k, False: 12.2k]
  ------------------
  841|   924k|            return false; // pure ASCII is trivially well formed UTF-8
  842|   924k|         }
  843|  12.2k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (843:14): [True: 372, False: 11.9k]
  ------------------
  844|    372|            ctx.error = error_code::invalid_utf8;
  845|    372|            return true;
  846|    372|         }
  847|  11.9k|         return false;
  848|  12.2k|      }
  849|   936k|   }
_ZN3glz13validate_utf8IcEEbPKT_m:
  801|  41.5k|   {
  802|  41.5k|      const uint8_t* it = reinterpret_cast<const uint8_t*>(str);
  803|  41.5k|      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|  41.5k|      return validate_utf8_scalar(it, end);
  815|  41.5k|   }
_ZN3glz20validate_utf8_scalarEPKhS1_:
  752|  41.5k|   {
  753|  1.62M|      while (it < end) {
  ------------------
  |  Branch (753:14): [True: 1.58M, False: 39.6k]
  ------------------
  754|       |         // Optimistic SWAR check for ASCII
  755|  1.58M|         if (it + 8 <= end) {
  ------------------
  |  Branch (755:14): [True: 1.49M, False: 87.1k]
  ------------------
  756|  1.49M|            uint64_t chunk;
  757|  1.49M|            std::memcpy(&chunk, it, 8);
  758|  1.49M|            if ((chunk & glz::repeat_byte8(0x80)) == 0) {
  ------------------
  |  Branch (758:17): [True: 1.42M, False: 67.0k]
  ------------------
  759|  1.42M|               it += 8;
  760|  1.42M|               continue;
  761|  1.42M|            }
  762|  1.49M|         }
  763|       |
  764|       |         // Byte-by-byte validation (standard conformant)
  765|   154k|         uint8_t byte = *it;
  766|       |
  767|   154k|         if (byte < 0x80) {
  ------------------
  |  Branch (767:14): [True: 115k, False: 38.2k]
  ------------------
  768|   115k|            it++;
  769|   115k|         }
  770|  38.2k|         else if ((byte & 0xE0) == 0xC0) {
  ------------------
  |  Branch (770:19): [True: 23.9k, False: 14.2k]
  ------------------
  771|       |            // 2-byte sequence
  772|  23.9k|            if (it + 2 > end || (it[1] & 0xC0) != 0x80) return false;
  ------------------
  |  Branch (772:17): [True: 55, False: 23.9k]
  |  Branch (772:33): [True: 196, False: 23.7k]
  ------------------
  773|  23.7k|            if (byte < 0xC2) return false; // Overlong
  ------------------
  |  Branch (773:17): [True: 40, False: 23.6k]
  ------------------
  774|  23.6k|            it += 2;
  775|  23.6k|         }
  776|  14.2k|         else if ((byte & 0xF0) == 0xE0) {
  ------------------
  |  Branch (776:19): [True: 8.52k, False: 5.75k]
  ------------------
  777|       |            // 3-byte sequence
  778|  8.52k|            if (it + 3 > end || (it[1] & 0xC0) != 0x80 || (it[2] & 0xC0) != 0x80) return false;
  ------------------
  |  Branch (778:17): [True: 27, False: 8.49k]
  |  Branch (778:33): [True: 108, False: 8.38k]
  |  Branch (778:59): [True: 80, False: 8.30k]
  ------------------
  779|  8.30k|            if (byte == 0xE0 && it[1] < 0xA0) return false; // Overlong
  ------------------
  |  Branch (779:17): [True: 1.94k, False: 6.36k]
  |  Branch (779:33): [True: 63, False: 1.88k]
  ------------------
  780|  8.24k|            if (byte == 0xED && it[1] >= 0xA0) return false; // Surrogate
  ------------------
  |  Branch (780:17): [True: 1.89k, False: 6.34k]
  |  Branch (780:33): [True: 44, False: 1.85k]
  ------------------
  781|  8.20k|            it += 3;
  782|  8.20k|         }
  783|  5.75k|         else if ((byte & 0xF8) == 0xF0) {
  ------------------
  |  Branch (783:19): [True: 4.92k, False: 824]
  ------------------
  784|       |            // 4-byte sequence
  785|  4.92k|            if (it + 4 > end || (it[1] & 0xC0) != 0x80 || (it[2] & 0xC0) != 0x80 || (it[3] & 0xC0) != 0x80)
  ------------------
  |  Branch (785:17): [True: 32, False: 4.89k]
  |  Branch (785:33): [True: 84, False: 4.81k]
  |  Branch (785:59): [True: 71, False: 4.74k]
  |  Branch (785:85): [True: 77, False: 4.66k]
  ------------------
  786|    264|               return false;
  787|  4.66k|            if (byte == 0xF0 && it[1] < 0x90) return false; // Overlong
  ------------------
  |  Branch (787:17): [True: 1.95k, False: 2.70k]
  |  Branch (787:33): [True: 73, False: 1.88k]
  ------------------
  788|  4.59k|            if (byte == 0xF4 && it[1] >= 0x90) return false; // > U+10FFFF
  ------------------
  |  Branch (788:17): [True: 1.38k, False: 3.20k]
  |  Branch (788:33): [True: 35, False: 1.34k]
  ------------------
  789|  4.55k|            if (byte > 0xF4) return false; // > U+10FFFF
  ------------------
  |  Branch (789:17): [True: 38, False: 4.51k]
  ------------------
  790|  4.51k|            it += 4;
  791|  4.51k|         }
  792|    824|         else {
  793|    824|            return false;
  794|    824|         }
  795|   154k|      }
  796|       |
  797|  39.6k|      return true;
  798|  41.5k|   }
_ZN3glz25handle_unicode_code_pointIccEEjRPKT_RPT0_S3_:
  288|  68.0k|   {
  289|  68.0k|      using namespace unicode;
  290|       |
  291|  68.0k|      if (it + 4 >= end) [[unlikely]] {
  ------------------
  |  Branch (291:11): [True: 134, False: 67.8k]
  ------------------
  292|    134|         return false;
  293|    134|      }
  294|  67.8k|      const uint32_t high = hex_to_u32(it);
  295|  67.8k|      if (high == 0xFFFFFFFFu) [[unlikely]] {
  ------------------
  |  Branch (295:11): [True: 243, False: 67.6k]
  ------------------
  296|    243|         return false;
  297|    243|      }
  298|  67.6k|      it += 4; // skip the code point characters
  299|       |
  300|  67.6k|      uint32_t code_point;
  301|       |
  302|  67.6k|      if ((high & generic_surrogate_mask) == generic_surrogate_value) {
  ------------------
  |  Branch (302:11): [True: 3.72k, False: 63.9k]
  ------------------
  303|       |         // surrogate pair code points
  304|  3.72k|         if ((high & surrogate_mask) != high_surrogate_value) {
  ------------------
  |  Branch (304:14): [True: 38, False: 3.68k]
  ------------------
  305|     38|            return false;
  306|     38|         }
  307|       |
  308|  3.68k|         if (it + 6 >= end) [[unlikely]] {
  ------------------
  |  Branch (308:14): [True: 58, False: 3.62k]
  ------------------
  309|     58|            return false;
  310|     58|         }
  311|       |         // The next two characters must be `\u`
  312|  3.62k|         uint16_t u;
  313|  3.62k|         std::memcpy(&u, it, 2);
  314|  3.62k|         if (u != to_uint16_t(R"(\u)")) [[unlikely]] {
  ------------------
  |  Branch (314:14): [True: 344, False: 3.28k]
  ------------------
  315|    344|            return false;
  316|    344|         }
  317|  3.28k|         it += 2;
  318|       |         // verify that second unicode escape sequence is present
  319|  3.28k|         const uint32_t low = hex_to_u32(it);
  320|  3.28k|         if (low == 0xFFFFFFFFu) [[unlikely]] {
  ------------------
  |  Branch (320:14): [True: 60, False: 3.22k]
  ------------------
  321|     60|            return false;
  322|     60|         }
  323|  3.22k|         it += 4;
  324|       |
  325|  3.22k|         if ((low & surrogate_mask) != low_surrogate_value) [[unlikely]] {
  ------------------
  |  Branch (325:14): [True: 162, False: 3.06k]
  ------------------
  326|    162|            return false;
  327|    162|         }
  328|       |
  329|  3.06k|         code_point = (high & surrogate_codepoint_mask) << surrogate_codepoint_bits;
  330|  3.06k|         code_point |= (low & surrogate_codepoint_mask);
  331|  3.06k|         code_point += surrogate_codepoint_offset;
  332|  3.06k|      }
  333|  63.9k|      else {
  334|  63.9k|         code_point = high;
  335|  63.9k|      }
  336|  66.9k|      const uint32_t offset = code_point_to_utf8(code_point, dst);
  337|  66.9k|      dst += offset;
  338|  66.9k|      return offset;
  339|  67.6k|   }
_ZN3glz10hex_to_u32EPKc:
  203|  71.1k|   {
  204|  71.1k|      constexpr auto& t = digit_hex_table;
  205|  71.1k|      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|  71.1k|      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|  71.1k|      if (chunk & repeat_byte4(0b11110000u)) [[unlikely]] {
  ------------------
  |  Branch (213:11): [True: 303, False: 70.8k]
  ------------------
  214|    303|         return 0xFFFFFFFFu;
  215|    303|      }
  216|       |
  217|       |      // now pack into first four bytes of uint32_t
  218|  70.8k|      uint32_t packed{};
  219|  70.8k|      packed |= (chunk & 0x0000000F);
  220|  70.8k|      packed |= (chunk & 0x00000F00) >> 4;
  221|  70.8k|      packed |= (chunk & 0x000F0000) >> 8;
  222|  70.8k|      packed |= (chunk & 0x0F000000) >> 12;
  223|  70.8k|      return packed;
  224|  71.1k|   }
_ZN3glz18code_point_to_utf8IcEEjjPT_:
  228|  66.9k|   {
  229|  66.9k|      if (code_point <= 0x7F) {
  ------------------
  |  Branch (229:11): [True: 23.8k, False: 43.1k]
  ------------------
  230|  23.8k|         c[0] = Char(code_point);
  231|  23.8k|         return 1;
  232|  23.8k|      }
  233|  43.1k|      if (code_point <= 0x7FF) {
  ------------------
  |  Branch (233:11): [True: 24.3k, False: 18.7k]
  ------------------
  234|  24.3k|         c[0] = Char(0xC0 | ((code_point >> 6) & 0x1F));
  235|  24.3k|         c[1] = Char(0x80 | (code_point & 0x3F));
  236|  24.3k|         return 2;
  237|  24.3k|      }
  238|  18.7k|      if (code_point <= 0xFFFF) {
  ------------------
  |  Branch (238:11): [True: 15.7k, False: 3.06k]
  ------------------
  239|  15.7k|         c[0] = Char(0xE0 | ((code_point >> 12) & 0x0F));
  240|  15.7k|         c[1] = Char(0x80 | ((code_point >> 6) & 0x3F));
  241|  15.7k|         c[2] = Char(0x80 | (code_point & 0x3F));
  242|  15.7k|         return 3;
  243|  15.7k|      }
  244|  3.06k|      if (code_point <= 0x10FFFF) {
  ------------------
  |  Branch (244:11): [True: 3.06k, False: 0]
  ------------------
  245|  3.06k|         c[0] = Char(0xF0 | ((code_point >> 18) & 0x07));
  246|  3.06k|         c[1] = Char(0x80 | ((code_point >> 12) & 0x3F));
  247|  3.06k|         c[2] = Char(0x80 | ((code_point >> 6) & 0x3F));
  248|  3.06k|         c[3] = Char(0x80 | (code_point & 0x3F));
  249|  3.06k|         return 4;
  250|  3.06k|      }
  251|      0|      return 0;
  252|  3.06k|   }
_ZN3glz17match_invalid_endILc58EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|   935k|   {
  412|   935k|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 613, False: 934k]
  ------------------
  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|    613|         else if constexpr (C == ':') {
  420|    613|            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|    613|         return true;
  432|    613|      }
  433|   934k|      else [[likely]] {
  434|   934k|         ++it;
  435|   934k|      }
  436|   934k|      if constexpr (not Opts.null_terminated) {
  437|   934k|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (437:14): [True: 703, False: 934k]
  ------------------
  438|    703|            ctx.error = error_code::unexpected_end;
  439|    703|            return true;
  440|    703|         }
  441|   934k|      }
  442|   934k|      return false;
  443|   935k|   }
_ZN3glz17match_invalid_endILc91EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|   645k|   {
  412|   645k|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 0, False: 645k]
  ------------------
  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|   645k|      else [[likely]] {
  434|   645k|         ++it;
  435|   645k|      }
  436|   645k|      if constexpr (not Opts.null_terminated) {
  437|   645k|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (437:14): [True: 107, False: 644k]
  ------------------
  438|    107|            ctx.error = error_code::unexpected_end;
  439|    107|            return true;
  440|    107|         }
  441|   645k|      }
  442|   644k|      return false;
  443|   645k|   }
_ZN3glz16skip_matching_wsIcRPKcEEvPKT_OT0_m:
  689|  94.6k|   {
  690|  94.6k|      if (length > 7) {
  ------------------
  |  Branch (690:11): [True: 16.1k, False: 78.5k]
  ------------------
  691|  16.1k|         uint64_t v[2];
  692|  21.8k|         while (length > 8) {
  ------------------
  |  Branch (692:17): [True: 14.3k, False: 7.53k]
  ------------------
  693|  14.3k|            std::memcpy(v, ws, 8);
  694|  14.3k|            std::memcpy(v + 1, it, 8);
  695|  14.3k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (695:17): [True: 8.57k, False: 5.76k]
  ------------------
  696|  8.57k|               return;
  697|  8.57k|            }
  698|  5.76k|            length -= 8;
  699|  5.76k|            ws += 8;
  700|  5.76k|            it += 8;
  701|  5.76k|         }
  702|       |
  703|  7.53k|         const auto shift = 8 - length;
  704|  7.53k|         ws -= shift;
  705|  7.53k|         it -= shift;
  706|       |
  707|  7.53k|         std::memcpy(v, ws, 8);
  708|  7.53k|         std::memcpy(v + 1, it, 8);
  709|  7.53k|         if (v[0] != v[1]) {
  ------------------
  |  Branch (709:14): [True: 4.96k, False: 2.56k]
  ------------------
  710|  4.96k|            return;
  711|  4.96k|         }
  712|  2.56k|         it += 8;
  713|  2.56k|         return;
  714|  7.53k|      }
  715|  78.5k|      {
  716|  78.5k|         constexpr uint64_t n{sizeof(uint32_t)};
  717|  78.5k|         if (length >= n) {
  ------------------
  |  Branch (717:14): [True: 21.0k, False: 57.4k]
  ------------------
  718|  21.0k|            uint32_t v[2];
  719|  21.0k|            std::memcpy(v, ws, n);
  720|  21.0k|            std::memcpy(v + 1, it, n);
  721|  21.0k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (721:17): [True: 12.9k, False: 8.11k]
  ------------------
  722|  12.9k|               return;
  723|  12.9k|            }
  724|  8.11k|            length -= n;
  725|  8.11k|            ws += n;
  726|  8.11k|            it += n;
  727|  8.11k|         }
  728|  78.5k|      }
  729|  65.5k|      {
  730|  65.5k|         constexpr uint64_t n{sizeof(uint16_t)};
  731|  65.5k|         if (length >= n) {
  ------------------
  |  Branch (731:14): [True: 9.69k, False: 55.8k]
  ------------------
  732|  9.69k|            uint16_t v[2];
  733|  9.69k|            std::memcpy(v, ws, n);
  734|  9.69k|            std::memcpy(v + 1, it, n);
  735|  9.69k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (735:17): [True: 7.67k, False: 2.02k]
  ------------------
  736|  7.67k|               return;
  737|  7.67k|            }
  738|       |            // length -= n;
  739|       |            // ws += n;
  740|  2.02k|            it += n;
  741|  2.02k|         }
  742|  65.5k|      }
  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|  65.5k|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  832|  6.54k|   {
  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.54k|      else {
  840|  6.54k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (840:14): [True: 4.57k, False: 1.97k]
  ------------------
  841|  4.57k|            return false; // pure ASCII is trivially well formed UTF-8
  842|  4.57k|         }
  843|  1.97k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (843:14): [True: 217, False: 1.75k]
  ------------------
  844|    217|            ctx.error = error_code::invalid_utf8;
  845|    217|            return true;
  846|    217|         }
  847|  1.75k|         return false;
  848|  1.97k|      }
  849|  6.54k|   }
_ZN3glz5matchITnNS_14string_literalEXtlNS1_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS8_Qntcl15check_is_paddedT0_EEEvOT1_OT2_T3_:
  491|    665|   {
  492|    665|      const auto n = size_t(end - it);
  493|    665|      static constexpr auto S = str.sv();
  494|    665|      if ((n < str.size()) || not comparitor<S>(it)) [[unlikely]] {
  ------------------
  |  Branch (494:11): [True: 71, False: 594]
  |  Branch (494:31): [True: 113, False: 481]
  ------------------
  495|    184|         ctx.error = error_code::syntax_error;
  496|    184|      }
  497|    481|      else [[likely]] {
  498|    481|         it += str.size();
  499|    481|      }
  500|    665|   }
_ZN3glz7skip_wsIXtlNS_7ws_optsELb0ELb1EEETkNS_10is_contextERNS_7contextERPKcS5_EEbOT0_OT1_T2_:
  622|  16.3M|   {
  623|  16.3M|      using namespace glz::detail;
  624|       |
  625|  16.3M|      if constexpr (not Opts.minified) {
  626|  16.3M|         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|  16.3M|            else {
  641|  48.9M|               while (whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (641:23): [True: 32.5M, False: 16.3M]
  ------------------
  642|  32.5M|                  ++it;
  643|  32.5M|               }
  644|  16.3M|            }
  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|  16.3M|      return false;
  686|  16.3M|   }
_ZN3glz17match_invalid_endILc44EXtlNS_22match_invalid_end_optsELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|  1.82M|   {
  412|  1.82M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 880, False: 1.82M]
  ------------------
  413|       |         if constexpr (C == '"') {
  414|       |            ctx.error = error_code::expected_quote;
  415|       |         }
  416|    880|         else if constexpr (C == ',') {
  417|    880|            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|    880|         return true;
  432|    880|      }
  433|  1.82M|      else [[likely]] {
  434|  1.82M|         ++it;
  435|  1.82M|      }
  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.82M|      return false;
  443|  1.82M|   }
_ZN3glz17match_invalid_endILc34EXtlNS_22match_invalid_end_optsELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|  1.88M|   {
  412|  1.88M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 640, False: 1.88M]
  ------------------
  413|    640|         if constexpr (C == '"') {
  414|    640|            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|    640|         return true;
  432|    640|      }
  433|  1.88M|      else [[likely]] {
  434|  1.88M|         ++it;
  435|  1.88M|      }
  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.88M|      return false;
  443|  1.88M|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  832|   936k|   {
  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|   936k|      else {
  840|   936k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (840:14): [True: 924k, False: 12.1k]
  ------------------
  841|   924k|            return false; // pure ASCII is trivially well formed UTF-8
  842|   924k|         }
  843|  12.1k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (843:14): [True: 379, False: 11.8k]
  ------------------
  844|    379|            ctx.error = error_code::invalid_utf8;
  845|    379|            return true;
  846|    379|         }
  847|  11.8k|         return false;
  848|  12.1k|      }
  849|   936k|   }
_ZN3glz17match_invalid_endILc58EXtlNS_22match_invalid_end_optsELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|  1.87M|   {
  412|  1.87M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 1.67k, False: 1.86M]
  ------------------
  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.67k|         else if constexpr (C == ':') {
  420|  1.67k|            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.67k|         return true;
  432|  1.67k|      }
  433|  1.86M|      else [[likely]] {
  434|  1.86M|         ++it;
  435|  1.86M|      }
  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.86M|      return false;
  443|  1.87M|   }
_ZN3glz17match_invalid_endILc91EXtlNS_22match_invalid_end_optsELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  411|  1.29M|   {
  412|  1.29M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (412:11): [True: 0, False: 1.29M]
  ------------------
  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.29M|      else [[likely]] {
  434|  1.29M|         ++it;
  435|  1.29M|      }
  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.29M|      return false;
  443|  1.29M|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  832|  6.59k|   {
  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.59k|      else {
  840|  6.59k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (840:14): [True: 4.60k, False: 1.98k]
  ------------------
  841|  4.60k|            return false; // pure ASCII is trivially well formed UTF-8
  842|  4.60k|         }
  843|  1.98k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (843:14): [True: 245, False: 1.74k]
  ------------------
  844|    245|            ctx.error = error_code::invalid_utf8;
  845|    245|            return true;
  846|    245|         }
  847|  1.74k|         return false;
  848|  1.98k|      }
  849|  6.59k|   }
_ZN3glz5matchITnNS_14string_literalEXtlNS1_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS8_Qntcl15check_is_paddedT0_EEEvOT1_OT2_T3_:
  491|    665|   {
  492|    665|      const auto n = size_t(end - it);
  493|    665|      static constexpr auto S = str.sv();
  494|    665|      if ((n < str.size()) || not comparitor<S>(it)) [[unlikely]] {
  ------------------
  |  Branch (494:11): [True: 37, False: 628]
  |  Branch (494:31): [True: 147, False: 481]
  ------------------
  495|    184|         ctx.error = error_code::syntax_error;
  496|    184|      }
  497|    481|      else [[likely]] {
  498|    481|         it += str.size();
  499|    481|      }
  500|    665|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  832|   936k|   {
  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|   936k|      else {
  840|   936k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (840:14): [True: 925k, False: 11.1k]
  ------------------
  841|   925k|            return false; // pure ASCII is trivially well formed UTF-8
  842|   925k|         }
  843|  11.1k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (843:14): [True: 379, False: 10.8k]
  ------------------
  844|    379|            ctx.error = error_code::invalid_utf8;
  845|    379|            return true;
  846|    379|         }
  847|  10.8k|         return false;
  848|  11.1k|      }
  849|   936k|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj36EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  832|  6.62k|   {
  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.62k|      else {
  840|  6.62k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (840:14): [True: 4.72k, False: 1.89k]
  ------------------
  841|  4.72k|            return false; // pure ASCII is trivially well formed UTF-8
  842|  4.72k|         }
  843|  1.89k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (843:14): [True: 255, False: 1.64k]
  ------------------
  844|    255|            ctx.error = error_code::invalid_utf8;
  845|    255|            return true;
  846|    255|         }
  847|  1.64k|         return false;
  848|  1.89k|      }
  849|  6.62k|   }
_ZN3glz5matchITnNS_14string_literalEXtlNS1_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj32EEETkNS_10is_contextERNS_7contextERPKcS8_Qaacl15check_is_paddedT0_ElecldtT_4sizeEL_ZNS_13padding_bytesEEEEvOT1_OT2_T3_:
  478|    665|   {
  479|    665|      static constexpr auto S = str.sv();
  480|    665|      if (not comparitor<S>(it)) [[unlikely]] {
  ------------------
  |  Branch (480:11): [True: 184, False: 481]
  ------------------
  481|    184|         ctx.error = error_code::syntax_error;
  482|    184|      }
  483|    481|      else [[likely]] {
  484|    481|         it += str.size();
  485|    481|      }
  486|    665|   }

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

