@@ -308,7 +308,7 @@ extension MutableRawSpan {
308
308
}
309
309
310
310
@_alwaysEmitIntoClient
311
- public func storeBytes< T: BitwiseCopyable > (
311
+ public mutating func storeBytes< T: BitwiseCopyable > (
312
312
of value: T , toByteOffset offset: Int = 0 , as type: T . Type
313
313
) {
314
314
_precondition (
@@ -321,7 +321,7 @@ extension MutableRawSpan {
321
321
322
322
@unsafe
323
323
@_alwaysEmitIntoClient
324
- public func storeBytes< T: BitwiseCopyable > (
324
+ public mutating func storeBytes< T: BitwiseCopyable > (
325
325
of value: T , toUncheckedByteOffset offset: Int , as type: T . Type
326
326
) {
327
327
unsafe _start( ) . storeBytes ( of: value, toByteOffset: offset, as: type)
@@ -334,20 +334,18 @@ extension MutableRawSpan {
334
334
335
335
@_alwaysEmitIntoClient
336
336
public mutating func update< S: Sequence > (
337
- startingAt byteOffset: Int = 0 ,
338
337
from source: S
339
338
) -> ( unwritten: S . Iterator , byteOffset: Int ) where S. Element: BitwiseCopyable {
340
339
var iterator = source. makeIterator ( )
341
- let offset = update ( startingAt : byteOffset , from: & iterator)
340
+ let offset = update ( from: & iterator)
342
341
return ( iterator, offset)
343
342
}
344
343
345
344
@_alwaysEmitIntoClient
346
345
public mutating func update< Element: BitwiseCopyable > (
347
- startingAt byteOffset: Int = 0 ,
348
346
from elements: inout some IteratorProtocol < Element >
349
347
) -> Int {
350
- var offset = byteOffset
348
+ var offset = 0
351
349
while offset + MemoryLayout < Element > . stride <= _count {
352
350
guard let element = elements. next ( ) else { break }
353
351
unsafe storeBytes(
@@ -360,18 +358,15 @@ extension MutableRawSpan {
360
358
361
359
@_alwaysEmitIntoClient
362
360
public mutating func update< C: Collection > (
363
- startingAt byteOffset: Int = 0 ,
364
361
fromContentsOf source: C
365
362
) -> Int where C. Element: BitwiseCopyable {
366
363
let newOffset = source. withContiguousStorageIfAvailable {
367
- self . update (
368
- startingAt: byteOffset, fromContentsOf: Span ( _unsafeElements: $0)
369
- )
364
+ self . update ( fromContentsOf: RawSpan ( _unsafeElements: $0) )
370
365
}
371
366
if let newOffset { return newOffset }
372
367
373
368
var elements = source. makeIterator ( )
374
- let lastOffset = update ( startingAt : byteOffset , from: & elements)
369
+ let lastOffset = update ( from: & elements)
375
370
_precondition (
376
371
elements. next ( ) == nil ,
377
372
" destination span cannot contain every element from source. "
@@ -381,45 +376,40 @@ extension MutableRawSpan {
381
376
382
377
@_alwaysEmitIntoClient
383
378
public mutating func update< Element: BitwiseCopyable > (
384
- startingAt byteOffset: Int = 0 ,
385
379
fromContentsOf source: Span < Element >
386
380
) -> Int {
387
- // update(startingAt: byteOffset, from: source.bytes)
381
+ // update(from: source.bytes)
388
382
source. withUnsafeBytes {
389
- update ( startingAt : byteOffset , fromContentsOf: $0)
383
+ update ( fromContentsOf: $0)
390
384
}
391
385
}
392
386
393
387
@_alwaysEmitIntoClient
394
388
public mutating func update< Element: BitwiseCopyable > (
395
- startingAt byteOffset: Int = 0 ,
396
389
fromContentsOf source: borrowing MutableSpan < Element >
397
390
) -> Int {
398
- // update(startingAt: byteOffset, from: source.storage .bytes)
391
+ // update(from: source.span .bytes)
399
392
source. withUnsafeBytes {
400
- update ( startingAt : byteOffset , fromContentsOf: $0)
393
+ update ( fromContentsOf: $0)
401
394
}
402
395
}
403
396
404
397
@_alwaysEmitIntoClient
405
398
public mutating func update(
406
- startingAt byteOffset: Int = 0 ,
407
- from source: RawSpan
399
+ fromContentsOf source: RawSpan
408
400
) -> Int {
409
- if source. byteCount == 0 { return byteOffset }
401
+ if source. byteCount == 0 { return 0 }
410
402
source. withUnsafeBytes {
411
- unsafe _start( ) . advanced ( by: byteOffset)
412
- . copyMemory ( from: $0. baseAddress!, byteCount: $0. count)
403
+ unsafe _start( ) . copyMemory ( from: $0. baseAddress!, byteCount: $0. count)
413
404
}
414
- return byteOffset &+ source. byteCount
405
+ return source. byteCount
415
406
}
416
407
417
408
@_alwaysEmitIntoClient
418
409
public mutating func update(
419
- startingAt byteOffset: Int = 0 ,
420
- from source: borrowing MutableRawSpan
410
+ fromContentsOf source: borrowing MutableRawSpan
421
411
) -> Int {
422
- update ( startingAt : byteOffset , from : source. bytes)
412
+ update ( fromContentsOf : source. bytes)
423
413
}
424
414
}
425
415
@@ -514,20 +504,9 @@ extension MutableRawSpan {
514
504
@unsafe
515
505
@_alwaysEmitIntoClient
516
506
@lifetime ( borrow self)
517
- mutating public func _extracting(
518
- unchecked bounds: some RangeExpression < Int >
519
- ) -> Self {
520
- unsafe _extracting( unchecked: bounds. relative ( to: byteOffsets) )
521
- }
522
-
523
- @unsafe
524
- @_alwaysEmitIntoClient
525
- @lifetime ( borrow self)
526
- mutating public func _extracting(
527
- unchecked bounds: ClosedRange < Int >
528
- ) -> Self {
529
- let range = Range (
530
- _uncheckedBounds: ( bounds. lowerBound, bounds. upperBound&+ 1 )
507
+ mutating public func _extracting( unchecked bounds: ClosedRange < Int > ) -> Self {
508
+ let range = unsafe Range(
509
+ uncheckedBounds: ( bounds. lowerBound, bounds. upperBound+ 1 )
531
510
)
532
511
return unsafe _extracting( unchecked: range)
533
512
}
0 commit comments