File tree Expand file tree Collapse file tree 2 files changed +4
-22
lines changed
CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax
Sources/SwiftSyntax/generated Expand file tree Collapse file tree 2 files changed +4
-22
lines changed Original file line number Diff line number Diff line change @@ -318,15 +318,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
318
318
// with 'Syntax'
319
319
var rewrittens: ContiguousArray<RetainedSyntaxArena> = []
320
320
321
- // Incrementing i manually is faster than using .enumerated()
322
- var childIndex = 0
323
- for (raw, info) in RawSyntaxChildren(node) {
324
- defer { childIndex += 1 }
325
-
326
- guard let child = raw, viewMode.shouldTraverse(node: child) else {
327
- // Node does not exist or should not be visited.
328
- continue
329
- }
321
+ for case let (child?, info) in RawSyntaxChildren(node) where viewMode.shouldTraverse(node: child) {
330
322
331
323
// Build the Syntax node to rewrite
332
324
var childNode = nodeFactory.create(parent: node, raw: child, absoluteInfo: info)
@@ -343,7 +335,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
343
335
}
344
336
345
337
// Update the rewritten child.
346
- newLayout[childIndex ] = childNode.raw
338
+ newLayout[Int(info.indexInParent) ] = childNode.raw
347
339
// Retain the syntax arena of the new node until it's wrapped with Syntax node.
348
340
rewrittens.append(childNode.raw.arenaReference.retained)
349
341
}
Original file line number Diff line number Diff line change @@ -3915,17 +3915,7 @@ open class SyntaxRewriter {
3915
3915
// with 'Syntax'
3916
3916
var rewrittens : ContiguousArray < RetainedSyntaxArena > = [ ]
3917
3917
3918
- // Incrementing i manually is faster than using .enumerated()
3919
- var childIndex = 0
3920
- for (raw, info) in RawSyntaxChildren ( node) {
3921
- defer {
3922
- childIndex += 1
3923
- }
3924
-
3925
- guard let child = raw, viewMode. shouldTraverse ( node: child) else {
3926
- // Node does not exist or should not be visited.
3927
- continue
3928
- }
3918
+ for case let ( child? , info) in RawSyntaxChildren ( node) where viewMode. shouldTraverse ( node: child) {
3929
3919
3930
3920
// Build the Syntax node to rewrite
3931
3921
var childNode = nodeFactory. create ( parent: node, raw: child, absoluteInfo: info)
@@ -3942,7 +3932,7 @@ open class SyntaxRewriter {
3942
3932
}
3943
3933
3944
3934
// Update the rewritten child.
3945
- newLayout [ childIndex ] = childNode. raw
3935
+ newLayout [ Int ( info . indexInParent ) ] = childNode. raw
3946
3936
// Retain the syntax arena of the new node until it's wrapped with Syntax node.
3947
3937
rewrittens. append ( childNode. raw. arenaReference. retained)
3948
3938
}
You can’t perform that action at this time.
0 commit comments