Repository navigation
perf(internal): use O(log N) exponential + binary search in cpp20::num_fields - #233
Open
clockblocker wants to merge 1 commit into
Open
clockblocker wants to merge 1 commit into
clockblocker wants to merge 1 commit into
Conversation
…m_fields Replaces the O(N) linear SFINAE recursion in `rfl::internal::cpp20::num_fields` with an O(log N) exponential probe + binary search, cutting wide-struct C++20 reflection compile time and bounding template instantiation depth in +49/-4 LOC with zero public API changes. Downstream wide-struct / `num_fields` consumers: - openmoq/moqx invokes `num_fields` 27x in one TU: https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/test/config/ConfigSerializerTest.cpp#L26-L128 - hudson-trading/slang-server defines 376 LSP structs up to 36 fields: https://github.com/hudson-trading/slang-server/blob/1b413a4655877a55b3f8a450c23e4ba6c2bf4267/include/lsp/LspTypes.h#L3816-L3976 - FANUC-CORPORATION/fanuc_driver has 23-field packet structs: https://github.com/FANUC-CORPORATION/fanuc_driver/blob/da5db3f611cdc9dffe687e056c4e79bea584bf5c/fanuc_libs/rmi/include/rmi/packets.hpp#L641-L666
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related munich-data-engineering/reflect-cpp#799
Problem
In C++20 mode,$0$ up to $N$ .
rfl::num_fieldscounts an aggregate's fields by probing constructibility linearly fromOn wide structs (20–36+ fields) or translation units reflecting hundreds of structs, linear SFINAE recursion inflates template depth and compile time.
Summary
static_assertdiagnostics intact.OSS consumers
openmoq/moqxConfigSerializerTest.cpp#L26-L128rfl::num_fields27 times in one TU over wide config structs.hudson-trading/slang-serverlsp/LspTypes.h#L3816-L3976FANUC-CORPORATION/fanuc_driverrmi/packets.hpp#L641-L666For Agents
upstream-queue(f2933beb) · Score83/100(S=28,M=26,D=16,R=13) ·+49/-4(1f)queue-tests/json/test_num_fields.cpp