Repository navigation
Avoid O(N^2) template instantiations in no_duplicate_field_names - #54
Closed
clockblocker wants to merge 1 commit into
Closed
clockblocker wants to merge 1 commit into
clockblocker wants to merge 1 commit into
Conversation
Owner
Author
|
Merged upstream as munich-data-engineering#799; closing fork PR (branch preserved). |
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.
Summary
Addresses munich-data-engineering#350 (eliminates recursive template instantiations that trigger MSVC
C1202on large field counts).Replaces the$O(N^2)$ recursive template expansion in
rfl::internal::no_duplicate_field_names(iterate_over_i→iterate_over_j→compare_two_fields<Fields, _i, _j>) with a singleconstexprsort-and-scan overstd::array<std::string_view, N>.rfl::Literal(-std=c++20,-fsyntax-only),compare_two_fieldspreviously instantiatedconstexprpredicate behavior: Previously,compare_two_fieldsfired an internalstatic_assertandno_duplicate_field_names()always returnedtrue. Now it returnsfalsewhen duplicates exist:rfl::Literal<...>::has_duplicates()actually works as aconstexpr boolpredicate (returningtrueon duplicates instead of failing to compile).to_ptr_named_tuple.hpp,FieldVariantParser.hpp,ParserTaggedUnion.hpp) all wrap the check in their ownstatic_assertand now report their own domain-specific messages.constexprShell sort overstd::array<std::string_view, N>(no<algorithm>dependency) and evaluates intoconstexpr bool resultso nostd::string_viewarray escapes the lambda.Verification
-Wall -Wextra -Werror) onclang++(Apple Clang 17) andg++-16in both C++20 and C++23.json.test_literal_has_duplicatesintests/json/test_literal.cppcovering unique/duplicaterfl::Literal(up to 32 entries) andrfl::internal::no_duplicate_field_nameson empty, single, distinct, and duplicaterfl::Fieldtuples.static_assertfailures still trigger with the caller-specific messages for duplicate flattened fields, duplicateTaggedUniontags, and duplicateFieldVariantParserfields.Base:
main(independent of all wave branches).