Skip to content

Commit

Permalink
refactor: remove bool comparisons to decrease build times (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaker6 authored Jan 15, 2022
1 parent b92667f commit b2a0d9c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Sources/ParseSwift/Extensions/URLSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal extension URLSession {
return .failure(error)
}
guard let parseError = error as? ParseError else {
guard JSONSerialization.isValidJSONObject(responseData) == true,
guard JSONSerialization.isValidJSONObject(responseData),
let json = try? JSONSerialization
.data(withJSONObject: responseData,
options: .prettyPrinted) else {
Expand Down
6 changes: 3 additions & 3 deletions Sources/ParseSwift/LiveQuery/ParseLiveQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public final class ParseLiveQuery: NSObject {
//Task
var task: URLSessionWebSocketTask! {
willSet {
if newValue == nil && isSocketEstablished == true {
if newValue == nil && isSocketEstablished {
isSocketEstablished = false
}
}
Expand All @@ -79,7 +79,7 @@ Not attempting to open ParseLiveQuery socket anymore
}
var isDisconnectedByUser = false {
willSet {
if newValue == true {
if newValue {
isConnected = false
}
}
Expand Down Expand Up @@ -110,7 +110,7 @@ Not attempting to open ParseLiveQuery socket anymore
/// True if the connection to the url is up and available. False otherwise.
public internal(set) var isSocketEstablished = false { //URLSession has an established socket
willSet {
if newValue == false {
if !newValue {
isConnected = newValue
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/ParseSwift/Objects/ParseUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ extension ParseUser {
}
var mutableSelf = self
if let currentUser = Self.current,
currentUser.hasSameObjectId(as: mutableSelf) == true {
currentUser.hasSameObjectId(as: mutableSelf) {
#if !os(Linux) && !os(Android) && !os(Windows)
// swiftlint:disable:next line_length
if let currentUserContainerInKeychain: CurrentUserContainer<BaseParseUser> = try? KeychainStore.shared.get(valueFor: ParseStorage.Keys.currentUser),
Expand Down Expand Up @@ -1103,7 +1103,7 @@ extension ParseUser {
}
var mutableSelf = self
if let currentUser = Self.current,
currentUser.hasSameObjectId(as: mutableSelf) == true {
currentUser.hasSameObjectId(as: mutableSelf) {
#if !os(Linux) && !os(Android) && !os(Windows)
// swiftlint:disable:next line_length
if let currentUserContainerInKeychain: CurrentUserContainer<BaseParseUser> = try? KeychainStore.shared.get(valueFor: ParseStorage.Keys.currentUser),
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/Parse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public struct ParseSwift {
#if !os(Linux) && !os(Android) && !os(Windows)
// Clear items out of the Keychain on app first run.
if UserDefaults.standard.object(forKey: ParseConstants.bundlePrefix) == nil {
if Self.configuration.isDeletingKeychainIfNeeded == true {
if Self.configuration.isDeletingKeychainIfNeeded {
try? KeychainStore.old.deleteAll()
try? KeychainStore.shared.deleteAll()
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/Types/ParseError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public extension Error {
*/
func containedIn(_ errorCodes: [ParseError.Code]) -> ParseError? {
guard let error = self as? ParseError,
errorCodes.contains(error.code) == true else {
errorCodes.contains(error.code) else {
return nil
}
return error
Expand Down

0 comments on commit b2a0d9c

Please sign in to comment.