Skip to content

Commit d976544

Browse files
committed
isEmpty in place of count > 0
1 parent 6cdb92b commit d976544

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

Sources/CryptoSwift/AES.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ final public class AES: BlockCipher {
9595
self.blockMode = blockMode
9696
self.padding = padding
9797

98-
if let iv = iv where iv.count > 0 {
98+
if let iv = iv where !iv.isEmpty {
9999
self.iv = iv
100100
} else {
101101
let defaultIV = [UInt8](count: AES.blockSize, repeatedValue: 0)
@@ -445,7 +445,7 @@ extension AES {
445445
}
446446

447447
mutating public func update(withBytes bytes:[UInt8], isLast: Bool = false) throws -> [UInt8] {
448-
if bytes.count == 0 {
448+
if bytes.isEmpty {
449449
return bytes;
450450
}
451451

Sources/CryptoSwift/Array+Extension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension Array {
1717
words.append(word)
1818
}
1919
let reminder = Array(self.suffix(self.count % chunksize))
20-
if (reminder.count > 0) {
20+
if !reminder.isEmpty {
2121
words.append(reminder)
2222
}
2323
return words

Sources/CryptoSwift/BytesSequence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct BytesSequence: SequenceType {
1818
let end = min(self.chunkSize, self.data.count - offset)
1919
let result = self.data[offset..<offset + end]
2020
offset += result.count
21-
return result.count > 0 ? result : nil
21+
return !result.isEmpty ? result : nil
2222
}
2323
}
2424
}

Sources/CryptoSwift/PKCS5/PBKDF2.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright © 2016 Marcin Krzyzanowski. All rights reserved.
77
//
88

9+
import Darwin
10+
911
public extension PKCS5 {
1012
/// A key derivation function.
1113
///
@@ -31,7 +33,7 @@ public extension PKCS5 {
3133
public init(password: [UInt8], salt: [UInt8], iterations: Int = 4096 /* c */, keyLength: Int? = nil /* dkLen */, variant: HMAC.Variant = .sha256) throws {
3234
precondition(iterations > 0)
3335

34-
guard let prf = HMAC(key: password, variant: variant) where iterations > 0 && password.count > 0 && salt.count > 0 else {
36+
guard let prf = HMAC(key: password, variant: variant) where iterations > 0 && !password.isEmpty && !salt.isEmpty else {
3537
throw Error.InvalidInput
3638
}
3739

Sources/CryptoSwift/PKCS7.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public struct PKCS7: Padding {
3737
}
3838

3939
public func remove(bytes: [UInt8], blockSize:Int?) -> [UInt8] {
40-
assert(bytes.count > 0, "Need bytes to remove padding")
41-
guard bytes.count > 0, let lastByte = bytes.last else {
40+
assert(!bytes.isEmpty, "Need bytes to remove padding")
41+
guard !bytes.isEmpty, let lastByte = bytes.last else {
4242
return bytes
4343
}
4444

0 commit comments

Comments
 (0)