Remove swift-collections dependency - #948
Conversation
|
Could you inspect the CI build errors? @dfed Hint: the key is binary distribution (it was downgraded for a reason); the closest comment I could find was apple/swift-collections#546 (comment) Haven't tested it tho |
|
After a short test, I see 2 obstacles:
I'm happy to merge it once we resolve the latter. |
|
Got it. @pblazej would y'all be interested in a PR that copy/pasted the existing implementation of |
|
@dfed thank you for going the extra mile here! The problem with binary distribution is pretty common across Apple libs e.g. apple/swift-nio#2897 and already happened to use with I think porting the minimal API is better than carrying "a big part of the lib" under Apache as our usage is pretty narrow, the impact of future optimizations (leveraging ownership etc.) is probably negligible. 2 things:
|
|
@dfed can we finalize this PR? I've got some reports on other consumers blocked by that, don't want to duplicate your great work. |
Replace DequeModule and OrderedCollections with minimal internal implementations covering only the APIs actually used (~14 call sites). This unblocks consumers from being pinned to old swift-collections versions due to library evolution mode compatibility constraints. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Array.removeFirst() is O(n), making the processSendQueue drain loop O(n²). Switch to a circular buffer backed by [Element?] with head pointer tracking for O(1) amortized append and removeFirst. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use bitwise AND instead of modulo in Deque (power-of-two optimization) - Change fatalError to preconditionFailure to match Array behavior - Handle duplicate keys in OrderedDictionary init(uniqueKeysWithValues:) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Summary
DequeModuleandOrderedCollectionsimports with minimal internal implementations (Deque,OrderedDictionary,OrderedSet) inSources/LiveKit/Support/DataStructures/swift-collectionsfromPackage.swift,Package@swift-6.0.swift, andLiveKitClient.podspecDetails
The actual API surface used was tiny — 3 types, ~14 call sites, all internal. The new implementations are ~180 lines total, matching the existing pattern of lightweight data structures in the repo (
RingBuffer,MapTable,TTLDictionary).Test plan
xcodebuild build -scheme LiveKit -destination 'platform=macOS'succeedsxcodebuild test -scheme LiveKit -only-testing LiveKitCoreTests -destination 'platform=macOS'— all non-E2E tests pass (E2E tests require local server)🤖 Generated with Claude Code