浏览代码

Remove unused and internal Int->bits functions that are inconsistent anyway

Marcin Krzyzanowski 6 年之前
父节点
当前提交
8559320dc5

+ 0 - 13
Sources/CryptoSwift/Generics.swift

@@ -13,19 +13,6 @@
 //  - This notice may not be removed or altered from any source or binary distribution.
 //
 
-/** build bit pattern from array of bits */
-@_specialize(exported: true, where T == UInt8)
-func integerFrom<T: FixedWidthInteger>(_ bits: Array<Bit>) -> T {
-    var bitPattern: T = 0
-    for idx in bits.indices {
-        if bits[idx] == Bit.one {
-            let bit = T(UInt64(1) << UInt64(idx))
-            bitPattern = bitPattern | bit
-        }
-    }
-    return bitPattern
-}
-
 /// Array of bytes. Caution: don't use directly because generic is slow.
 ///
 /// - parameter value: integer value

+ 0 - 7
Sources/CryptoSwift/Int+Extension.swift

@@ -20,13 +20,6 @@ import Darwin
 import Glibc
 #endif
 
-/* array of bits */
-extension Int {
-    init(bits: [Bit]) {
-        self.init(bitPattern: integerFrom(bits) as UInt)
-    }
-}
-
 extension FixedWidthInteger {
     @_transparent
     func bytes(totalBytes: Int = MemoryLayout<Self>.size) -> Array<UInt8> {

+ 0 - 4
Sources/CryptoSwift/UInt8+Extension.swift

@@ -43,10 +43,6 @@ extension UInt8 {
 
 /** Bits */
 extension UInt8 {
-    init(bits: [Bit]) {
-        self.init(integerFrom(bits) as UInt8)
-    }
-
     /** array of bits */
     public func bits() -> [Bit] {
         let totalBitsCount = MemoryLayout<UInt8>.size * 8