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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ All notable changes to **ValueStringBuilder** will be documented in this file. T

## [Unreleased]

### Added

- Added `Equals(ReadOnlySpan<char>, StringComparison)` (by @Joy-less in #234)

### Changed

- Improved `Equals(ReadOnlySpan<char>)` (by @Joy-less in #234)
- Added performance short-circuit when span is empty in `Append(ReadOnlySpan<char>)`, `AppendSpan(int)`, `Insert(int, ReadOnlySpan<char>)` in #233 (by @Joy-less)

## [2.2.0] - 2025-01-25
Expand Down
15 changes: 12 additions & 3 deletions src/LinkDotNet.StringBuilder/ValueStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public readonly int LastIndexOf(ReadOnlySpan<char> word, int startIndex)
}

/// <summary>
/// Returns a value indicating whether a specified substring occurs within this string.
/// Returns whether a specified substring occurs within this string.
/// </summary>
/// <param name="word">Word to look for in this string.</param>
/// <returns>True if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false.</returns>
Expand All @@ -254,12 +254,21 @@ public readonly int LastIndexOf(ReadOnlySpan<char> word, int startIndex)
public readonly bool Contains(ReadOnlySpan<char> word) => IndexOf(word) != -1;

/// <summary>
/// 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.
/// </summary>
/// <param name="span">The character span to compare with the current instance.</param>
/// <returns><see langword="true"/> if the characters are equal to this instance, otherwise <see langword="false"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(ReadOnlySpan<char> span) => span.SequenceEqual(AsSpan());
public readonly bool Equals(ReadOnlySpan<char> span) => span.Equals(AsSpan(), StringComparison.Ordinal);

/// <summary>
/// Returns whether the characters in this builder are equal to the characters in the given span according to the given comparison type.
/// </summary>
/// <param name="span">The character span to compare with the current instance.</param>
/// <param name="comparisonType">The way to compare the sequences of characters.</param>
/// <returns><see langword="true"/> if the characters are equal to this instance, otherwise <see langword="false"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(ReadOnlySpan<char> span, StringComparison comparisonType) => span.Equals(AsSpan(), comparisonType);

/// <summary>
/// Disposes the instance and returns the rented buffer to the array pool if needed.
Expand Down