File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -499,7 +499,8 @@ extension Unsafe${Mutable}BufferPointer {
499
499
@inlinable // unsafe-performance
500
500
public init( rebasing slice: Slice < UnsafeBufferPointer < Element > > ) {
501
501
let base = slice. base. baseAddress? . advanced ( by: slice. startIndex)
502
- self . init ( start: base, count: slice. count)
502
+ let count = slice. endIndex &- slice. startIndex
503
+ self . init ( start: base, count: count)
503
504
}
504
505
505
506
% end
@@ -526,7 +527,8 @@ extension Unsafe${Mutable}BufferPointer {
526
527
@inlinable // unsafe-performance
527
528
public init( rebasing slice: Slice < UnsafeMutableBufferPointer < Element > > ) {
528
529
let base = slice. base. baseAddress? . advanced ( by: slice. startIndex)
529
- self . init ( start: base, count: slice. count)
530
+ let count = slice. endIndex &- slice. startIndex
531
+ self . init ( start: base, count: count)
530
532
}
531
533
532
534
/// Deallocates the memory block previously allocated at this buffer pointer’s
Original file line number Diff line number Diff line change @@ -512,7 +512,8 @@ extension Unsafe${Mutable}RawBufferPointer {
512
512
@inlinable
513
513
public init ( rebasing slice: Slice < UnsafeRawBufferPointer > ) {
514
514
let base = slice. base. baseAddress? . advanced ( by: slice. startIndex)
515
- self . init ( start: base, count: slice. count)
515
+ let count = slice. endIndex &- slice. startIndex
516
+ self . init ( start: base, count: count)
516
517
}
517
518
% end # !mutable
518
519
@@ -539,7 +540,8 @@ extension Unsafe${Mutable}RawBufferPointer {
539
540
@inlinable
540
541
public init ( rebasing slice: Slice < UnsafeMutableRawBufferPointer > ) {
541
542
let base = slice. base. baseAddress? . advanced ( by: slice. startIndex)
542
- self . init ( start: base, count: slice. count)
543
+ let count = slice. endIndex &- slice. startIndex
544
+ self . init ( start: base, count: count)
543
545
}
544
546
545
547
/// A pointer to the first byte of the buffer.
You can’t perform that action at this time.
0 commit comments