Skip to content

Commit 4a872ed

Browse files
authored
Revert "Implement a custom Data.Iterator" (#3848)
1 parent c4ed81b commit 4a872ed

File tree

5 files changed

+1
-103
lines changed

5 files changed

+1
-103
lines changed

benchmark/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ set(SWIFT_BENCH_MODULES
3737
single-source/CaptureProp
3838
single-source/Chars
3939
single-source/ClassArrayGetter
40-
single-source/Data
4140
single-source/DeadArray
4241
single-source/DictionaryBridge
4342
single-source/DictionaryLiteral

benchmark/single-source/Data.swift

Lines changed: 0 additions & 34 deletions
This file was deleted.

benchmark/utils/main.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import Calculator
3838
import CaptureProp
3939
import Chars
4040
import ClassArrayGetter
41-
import Data
4241
import DeadArray
4342
import DictTest
4443
import DictTest2
@@ -142,7 +141,6 @@ precommitTests = [
142141
"HashTest": run_HashTest,
143142
"Histogram": run_Histogram,
144143
"Integrate": run_Integrate,
145-
"IterateData": run_IterateData,
146144
"Join": run_Join,
147145
"LinkedList": run_LinkedList,
148146
"MapReduce": run_MapReduce,

stdlib/public/SDK/Foundation/Data.swift

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -647,40 +647,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
647647
///
648648
/// The iterator will increment byte-by-byte.
649649
public func makeIterator() -> Data.Iterator {
650-
return Iterator(_data: self)
651-
}
652-
653-
public struct Iterator : IteratorProtocol {
654-
private let _data: Data
655-
private var _buffer: (
656-
UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8,
657-
UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8,
658-
UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8,
659-
UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8)
660-
private var _idx: Data.Index
661-
private let _endIdx: Data.Index
662-
663-
private init(_data: Data) {
664-
self._data = _data
665-
_buffer = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
666-
_idx = 0
667-
_endIdx = _data.endIndex
668-
}
669-
670-
public mutating func next() -> UInt8? {
671-
guard _idx < _endIdx else { return nil }
672-
defer { _idx += 1 }
673-
let bufferSize = sizeofValue(_buffer)
674-
return withUnsafeMutablePointer(to: &_buffer) { ptr_ in
675-
let ptr = UnsafeMutableRawPointer(ptr_).assumingMemoryBound(to: UInt8.self)
676-
let bufferIdx = _idx % bufferSize
677-
if bufferIdx == 0 {
678-
// populate the buffer
679-
_data.copyBytes(to: ptr, from: _idx..<(_endIdx - _idx > bufferSize ? _idx + bufferSize : _endIdx))
680-
}
681-
return ptr[bufferIdx]
682-
}
683-
}
650+
return IndexingIterator(_elements: self)
684651
}
685652

686653
// MARK: -

validation-test/stdlib/Data.swift

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)