Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -423,13 +423,21 @@ let benchmarks = {
let manyAttributesSubstring = manyAttributesString[manyAttributesStringRange]
let manyAttributes2Substring = manyAttributesString2[manyAttributesStringRange]

Benchmark("equalityShared") { benchmark in
blackHole(manyAttributesString == manyAttributesString)
}

Benchmark("equality") { benchmark in
blackHole(manyAttributesString == manyAttributesString2)
}

Benchmark("equalityDifferingCharacters") { benchmark in
blackHole(manyAttributesString == manyAttributesString3)
}

Benchmark("substringEqualityShared") { benchmark in
blackHole(manyAttributesSubstring == manyAttributesSubstring)
}

Benchmark("substringEquality") { benchmark in
blackHole(manyAttributesSubstring == manyAttributes2Substring)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ extension AttributedString {
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
extension AttributedString { // Equatable
public static func == (lhs: Self, rhs: Self) -> Bool {
AttributedString.Guts.characterwiseIsEqual(lhs._guts, to: rhs._guts)
if lhs._guts === rhs._guts {
return true
}
return AttributedString.Guts.characterwiseIsEqual(lhs._guts, to: rhs._guts)
}
}

Expand Down