Skip to content

Commit 5964255

Browse files
committed
Use elementsEqual in JSString: Equatable conformance
1 parent 6406ec2 commit 5964255

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/JavaScriptKit/FundamentalObjects/JSString.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ public struct JSString: LosslessStringConvertible, Equatable {
7777
/// - lhs: A string to compare.
7878
/// - rhs: Another string to compare.
7979
public static func == (lhs: JSString, rhs: JSString) -> Bool {
80-
return lhs.guts.buffer == rhs.guts.buffer
80+
guard !(lhs.guts.shouldDeallocateRef && rhs.guts.shouldDeallocateRef) else {
81+
return lhs.guts.jsRef == rhs.guts.jsRef
82+
}
83+
84+
return lhs.guts.buffer.utf8.elementsEqual(rhs.guts.buffer.utf8)
8185
}
8286
}
8387

0 commit comments

Comments
 (0)