Skip to content

Reduce buildBlock overloads with pairwise buildBlock(combining:into:) #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2022

Conversation

rxwei
Copy link
Contributor

@rxwei rxwei commented Jan 14, 2022

This patch replaces O(2^arity) overloads of buildBlock with O(arity^2) overloads of buildBlock(combining:into:) with the language feature implemented in swiftlang/swift#40799. This improves library compilation time, and fixes an issue where nested captures did not have a flattened type. Before this patch, fixing this would need O(arity!) overloads. This also allows us to switch back to native tuples for Match.

Also, rename renderAsPattern to renderAsBuilderDSL to work around a CI stale file issue.

This depends on swift-DEVELOPMENT-SNAPSHOT-2022-02-03 or later.

@rxwei rxwei force-pushed the pairwise-buildblock branch 4 times, most recently from 17f3055 to 2c66ee6 Compare January 18, 2022 11:48
@rxwei rxwei changed the title WIP: Pairwise buildBlock Reduce buildBlock overloads with pairwise buildBlock(combining:into:) Jan 18, 2022
@rxwei rxwei marked this pull request as ready for review January 18, 2022 11:51
@rxwei rxwei force-pushed the pairwise-buildblock branch from 2c66ee6 to ec66d20 Compare January 18, 2022 11:53
@rxwei rxwei force-pushed the pairwise-buildblock branch from ec66d20 to 97f4edc Compare January 25, 2022 07:48
@rxwei rxwei force-pushed the pairwise-buildblock branch 2 times, most recently from eede636 to c9c9028 Compare January 31, 2022 04:02
@rxwei rxwei requested a review from milseman January 31, 2022 04:12
@rxwei
Copy link
Contributor Author

rxwei commented Feb 7, 2022

@swift-ci please test linux

@rxwei rxwei force-pushed the pairwise-buildblock branch from c9c9028 to d853aae Compare February 7, 2022 08:13
@rxwei
Copy link
Contributor Author

rxwei commented Feb 7, 2022

@swift-ci please test

@rxwei
Copy link
Contributor Author

rxwei commented Feb 7, 2022

@swift-ci please test Linux

@rxwei
Copy link
Contributor Author

rxwei commented Feb 7, 2022

@swift-ci please clean test linux

@rxwei
Copy link
Contributor Author

rxwei commented Feb 7, 2022

/build/branch-main/swift-experimental-string-processing/Sources/PatternConverter/PatternConverter.swift:69:18: error: ambiguous use of 'renderAsPattern(maxTopDownLevels:minBottomUpLevels:)'
00:23:28     let render = ast.renderAsPattern(
00:23:28                  ^
00:23:28 /build/branch-main/swift-experimental-string-processing/Sources/_MatchingEngine/Regex/Printing/PrintAsPattern.swift:20:15: note: found this candidate
00:23:28   public func renderAsPattern(
00:23:28               ^
00:23:28 /build/branch-main/swift-experimental-string-processing/Sources/_StringProcessing/PrintAsPattern.swift:22:15: note: found this candidate
00:23:28   public func renderAsPattern(
00:23:28               ^

Such a strange error. There's only one func renderAsPattern in Sources/_StringProcessing/PrintAsPattern.swift.

@rxwei
Copy link
Contributor Author

rxwei commented Feb 7, 2022

@swift-ci please clean test Linux

@rxwei rxwei force-pushed the pairwise-buildblock branch from d853aae to e4529bc Compare February 7, 2022 08:32
@rxwei
Copy link
Contributor Author

rxwei commented Feb 7, 2022

@swift-ci please test Linux

@rxwei rxwei force-pushed the pairwise-buildblock branch from e4529bc to 5fe6e17 Compare February 7, 2022 08:34
@rxwei
Copy link
Contributor Author

rxwei commented Feb 7, 2022

@swift-ci please clean test linux

@rxwei
Copy link
Contributor Author

rxwei commented Feb 7, 2022

I suspect it's a stale file on the CI machine, and a clean test didn't fix it. I'll rename renderAsPattern to renderAsBuilderDSL to work around it.

@rxwei rxwei force-pushed the pairwise-buildblock branch from 5fe6e17 to bfe6ba7 Compare February 7, 2022 08:36
…o:)`.

This patch replaces `O(2^arity)` overloads of `buildBlock` with `O(arity^2)` overloads of `buildBlock(combining:into:)` with the language feature implemented in swiftlang/swift#40799. This improves library compilation time, and fixes an issue where nested captures did not have a flattened type. Before this patch, fixing this would need `O(arity!)` overloads. This also allows us to switch back to native tuples for `Match`.

Also, rename `renderAsPattern` to `renderAsBuilderDSL` to work around a CI stale file issue.
@rxwei rxwei force-pushed the pairwise-buildblock branch from bfe6ba7 to 8763e2d Compare February 7, 2022 08:37
@rxwei
Copy link
Contributor Author

rxwei commented Feb 7, 2022

@swift-ci please test Linux

@rxwei
Copy link
Contributor Author

rxwei commented Feb 7, 2022

Merging to unblock things. Additional feedback welcome.

@rxwei rxwei merged commit 15c97b3 into swiftlang:main Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant