@@ -47,56 +47,12 @@ public readonly void Replace(char oldValue, char newValue, int startIndex, int c
47
47
/// <param name="oldValue">The string to replace.</param>
48
48
/// <param name="newValue">The string to replace <paramref name="oldValue"/> with.</param>
49
49
/// <remarks>
50
- /// If <paramref name="newValue"/> is <c>empty</c>, instances of <paramref name="oldValue"/>
51
- /// are removed from this builder.
50
+ /// If <paramref name="newValue"/> is <c>empty</c>, instances of <paramref name="oldValue"/> are removed.
52
51
/// </remarks>
53
52
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
54
53
public void Replace ( ReadOnlySpan < char > oldValue , ReadOnlySpan < char > newValue )
55
54
=> Replace ( oldValue , newValue , 0 , Length ) ;
56
55
57
- /// <summary>
58
- /// Replaces all instances of one string with another in this builder.
59
- /// </summary>
60
- /// <param name="oldValue">The string to replace.</param>
61
- /// <param name="newValue">Object to replace <paramref name="oldValue"/> with.</param>
62
- /// <remarks>
63
- /// If <paramref name="newValue"/> is from type <see cref="ISpanFormattable"/> an optimized version is taken.
64
- /// Otherwise the ToString method is called.
65
- /// </remarks>
66
- /// /// <typeparam name="T">Any type.</typeparam>
67
- [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
68
- public void ReplaceGeneric < T > ( ReadOnlySpan < char > oldValue , T newValue )
69
- => ReplaceGeneric ( oldValue , newValue , 0 , Length ) ;
70
-
71
- /// <summary>
72
- /// Replaces all instances of one string with another in this builder.
73
- /// </summary>
74
- /// <param name="oldValue">The string to replace.</param>
75
- /// <param name="newValue">Object to replace <paramref name="oldValue"/> with.</param>
76
- /// <param name="startIndex">The index to start in this builder.</param>
77
- /// <param name="count">The number of characters to read in this builder.</param>
78
- /// <remarks>
79
- /// If <paramref name="newValue"/> is from type <see cref="ISpanFormattable"/> an optimized version is taken.
80
- /// Otherwise the ToString method is called.
81
- /// </remarks>
82
- /// /// <typeparam name="T">Any type.</typeparam>
83
- [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
84
- public void ReplaceGeneric < T > ( ReadOnlySpan < char > oldValue , T newValue , int startIndex , int count )
85
- {
86
- if ( newValue is ISpanFormattable spanFormattable )
87
- {
88
- Span < char > tempBuffer = stackalloc char [ 24 ] ;
89
- if ( spanFormattable . TryFormat ( tempBuffer , out var written , default , null ) )
90
- {
91
- Replace ( oldValue , tempBuffer [ ..written ] , startIndex , count ) ;
92
- }
93
- }
94
- else
95
- {
96
- Replace ( oldValue , ( ReadOnlySpan < char > ) newValue ? . ToString ( ) , startIndex , count ) ;
97
- }
98
- }
99
-
100
56
/// <summary>
101
57
/// Replaces all instances of one string with another in this builder.
102
58
/// </summary>
@@ -105,8 +61,7 @@ public void ReplaceGeneric<T>(ReadOnlySpan<char> oldValue, T newValue, int start
105
61
/// <param name="startIndex">The index to start in this builder.</param>
106
62
/// <param name="count">The number of characters to read in this builder.</param>
107
63
/// <remarks>
108
- /// If <paramref name="newValue"/> is <c>empty</c>, instances of <paramref name="oldValue"/>
109
- /// are removed from this builder.
64
+ /// If <paramref name="newValue"/> is <c>empty</c>, instances of <paramref name="oldValue"/> are removed.
110
65
/// </remarks>
111
66
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
112
67
public void Replace ( scoped ReadOnlySpan < char > oldValue , scoped ReadOnlySpan < char > newValue , int startIndex , int count )
@@ -160,4 +115,47 @@ public void Replace(scoped ReadOnlySpan<char> oldValue, scoped ReadOnlySpan<char
160
115
}
161
116
}
162
117
}
118
+
119
+ /// <summary>
120
+ /// Replaces all instances of one string with another in this builder.
121
+ /// </summary>
122
+ /// <param name="oldValue">The string to replace.</param>
123
+ /// <param name="newValue">Object to replace <paramref name="oldValue"/> with.</param>
124
+ /// <remarks>
125
+ /// If <paramref name="newValue"/> is from type <see cref="ISpanFormattable"/> an optimized version is taken.
126
+ /// Otherwise the ToString method is called.
127
+ /// </remarks>
128
+ /// /// <typeparam name="T">Any type.</typeparam>
129
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
130
+ public void ReplaceGeneric < T > ( ReadOnlySpan < char > oldValue , T newValue )
131
+ => ReplaceGeneric ( oldValue , newValue , 0 , Length ) ;
132
+
133
+ /// <summary>
134
+ /// Replaces all instances of one string with another in this builder.
135
+ /// </summary>
136
+ /// <param name="oldValue">The string to replace.</param>
137
+ /// <param name="newValue">Object to replace <paramref name="oldValue"/> with.</param>
138
+ /// <param name="startIndex">The index to start in this builder.</param>
139
+ /// <param name="count">The number of characters to read in this builder.</param>
140
+ /// <remarks>
141
+ /// If <paramref name="newValue"/> is from type <see cref="ISpanFormattable"/> an optimized version is taken.
142
+ /// Otherwise the ToString method is called.
143
+ /// </remarks>
144
+ /// /// <typeparam name="T">Any type.</typeparam>
145
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
146
+ public void ReplaceGeneric < T > ( ReadOnlySpan < char > oldValue , T newValue , int startIndex , int count )
147
+ {
148
+ if ( newValue is ISpanFormattable spanFormattable )
149
+ {
150
+ Span < char > tempBuffer = stackalloc char [ 24 ] ;
151
+ if ( spanFormattable . TryFormat ( tempBuffer , out var written , default , null ) )
152
+ {
153
+ Replace ( oldValue , tempBuffer [ ..written ] , startIndex , count ) ;
154
+ }
155
+ }
156
+ else
157
+ {
158
+ Replace ( oldValue , ( ReadOnlySpan < char > ) newValue ? . ToString ( ) , startIndex , count ) ;
159
+ }
160
+ }
163
161
}
0 commit comments