Skip to content

Commit

Permalink
only use the last file component when deciding decoding strategy (#665)
Browse files Browse the repository at this point in the history
rdar://112664398
  • Loading branch information
QuietMisdreavus authored Jul 21, 2023
1 parent a85c614 commit 430262e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct SymbolGraphLoader {
// This strategy benchmarks better when we have multiple
// "larger" symbol graphs.
#if os(macOS) || os(iOS)
if bundle.symbolGraphURLs.filter({ !$0.path.contains("@") }).count > 1 {
if bundle.symbolGraphURLs.filter({ !$0.lastPathComponent.contains("@") }).count > 1 {
// There are multiple main symbol graphs, better parallelize all files decoding.
decodingStrategy = .concurrentlyAllFiles
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,27 @@ class SymbolGraphLoaderTests: XCTestCase {
XCTAssertTrue(foundMainAsyncMethodsGraph, "AsyncMethods graph wasn't found")
}
}


/// Ensure that loading symbol graphs from a directory with an at-sign properly selects the
/// `concurrentlyAllFiles` decoding strategy on macOS and iOS.
func testLoadingSymbolsInAtSignDirectory() throws {
let tempURL = try createTemporaryDirectory(pathComponents: "MyTempDir@2")
let originalSymbolGraphs = [
CopyOfFile(original: Bundle.module.url(forResource: "Asides.symbols", withExtension: "json", subdirectory: "Test Resources")!),
CopyOfFile(original: Bundle.module.url(forResource: "WithCompletionHandler.symbols", withExtension: "json", subdirectory: "Test Resources")!)
]
let symbolGraphURLs = try originalSymbolGraphs.map({ try $0.write(inside: tempURL) })

var loader = try makeSymbolGraphLoader(symbolGraphURLs: symbolGraphURLs)
try loader.loadAll()

#if os(macOS) || os(iOS)
XCTAssertEqual(loader.decodingStrategy, .concurrentlyAllFiles)
#else
XCTAssertEqual(loader.decodingStrategy, .concurrentlyEachFileInBatches)
#endif
}

func testInputWithMixedGraphFormats() throws {
let tempURL = try createTemporaryDirectory()

Expand Down

0 comments on commit 430262e

Please sign in to comment.