File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -337,3 +337,35 @@ extension _UnsafeBitset.Word: Sequence, IteratorProtocol {
337
337
return bit
338
338
}
339
339
}
340
+
341
+ extension _UnsafeBitset {
342
+ @_alwaysEmitIntoClient
343
+ @inline ( __always)
344
+ internal static func _withTemporaryUninitializedBitset< R> (
345
+ wordCount: Int ,
346
+ body: ( _UnsafeBitset ) throws -> R
347
+ ) rethrows -> R {
348
+ try withUnsafeTemporaryAllocation (
349
+ of: _UnsafeBitset. Word. self, capacity: wordCount
350
+ ) { buffer in
351
+ let bitset = _UnsafeBitset (
352
+ words: buffer. baseAddress!, wordCount: buffer. count)
353
+ return try body ( bitset)
354
+ }
355
+ }
356
+
357
+ @_alwaysEmitIntoClient
358
+ @inline ( __always)
359
+ internal static func withTemporaryBitset< R> (
360
+ capacity: Int ,
361
+ body: ( _UnsafeBitset ) throws -> R
362
+ ) rethrows -> R {
363
+ let wordCount = Swift . max ( 1 , Self . wordCount ( forCapacity: capacity) )
364
+ return try _withTemporaryUninitializedBitset (
365
+ wordCount: wordCount
366
+ ) { bitset in
367
+ bitset. clear ( )
368
+ return try body ( bitset)
369
+ }
370
+ }
371
+ }
You can’t perform that action at this time.
0 commit comments