Skip to content

Commit a580b61

Browse files
committed
Use other JIT hints
1 parent ce29b51 commit a580b61

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/LinkDotNet.StringBuilder/ValueStringBuilder.AppendJoin.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void AppendJoin<T>(ReadOnlySpan<char> separator, IEnumerable<T> values)
4242
public void AppendJoin<T>(char separator, IEnumerable<T> values)
4343
=> AppendJoinInternalChar(separator, values);
4444

45-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
45+
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
4646
private void AppendJoinInternalString<T>(ReadOnlySpan<char> separator, IEnumerable<T> values)
4747
{
4848
ArgumentNullException.ThrowIfNull(values);
@@ -68,7 +68,7 @@ private void AppendJoinInternalString<T>(ReadOnlySpan<char> separator, IEnumerab
6868
}
6969
}
7070

71-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
71+
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
7272
private void AppendJoinInternalChar<T>(char separator, IEnumerable<T> values)
7373
{
7474
ArgumentNullException.ThrowIfNull(values);

src/LinkDotNet.StringBuilder/ValueStringBuilder.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public ValueStringBuilder(ReadOnlySpan<char> initialText)
114114
/// </summary>
115115
/// <param name="range">The range that will be retrieved.</param>
116116
/// <returns>The <see cref="string"/> instance.</returns>
117+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
117118
public readonly string ToString(Range range)
118119
{
119120
var (offset, length) = range.GetOffsetAndLength(bufferPosition);
@@ -296,9 +297,10 @@ public readonly void Dispose()
296297
/// <summary>
297298
/// Reverses the sequence of elements in this instance.
298299
/// </summary>
300+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
299301
public readonly void Reverse() => buffer[..bufferPosition].Reverse();
300302

301-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
303+
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
302304
private void Grow(int capacity = 0)
303305
{
304306
var size = buffer.Length == 0 ? 8 : buffer.Length;

tests/LinkDotNet.StringBuilder.UnitTests/ValueStringBuilder.Append.Tests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,15 @@ public void GivenMemorySlice_ShouldAppend()
168168

169169
builder.ToString().Should().Be("ccccc");
170170
}
171+
172+
[Fact]
173+
public void GivenAStringWithWhitespace_WhenTrimIsCalled_ThenTheStringShouldBeTrimmed()
174+
{
175+
using var builder = new ValueStringBuilder();
176+
builder.Append(" Hello World ");
177+
178+
builder.Trim();
179+
180+
builder.ToString().Should().Be("Hello World");
181+
}
171182
}

0 commit comments

Comments
 (0)