perf: harmonize residual direct file reads to cache-first read_file_content (Wave Z)#2282
Merged
Merged
Conversation
…ontent
The whole-tree Wave-Z regression re-grep confirmed no reintroduced
interpolated-regex-in-loop (the one remaining dynamic-name match in
tornado is guarded by a `starts_with?` and returns on first match — the
sanctioned low-cardinality pattern). It did surface the last residual
direct-disk reads that the per-file "apply the first tier only" sweep
discipline skipped on files that already got a Tier-A/B fix:
- scala/{zio_http,akka,tapir,scalatra}.cr `analyze_file` (+ scalatra's
`build_mount_prefixes`) read via bare `File.read(path)` — identical to
the http4s case already swapped in #2260.
- java/dropwizard.cr `read_path_config` read config yaml via `File.read`.
- kotlin/spring.cr `read_properties` read via `File.each_line`.
All routed through the base-class `read_file_content`, which returns the
detector-populated cache when present (skipping a redundant disk read)
and otherwise falls back to `File.read(..., encoding: "utf-8",
invalid: :skip)`. Byte-identical on all valid UTF-8 (every fixture
passes) and aligns invalid-byte handling with the rest of the codebase.
Left as-is: crystal/kemal.cr's `File.read_lines` (no encoding arg) —
swapping it would change invalid-UTF-8 handling, so it is not a
detection-neutral swap (tracked separately).
Detection-neutral: full suite 3681 unit + 20967 functional, 0 failures.
Co-authored-by: ksg97031 <ksg97031@gmail.com>
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
Final pass of the analyzer performance sweep (follows #2258). A whole-tree regression re-grep across
src/analyzer/analyzers/confirmed no reintroduced interpolated-regex-in-loop (the one remaining dynamic-name.matchintornado.cris guarded bystarts_with?+ returns on first match — the sanctioned low-cardinality pattern). It surfaced the last residual direct-disk reads that the per-file "apply the first tier only" discipline skipped on files that already received a Tier-A/B fix:scala/zio_http.cr/akka.cr/tapir.cr/scalatra.cranalyze_file(+ scalatrabuild_mount_prefixes)File.read(path)→read_file_content(path)(identical to the http4s swap in #2260)java/dropwizard.crread_path_configYAML.parse(File.read(path))→read_file_contentkotlin/spring.crread_propertiesFile.each_line(path)→read_file_content(path).each_lineread_file_contentreturns the detector-populated cache when present (skipping a redundant disk read) and otherwise falls back toFile.read(..., encoding: "utf-8", invalid: :skip). Byte-identical on all valid UTF-8 (every fixture passes) and aligns invalid-byte handling with the rest of the codebase.Left as-is:
crystal/kemal.cr'sFile.read_lines(no encoding arg) — swapping would change invalid-UTF-8 handling, so it's not a detection-neutral swap.Test plan
just test→ 3681 unit + 20967 functional, 0 failures.crystal tool format --checkclean;ameba→ 6 inspected, 0 failures;typosclean.Co-authored-by: ksg97031 ksg97031@gmail.com