Skip to content

Commit

Permalink
copy(with: VerificationResult): optimization to avoid copies
Browse files Browse the repository at this point in the history
I noticed this could be improved while working on #2635.
  • Loading branch information
NachoSoto committed Jun 13, 2023
1 parent 06b0f3d commit f78fba4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/Identity/CustomerInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ extension CustomerInfo {

/// Creates a copy of this ``CustomerInfo`` modifying only the ``VerificationResult``.
func copy(with entitlementVerification: VerificationResult) -> Self {
guard entitlementVerification != self.data.entitlementVerification else { return self }

var copy = self.data
copy.entitlementVerification = entitlementVerification
return .init(data: copy)
Expand Down
2 changes: 2 additions & 0 deletions Sources/Networking/HTTPClient/HTTPResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ extension HTTPResponse {
}

func copy(with newVerificationResult: VerificationResult) -> Self {
guard newVerificationResult != self.verificationResult else { return self }

return .init(
statusCode: self.statusCode,
responseHeaders: self.responseHeaders,
Expand Down

0 comments on commit f78fba4

Please sign in to comment.