@@ -163,8 +163,6 @@ final class SwiftIndexer: Indexer {
163163 /// phase two.
164164 func phaseOne( ) throws {
165165 var rawDeclsByKey : [ RawDeclaration . Key : [ ( RawDeclaration , [ RawRelation ] ) ] ] = [ : ]
166- // Array (not Set) to avoid redundant hashing -- deduplication happens
167- // in SourceGraph.allReferences when references are added under the lock.
168166 var references : [ Reference ] = [ ]
169167
170168 for unit in units {
@@ -246,11 +244,8 @@ final class SwiftIndexer: Indexer {
246244 }
247245
248246 try graph. withLock { graph in
249- graph. ensureReferencesCapacity ( graph. allReferences. count + references. count)
250247 graph. add ( references)
251248 try graph. add ( newDeclarations)
252- // Apply batched retention after insertion so any synthetic
253- // retained references resolve against the completed file graph.
254249 graph. markRetained ( retainedDecls)
255250
256251 if retainAllDeclarations {
@@ -260,8 +255,6 @@ final class SwiftIndexer: Indexer {
260255
261256 establishDeclarationHierarchy ( )
262257
263- // Only sort when needed -- associateDanglingReferences is the sole consumer
264- // and it early-exits when there are no dangling references.
265258 if !danglingReferences. isEmpty {
266259 sortedDeclarationsCache = declarations. sorted ( )
267260 }
@@ -359,7 +352,6 @@ final class SwiftIndexer: Indexer {
359352 for (parent, decls) in childDeclsByParentUsr {
360353 guard let parentDecl = graph. declaration ( withUsr: parent) else {
361354 if varParameterUsrs. contains ( parent) {
362- // These declarations are children of a parameter and are redundant.
363355 decls. forEach { graph. remove ( $0) }
364356 }
365357
@@ -370,7 +362,7 @@ final class SwiftIndexer: Indexer {
370362 decl. parent = parentDecl
371363 }
372364
373- parentDecl. declarations. formUnion ( decls)
365+ parentDecl. declarations. append ( contentsOf : decls)
374366 }
375367 }
376368 }
@@ -513,17 +505,17 @@ final class SwiftIndexer: Indexer {
513505 graph. markCommandIgnored ( decl, kind: kind)
514506 decl. unusedParameters. forEach { graph. markCommandIgnored ( $0, kind: kind) }
515507
516- commandIgnoreUnsafe ( Array ( decl. declarations) , kind: kind, graph: graph)
508+ commandIgnoreUnsafe ( decl. declarations, kind: kind, graph: graph)
517509 }
518510 }
519511
520512 private func associateUnsafe( _ ref: Reference , with decl: Declaration ) {
521513 ref. parent = decl
522514
523515 if ref. kind == . related {
524- decl. related. insert ( ref)
516+ decl. related. append ( ref)
525517 } else {
526- decl. references. insert ( ref)
518+ decl. references. append ( ref)
527519 }
528520 }
529521
@@ -561,7 +553,7 @@ final class SwiftIndexer: Indexer {
561553
562554 for param in params {
563555 let paramDecl = param. makeDeclaration ( withParent: functionDecl, interner: self . graph. usrInterner)
564- functionDecl. unusedParameters. insert ( paramDecl)
556+ functionDecl. unusedParameters. append ( paramDecl)
565557 try graph. add ( paramDecl)
566558
567559 if retainAllDeclarations || ( functionDecl. isObjcAccessible && configuration. retainObjcAccessible) {
@@ -643,7 +635,7 @@ final class SwiftIndexer: Indexer {
643635 location: decl. location
644636 )
645637 reference. parent = decl
646- decl. related. insert ( reference)
638+ decl. related. append ( reference)
647639 references. append ( reference)
648640 }
649641 }
0 commit comments