Skip to content

Commit 7311892

Browse files
committed
instead of storing module indices in DeclNode, store decl indices in Module structure
1 parent b55c2fd commit 7311892

File tree

5 files changed

+13
-87
lines changed

5 files changed

+13
-87
lines changed

Sources/SymbolGraphBuilder/Sources/SSGC.DocumentationSources.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,7 @@ extension SSGC.DocumentationSources
171171
time loading sources : \(profiler.loadingSources)
172172
time linking : \(profiler.linking)
173173
symbols : \(graph.decls.symbols.count)
174-
redirects : \(graph.decls.nodes.reduce(0)
175-
{
176-
$0 + $1.exporters.count
177-
})
174+
redirects : \(graph.cultures.reduce(0) { $0 + $1.reexports.count })
178175
""")
179176

180177
return graph

Sources/SymbolGraphLinker/SSGC.Linker.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ extension SSGC.Linker
236236
{
237237
if let reexported:Int32 = self.tables.citizen(id)
238238
{
239-
self.tables.graph.decls.nodes[reexported].exporters.append(offset)
239+
self.tables.graph.cultures[offset].reexports.append(reexported)
240240
}
241241
}
242242
}

Sources/SymbolGraphs/Buffers/SymbolGraph.Buffer16.swift

Lines changed: 0 additions & 72 deletions
This file was deleted.

Sources/SymbolGraphs/Declarations/SymbolGraph.DeclNode.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ extension SymbolGraph
1111
public
1212
var extensions:[Extension]
1313
public
14-
var exporters:[Int]
15-
public
1614
var decl:Decl?
1715

1816
@inlinable public
19-
init(extensions:[Extension] = [], exporters:[Int] = [], decl:Decl? = nil)
17+
init(extensions:[Extension] = [], decl:Decl? = nil)
2018
{
2119
self.extensions = extensions
22-
self.exporters = exporters
2320
self.decl = decl
2421
}
2522
}
@@ -50,7 +47,6 @@ extension SymbolGraph.DeclNode
5047
enum CodingKey:String, Sendable
5148
{
5249
case extensions = "E"
53-
case exporters = "X"
5450
case decl = "V"
5551
}
5652
}
@@ -60,7 +56,6 @@ extension SymbolGraph.DeclNode:BSONDocumentEncodable
6056
func encode(to bson:inout BSON.DocumentEncoder<CodingKey>)
6157
{
6258
bson[.decl] = self.decl
63-
bson[.exporters] = SymbolGraph.Buffer16.init(elidingEmpty: self.exporters)
6459
bson[.extensions] = self.extensions.isEmpty ? nil : self.extensions
6560
}
6661
}
@@ -69,10 +64,7 @@ extension SymbolGraph.DeclNode:BSONDocumentDecodable
6964
@inlinable public
7065
init(bson:BSON.DocumentDecoder<CodingKey>) throws
7166
{
72-
self.init(
73-
extensions: try bson[.extensions]?.decode() ?? [],
74-
exporters: try bson[.exporters]?.decode(
75-
as: SymbolGraph.Buffer16.self, with: \.elements) ?? [],
67+
self.init(extensions: try bson[.extensions]?.decode() ?? [],
7668
decl: try bson[.decl]?.decode())
7769
}
7870
}

Sources/SymbolGraphs/Modules/SymbolGraph.Culture.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ extension SymbolGraph
1414
/// The ranges must be contiguous and non-overlapping.
1515
public
1616
var namespaces:[SymbolGraph.Namespace]
17+
/// Declarations this module re-exports, if any.
18+
public
19+
var reexports:[Int32]
20+
1721
/// This module’s standalone articles, if it has any.
1822
public
1923
var articles:ClosedRange<Int32>?
@@ -31,6 +35,7 @@ extension SymbolGraph
3135
self.module = module
3236

3337
self.namespaces = []
38+
self.reexports = []
3439
self.articles = nil
3540
self.headline = nil
3641
self.article = nil
@@ -69,6 +74,7 @@ extension SymbolGraph.Culture
6974
case module = "M"
7075

7176
case namespaces = "N"
77+
case reexports = "X"
7278
case articles_lower = "L"
7379
case articles_upper = "U"
7480
case headline = "H"
@@ -83,6 +89,7 @@ extension SymbolGraph.Culture:BSONDocumentEncodable
8389
bson[.module] = self.module
8490

8591
bson[.namespaces] = self.namespaces.isEmpty ? nil : self.namespaces
92+
bson[.reexports] = SymbolGraph.Buffer24.init(elidingEmpty: self.reexports)
8693
bson[.articles_lower] = self.articles?.lowerBound
8794
bson[.articles_upper] = self.articles?.upperBound
8895
bson[.headline] = self.headline
@@ -104,6 +111,8 @@ extension SymbolGraph.Culture:BSONDocumentDecodable
104111

105112
// TODO: validate well-formedness of scalar ranges.
106113
self.namespaces = try bson[.namespaces]?.decode() ?? []
114+
self.reexports = try bson[.reexports]?.decode(as: SymbolGraph.Buffer24.self,
115+
with: \.elements) ?? []
107116
self.headline = try bson[.headline]?.decode()
108117
self.article = try bson[.article]?.decode()
109118
}

0 commit comments

Comments
 (0)