diff --git a/CHANGELOG.md b/CHANGELOG.md index c0515ca..944567a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,13 @@ All notable changes to **ValueStringBuilder** will be documented in this file. T ## [Unreleased] +### Added + +- Added `Equals(ReadOnlySpan, StringComparison)` (by @Joy-less in #234) + ### Changed +- Improved `Equals(ReadOnlySpan)` (by @Joy-less in #234) - Added performance short-circuit when span is empty in `Append(ReadOnlySpan)`, `AppendSpan(int)`, `Insert(int, ReadOnlySpan)` in #233 (by @Joy-less) ## [2.2.0] - 2025-01-25 diff --git a/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs b/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs index dfcc688..f760d2a 100644 --- a/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs +++ b/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs @@ -243,7 +243,7 @@ public readonly int LastIndexOf(ReadOnlySpan word, int startIndex) } /// - /// Returns a value indicating whether a specified substring occurs within this string. + /// Returns whether a specified substring occurs within this string. /// /// Word to look for in this string. /// True if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false. @@ -254,12 +254,21 @@ public readonly int LastIndexOf(ReadOnlySpan word, int startIndex) public readonly bool Contains(ReadOnlySpan word) => IndexOf(word) != -1; /// - /// Returns a value indicating whether the characters in this instance are equal to the characters in a specified read-only character span. + /// Returns whether the characters in this builder are equal to the characters in the given span. /// /// The character span to compare with the current instance. /// if the characters are equal to this instance, otherwise . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly bool Equals(ReadOnlySpan span) => span.SequenceEqual(AsSpan()); + public readonly bool Equals(ReadOnlySpan span) => span.Equals(AsSpan(), StringComparison.Ordinal); + + /// + /// Returns whether the characters in this builder are equal to the characters in the given span according to the given comparison type. + /// + /// The character span to compare with the current instance. + /// The way to compare the sequences of characters. + /// if the characters are equal to this instance, otherwise . + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly bool Equals(ReadOnlySpan span, StringComparison comparisonType) => span.Equals(AsSpan(), comparisonType); /// /// Disposes the instance and returns the rented buffer to the array pool if needed.