refactor: tidy parser file layout and inline redundant NFC wrapper#50
Merged
Conversation
a90250a to
71fe19b
Compare
Housekeeping in the parser and idna packages:
- Collapse three per-file copies of `private const val FILE_SCHEME = "file"`
in the parser package into one internal const in UrlParserHelpers. (Url.kt's
own copy stays: it is in a different package, and importing a parser-internal
const there for one literal would read worse than the local one.)
- Fold UrlParserDrive's three Windows-drive predicates into UrlParserHelpers,
which already consumes them, and delete the file. One flat bag of
same-package helper predicates does not need two files.
- Inline Idna's one-line normalizeNfc pass-through to Normalizer.nfc at both
call sites, keeping the "UTS-46 step 3" rationale as a comment.
Pure refactor: no behavior change, public API unchanged.
77c554a to
29fb632
Compare
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 small housekeeping cleanups in the parser and idna packages.
FILE_SCHEMEconstant was declaredprivate const val FILE_SCHEME = "file"in three separate parser files.UrlParserDrive.ktheld only threeinternalWindows-drive predicates, in the same package asUrlParserHelpers.kt— which already consumes them.Idna.normalizeNfcwas a one-line pass-through toNormalizer.nfc.Change
FILE_SCHEMEinto oneinternal constinUrlParserHelpers.Url.ktkeeps its own copy — it's in a different package, and importing a parser-internalconst there for a single literal would read worse than the local const (andSpecialScheme.FILEis an enum property, not a compile-time constant, so it's no cleaner for hot-path string comparisons).UrlParserHelpersbeside their consumers and deleteUrlParserDrive.kt. Same package + sameinternalsignatures, so callers are unchanged.UrlParserHelpersgains a@file:Suppress("TooManyFunctions"), matching the existing precedent for deliberate helper files.normalizeNfctoNormalizer.nfcat both call sites, preserving the "UTS-46 step 3" rationale as a comment and fixing a now-dangling KDoc link.Safety
Pure refactor — no behavior change, public API unchanged (
apiCheckpasses with noapiDump). Verified on the JVM gate + a Kotlin/NativemacosArm64compile.Stacked on #49.