Skip to content

Commit a930e7d

Browse files
committed
removed commented code blocks that are identical to the actual code
1 parent 0b21f85 commit a930e7d

File tree

1 file changed

+0
-52
lines changed

1 file changed

+0
-52
lines changed

Sources/web3swift/Convenience/Data+Extension.swift

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,6 @@ public extension Data {
2525
}
2626
}
2727

28-
// func toArray<T>(type: T.Type) throws -> [T] {
29-
// return try self.withUnsafeBytes { (body: UnsafeRawBufferPointer) in
30-
// if let bodyAddress = body.baseAddress, body.count > 0 {
31-
// let pointer = bodyAddress.assumingMemoryBound(to: T.self)
32-
// return [T](UnsafeBufferPointer(start: pointer, count: self.count/MemoryLayout<T>.stride))
33-
// } else {
34-
// throw Web3Error.dataError
35-
// }
36-
// }
37-
// }
38-
3928
func constantTimeComparisonTo(_ other: Data?) -> Bool {
4029
guard let rhs = other else {return false}
4130
guard self.count == rhs.count else {return false}
@@ -53,13 +42,6 @@ public extension Data {
5342
}
5443
}
5544

56-
// static func zero(_ data: inout Data) {
57-
// let count = data.count
58-
// data.withUnsafeMutableBytes { (body: UnsafeMutableRawBufferPointer) in
59-
// body.baseAddress?.assumingMemoryBound(to: UInt8.self).initialize(repeating: 0, count: count)
60-
// }
61-
// }
62-
6345
static func randomBytes(length: Int) -> Data? {
6446
for _ in 0...1024 {
6547
var data = Data(repeating: 0, count: length)
@@ -78,24 +60,6 @@ public extension Data {
7860
return nil
7961
}
8062

81-
// static func randomBytes(length: Int) -> Data? {
82-
// for _ in 0...1024 {
83-
// var data = Data(repeating: 0, count: length)
84-
// let result = data.withUnsafeMutableBytes { (body: UnsafeMutableRawBufferPointer) -> Int32? in
85-
// if let bodyAddress = body.baseAddress, body.count > 0 {
86-
// let pointer = bodyAddress.assumingMemoryBound(to: UInt8.self)
87-
// return SecRandomCopyBytes(kSecRandomDefault, 32, pointer)
88-
// } else {
89-
// return nil
90-
// }
91-
// }
92-
// if let notNilResult = result, notNilResult == errSecSuccess {
93-
// return data
94-
// }
95-
// }
96-
// return nil
97-
// }
98-
9963
static func fromHex(_ hex: String) -> Data? {
10064
let string = hex.lowercased().stripHexPrefix()
10165
let array = Array<UInt8>(hex: string)
@@ -124,20 +88,4 @@ public extension Data {
12488
uintRepresentation = uintRepresentation >> UInt64(64 - length)
12589
return uintRepresentation
12690
}
127-
128-
// func bitsInRange(_ startingBit: Int, _ length: Int) -> UInt64? { // return max of 8 bytes for simplicity, non-public
129-
// if startingBit + length / 8 > self.count, length > 64, startingBit > 0, length >= 1 {return nil}
130-
// let bytes = self[(startingBit/8) ..< (startingBit+length+7)/8]
131-
// let padding = Data(repeating: 0, count: 8 - bytes.count)
132-
// let padded = bytes + padding
133-
// guard padded.count == 8 else {return nil}
134-
// let pointee = padded.withUnsafeBytes { (body: UnsafeRawBufferPointer) in
135-
// body.baseAddress?.assumingMemoryBound(to: UInt64.self).pointee
136-
// }
137-
// guard let ptee = pointee else {return nil}
138-
// var uintRepresentation = UInt64(bigEndian: ptee)
139-
// uintRepresentation = uintRepresentation << (startingBit % 8)
140-
// uintRepresentation = uintRepresentation >> UInt64(64 - length)
141-
// return uintRepresentation
142-
// }
14391
}

0 commit comments

Comments
 (0)