From da78365bef8e88e6952827ddc48530cacd16a60e Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Thu, 16 Mar 2023 11:08:31 -0700 Subject: [PATCH] _BString: Add isIdentical(to:) to all string views --- Sources/RopeModule/BString/Views/_BString+UTF16View.swift | 4 ++++ Sources/RopeModule/BString/Views/_BString+UTF8View.swift | 4 ++++ .../BString/Views/_BString+UnicodeScalarView.swift | 4 ++++ Sources/RopeModule/BString/Views/_BSubstring+UTF16View.swift | 5 +++++ Sources/RopeModule/BString/Views/_BSubstring+UTF8View.swift | 5 +++++ .../BString/Views/_BSubstring+UnicodeScalarView.swift | 5 +++++ 6 files changed, 27 insertions(+) diff --git a/Sources/RopeModule/BString/Views/_BString+UTF16View.swift b/Sources/RopeModule/BString/Views/_BString+UTF16View.swift index faf34b2d..5989af7f 100644 --- a/Sources/RopeModule/BString/Views/_BString+UTF16View.swift +++ b/Sources/RopeModule/BString/Views/_BString+UTF16View.swift @@ -37,6 +37,10 @@ extension _BString.UTF16View: Equatable { internal static func ==(left: Self, right: Self) -> Bool { _BString.utf8IsEqual(left._base, to: right._base) } + + internal func isIdentical(to other: Self) -> Bool { + self._base.isIdentical(to: other._base) + } } @available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) diff --git a/Sources/RopeModule/BString/Views/_BString+UTF8View.swift b/Sources/RopeModule/BString/Views/_BString+UTF8View.swift index ccdc4646..53dd82eb 100644 --- a/Sources/RopeModule/BString/Views/_BString+UTF8View.swift +++ b/Sources/RopeModule/BString/Views/_BString+UTF8View.swift @@ -37,6 +37,10 @@ extension _BString.UTF8View: Equatable { internal static func ==(left: Self, right: Self) -> Bool { _BString.utf8IsEqual(left._base, to: right._base) } + + internal func isIdentical(to other: Self) -> Bool { + self._base.isIdentical(to: other._base) + } } @available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) diff --git a/Sources/RopeModule/BString/Views/_BString+UnicodeScalarView.swift b/Sources/RopeModule/BString/Views/_BString+UnicodeScalarView.swift index 1c09521d..efbdf111 100644 --- a/Sources/RopeModule/BString/Views/_BString+UnicodeScalarView.swift +++ b/Sources/RopeModule/BString/Views/_BString+UnicodeScalarView.swift @@ -71,6 +71,10 @@ extension _BString.UnicodeScalarView: Equatable { internal static func ==(left: Self, right: Self) -> Bool { _BString.utf8IsEqual(left._base, to: right._base) } + + internal func isIdentical(to other: Self) -> Bool { + self._base.isIdentical(to: other._base) + } } @available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) diff --git a/Sources/RopeModule/BString/Views/_BSubstring+UTF16View.swift b/Sources/RopeModule/BString/Views/_BSubstring+UTF16View.swift index e16b68e3..4e59bfbc 100644 --- a/Sources/RopeModule/BString/Views/_BSubstring+UTF16View.swift +++ b/Sources/RopeModule/BString/Views/_BSubstring+UTF16View.swift @@ -85,6 +85,11 @@ extension _BSubstring.UTF16View: Equatable { return _BString.utf8IsEqual(left._base, in: i1 ..< j1, to: right._base, in: i2 ..< j2) } + + internal func isIdentical(to other: Self) -> Bool { + guard self._base.isIdentical(to: other._base) else { return false } + return self._bounds == other._bounds + } } @available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) diff --git a/Sources/RopeModule/BString/Views/_BSubstring+UTF8View.swift b/Sources/RopeModule/BString/Views/_BSubstring+UTF8View.swift index f8c83458..048e5b90 100644 --- a/Sources/RopeModule/BString/Views/_BSubstring+UTF8View.swift +++ b/Sources/RopeModule/BString/Views/_BSubstring+UTF8View.swift @@ -62,6 +62,11 @@ extension _BSubstring.UTF8View: Equatable { internal static func ==(left: Self, right: Self) -> Bool { _BString.utf8IsEqual(left._base, in: left._bounds, to: right._base, in: right._bounds) } + + internal func isIdentical(to other: Self) -> Bool { + guard self._base.isIdentical(to: other._base) else { return false } + return self._bounds == other._bounds + } } @available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) diff --git a/Sources/RopeModule/BString/Views/_BSubstring+UnicodeScalarView.swift b/Sources/RopeModule/BString/Views/_BSubstring+UnicodeScalarView.swift index 6b28d6f8..cb5e578c 100644 --- a/Sources/RopeModule/BString/Views/_BSubstring+UnicodeScalarView.swift +++ b/Sources/RopeModule/BString/Views/_BSubstring+UnicodeScalarView.swift @@ -90,6 +90,11 @@ extension _BSubstring.UnicodeScalarView: Equatable { internal static func ==(left: Self, right: Self) -> Bool { _BString.utf8IsEqual(left._base, in: left._bounds, to: right._base, in: right._bounds) } + + internal func isIdentical(to other: Self) -> Bool { + guard self._base.isIdentical(to: other._base) else { return false } + return self._bounds == other._bounds + } } @available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *)