Skip to content
This repository was archived by the owner on Apr 23, 2026. It is now read-only.

Performance fixes for Scala code generation#22

Merged
max-leuthaeuser merged 1 commit into
masterfrom
max/perf-fixes
Apr 9, 2026
Merged

Performance fixes for Scala code generation#22
max-leuthaeuser merged 1 commit into
masterfrom
max/perf-fixes

Conversation

@max-leuthaeuser
Copy link
Copy Markdown
Collaborator

  • Cache SwiftNode.toString to avoid repeated reflection overhead
  • Replace generated AST node wrappers with direct pattern matching (~2800 lines removed)
  • Replace O(n) sequential if-chain in createSwiftNode with HashMap dispatch for both node types and token kinds
  • Replace repeated .arr.toList.find() child accessors with a cached _childrenMap (Map[String, Value]) built once per node, eliminating linear scans and intermediate List allocations on every property access
  • Replace Try-based range accessors (startOffset, endLine, etc.) with safe obj.get lookups, avoiding exception construction and fillInStackTrace overhead when fields are absent

- Cache `SwiftNode.toString` to avoid repeated reflection overhead
- Replace generated AST node wrappers with direct pattern matching (~2800 lines removed)
- Replace O(n) sequential if-chain in `createSwiftNode` with `HashMap`
  dispatch for both node types and token kinds
- Replace repeated `.arr.toList.find()` child accessors with a cached
  `_childrenMap` (`Map[String, Value]`) built once per node, eliminating
  linear scans and intermediate List allocations on every property access
- Replace Try-based range accessors (`startOffset`, `endLine`, etc.) with
  safe `obj.get` lookups, avoiding exception construction and fillInStackTrace overhead when fields are absent
@max-leuthaeuser max-leuthaeuser merged commit 2c9ab6c into master Apr 9, 2026
3 checks passed
@max-leuthaeuser max-leuthaeuser deleted the max/perf-fixes branch April 9, 2026 15:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant