refactor: remove speculative abstraction from kuri-bind#51
Merged
Conversation
77c554a to
29fb632
Compare
Three simplifications in the reflection binder, all internal:
- Collapse the UrlBinder/UriBinder interfaces (one implementer each, never
referenced as a type — introduced only for a hypothetical future codegen
backend) and their two near-identical ReflectiveBinder wrappers. KuriBind
now drives a single shared BindingExecutor directly, dropping two redundant
executor instances and two dead `check(bound === base)` postconditions.
- Fold the duplicated iterable-fan-out query logic (applyQuery /
applyQueryMapEntry) into one addQueryValues helper.
- Merge the thin PlanCache wrapper into PlanCompiler, matching the inline
ConcurrentHashMap-cache idiom the member scanner already uses, and dedupe
the `type != Any::class` precondition to a single site.
Two files are renamed to match their sole remaining declaration (Binder.kt ->
Profile.kt, ReflectiveBinder.kt -> BindingExecutor.kt). One end-to-end test is
retargeted from the removed ReflectiveUrlBinder class to BindingExecutor,
preserving all its assertions.
Pure refactor: binding behavior unchanged, public API unchanged.
b60c01f to
1ac2a99
Compare
The reflective binder wrappers were removed along with the ReflectiveBinder.kt file, but the end-to-end test kept the old name for a type that no longer exists. Rename the file and class to BindingExecutorTest, matching the class it actually exercises, and reword the addQueryValues comment to explain why value is nullable rather than restating the null-safe call mechanics.
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.
What
Three simplifications in the
kuri-bindreflection binder, allinternal.UrlBinder/UriBinderinterfaces had one implementer each and were never referenced as a declared type — introduced only for a "codegen later" that isn't here. Their twoReflective*Binderwrappers were near-identical glue, each spinning up its ownBindingExecutor.applyQuery/applyQueryMapEntryduplicated the same iterable-fan-out logic.PlanCachewas a ~35-line wrapper overPlanCompiler(one caller each), duplicatingPlanCompiler's owntype != Any::classguard, while the member scanner already caches inline.Change
KuriBinddrives a single sharedBindingExecutordirectly. Drops two redundant executor instances and two deadcheck(bound === base)postconditions.addQueryValueshelper; the map-entry path keeps its name/empty-guard, the plain path collapses to a call.ConcurrentHashMapintoPlanCompiler(matching the scanner's inline-cache idiom), deletePlanCache, and dedupe the precondition to one site.compile()stays public (the compiler test suites call it).Two files are renamed to match their sole remaining declaration:
Binder.kt→Profile.kt,ReflectiveBinder.kt→BindingExecutor.kt.Safety
Pure refactor — binding behavior unchanged. The one end-to-end test (
ReflectiveBinderTest) is retargeted from the removedReflectiveUrlBindertoBindingExecutor, preserving all six assertions (6 tests, 0 failures). Public API unchanged (apiCheckpasses with noapiDump— every removed symbol was internal). Net −65 lines.Left as-is (verified genuine, not over-abstraction)
BuilderSink(real 2-impl seam — Url vs Uri userinfo differ),ComponentSink,Converters' typedwhenbranches, theMemberScanner/PlanCompilersplit, the distinct scan-cache vs plan-cache purposes, andKuriBind's paralleltoUrl*/toUri*methods (intentional Java-ergonomic symmetry).Final PR in the series; stacked on #50.