Skip to content

Commit 0b9d75f

Browse files
committed
Swift member calls: read each body's bindings once, and keep non-view leading-dot chains
Cast receivers: the lookup of `let x = y as? T` (and `if let` / `guard let` / `let x: T`) walked the enclosing function body once per member call on a lowercase receiver, so extraction was quadratic in function size (an 8k-line generated function: 45 s). Each body is now read once into a per-file table (CBMExtractCtx.swift_bindings, scratch arena), grouped by name; a call is one hash probe and a binary search for the latest binding before it. Same answers; the same function now indexes in 1.6 s. Leading-dot chains: every multi-line `expr()\n .m()` became View.m, so Combine, URLSession and other operator chains lost their edges. View.m is now spelled only when the chain is a SwiftUI view: its root is a constructor expression or a call of a capitalised (or qualified) type name, or the chain applies a known view modifier. Other chains keep their source text and bind as they did before the rewrite. Signed-off-by: chidev <[email protected]>
1 parent 4cac258 commit 0b9d75f

3 files changed

Lines changed: 594 additions & 59 deletions

File tree

‎internal/cbm/cbm.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,10 @@ typedef struct {
11221122
* The core never reads, interprets or frees it. It is the only place for
11231123
* such state: a static or thread-local cache is not. */
11241124
void *doclink_state;
1125+
/* Swift: the local bindings of each function body a member call has
1126+
* looked into (extract_calls.c), NULL until the first lookup; allocated
1127+
* in `scratch`. */
1128+
void *swift_bindings;
11251129
} CBMExtractCtx;
11261130

11271131
/* Internal configured-definition seams. No declarations pointer enters a result. */

0 commit comments

Comments
 (0)