Skip to content

Commit 5ec8b26

Browse files
authored
Merge pull request #28 from tayloraswift/fix-slow-package-correlation-lookup
fix #27
2 parents f88da28 + 76e0b24 commit 5ec8b26

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

Sources/UnidocPages/RenderablePage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ extension RenderablePage
5858
$0.href = "\(Site.Asset[.main_css])"
5959
$0.rel = .stylesheet
6060
}
61-
if let canonical:String
61+
if let canonical:String = canonical ?? location
6262
{
6363
$0[.link]
6464
{

Sources/UnidocQueries/Queries/WideQuery.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ extension WideQuery:VolumeLookupQuery
102102
$0[let: symbol] = Output.Principal[.master] / Volume.Vertex[.symbol]
103103
$0[let: hash] = Output.Principal[.master] / Volume.Vertex[.hash]
104104

105+
// ``namesOfLatest`` is always non-nil, so we don’t need to worry about
106+
// degenerate index behavior.
105107
$0[let: min] = Output.Principal[.namesOfLatest] / Volume.Names[.planes_min]
106108
$0[let: max] = Output.Principal[.namesOfLatest] / Volume.Names[.planes_max]
107109
}

Sources/UnidocQueries/Volumes/VolumeLookupQuery.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ extension VolumeLookupQuery
9494
$0[.replaceWith] = .init
9595
{
9696
$0[Self.names] = Mongo.Pipeline.ROOT
97+
98+
// ``Volume.Names`` is complex but not that large, and duplicating this
99+
// makes the rest of the query a lot simpler.
100+
if let names:Mongo.KeyPath = Self.namesOfLatest
101+
{
102+
$0[names] = Mongo.Pipeline.ROOT
103+
}
97104
}
98105
}
99106

Sources/UnidocRecords/Vertices/Volume.Vertex.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ extension Volume.Vertex:BSONDocumentEncodable
327327
bson[.symbol] = self.symbol
328328

329329
case .meta(let self):
330+
// This must have a value, otherwise it would get lost among all the file
331+
// vertices, and queries for it would be very slow.
332+
bson[.hash] = 0
333+
330334
bson[.stem] = ""
331335
bson[.abi] = self.abi
332336
bson[.dependencies] = self.dependencies.isEmpty ? nil : self.dependencies

0 commit comments

Comments
 (0)