@@ -80,56 +80,12 @@ public void Replace(Rune oldValue, Rune newValue, int startIndex, int count)
80
80
/// <param name="oldValue">The string to replace.</param>
81
81
/// <param name="newValue">The string to replace <paramref name="oldValue"/> with.</param>
82
82
/// <remarks>
83
- /// If <paramref name="newValue"/> is <c>empty</c>, instances of <paramref name="oldValue"/>
84
- /// are removed from this builder.
83
+ /// If <paramref name="newValue"/> is <c>empty</c>, instances of <paramref name="oldValue"/> are removed.
85
84
/// </remarks>
86
85
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
87
86
public void Replace ( scoped ReadOnlySpan < char > oldValue , scoped ReadOnlySpan < char > newValue )
88
87
=> Replace ( oldValue , newValue , 0 , Length ) ;
89
88
90
- /// <summary>
91
- /// Replaces all instances of one string with another in this builder.
92
- /// </summary>
93
- /// <param name="oldValue">The string to replace.</param>
94
- /// <param name="newValue">Object to replace <paramref name="oldValue"/> with.</param>
95
- /// <remarks>
96
- /// If <paramref name="newValue"/> is from type <see cref="ISpanFormattable"/> an optimized version is taken.
97
- /// Otherwise the ToString method is called.
98
- /// </remarks>
99
- /// /// <typeparam name="T">Any type.</typeparam>
100
- [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
101
- public void ReplaceGeneric < T > ( scoped ReadOnlySpan < char > oldValue , T newValue )
102
- => ReplaceGeneric ( oldValue , newValue , 0 , Length ) ;
103
-
104
- /// <summary>
105
- /// Replaces all instances of one string with another in this builder.
106
- /// </summary>
107
- /// <param name="oldValue">The string to replace.</param>
108
- /// <param name="newValue">Object to replace <paramref name="oldValue"/> with.</param>
109
- /// <param name="startIndex">The index to start in this builder.</param>
110
- /// <param name="count">The number of characters to read in this builder.</param>
111
- /// <remarks>
112
- /// If <paramref name="newValue"/> is from type <see cref="ISpanFormattable"/> an optimized version is taken.
113
- /// Otherwise the ToString method is called.
114
- /// </remarks>
115
- /// /// <typeparam name="T">Any type.</typeparam>
116
- [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
117
- public void ReplaceGeneric < T > ( scoped ReadOnlySpan < char > oldValue , T newValue , int startIndex , int count )
118
- {
119
- if ( newValue is ISpanFormattable spanFormattable )
120
- {
121
- Span < char > tempBuffer = stackalloc char [ 24 ] ;
122
- if ( spanFormattable . TryFormat ( tempBuffer , out var written , default , null ) )
123
- {
124
- Replace ( oldValue , tempBuffer [ ..written ] , startIndex , count ) ;
125
- }
126
- }
127
- else
128
- {
129
- Replace ( oldValue , ( ReadOnlySpan < char > ) newValue ? . ToString ( ) , startIndex , count ) ;
130
- }
131
- }
132
-
133
89
/// <summary>
134
90
/// Replaces all instances of one string with another in this builder.
135
91
/// </summary>
@@ -138,8 +94,7 @@ public void ReplaceGeneric<T>(scoped ReadOnlySpan<char> oldValue, T newValue, in
138
94
/// <param name="startIndex">The index to start in this builder.</param>
139
95
/// <param name="count">The number of characters to read in this builder.</param>
140
96
/// <remarks>
141
- /// If <paramref name="newValue"/> is <c>empty</c>, instances of <paramref name="oldValue"/>
142
- /// are removed from this builder.
97
+ /// If <paramref name="newValue"/> is <c>empty</c>, instances of <paramref name="oldValue"/> are removed.
143
98
/// </remarks>
144
99
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
145
100
public void Replace ( scoped ReadOnlySpan < char > oldValue , scoped ReadOnlySpan < char > newValue , int startIndex , int count )
@@ -193,4 +148,47 @@ public void Replace(scoped ReadOnlySpan<char> oldValue, scoped ReadOnlySpan<char
193
148
}
194
149
}
195
150
}
151
+
152
+ /// <summary>
153
+ /// Replaces all instances of one string with another in this builder.
154
+ /// </summary>
155
+ /// <param name="oldValue">The string to replace.</param>
156
+ /// <param name="newValue">Object to replace <paramref name="oldValue"/> with.</param>
157
+ /// <remarks>
158
+ /// If <paramref name="newValue"/> is from type <see cref="ISpanFormattable"/> an optimized version is taken.
159
+ /// Otherwise the ToString method is called.
160
+ /// </remarks>
161
+ /// /// <typeparam name="T">Any type.</typeparam>
162
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
163
+ public void ReplaceGeneric < T > ( ReadOnlySpan < char > oldValue , T newValue )
164
+ => ReplaceGeneric ( oldValue , newValue , 0 , Length ) ;
165
+
166
+ /// <summary>
167
+ /// Replaces all instances of one string with another in this builder.
168
+ /// </summary>
169
+ /// <param name="oldValue">The string to replace.</param>
170
+ /// <param name="newValue">Object to replace <paramref name="oldValue"/> with.</param>
171
+ /// <param name="startIndex">The index to start in this builder.</param>
172
+ /// <param name="count">The number of characters to read in this builder.</param>
173
+ /// <remarks>
174
+ /// If <paramref name="newValue"/> is from type <see cref="ISpanFormattable"/> an optimized version is taken.
175
+ /// Otherwise the ToString method is called.
176
+ /// </remarks>
177
+ /// /// <typeparam name="T">Any type.</typeparam>
178
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
179
+ public void ReplaceGeneric < T > ( ReadOnlySpan < char > oldValue , T newValue , int startIndex , int count )
180
+ {
181
+ if ( newValue is ISpanFormattable spanFormattable )
182
+ {
183
+ Span < char > tempBuffer = stackalloc char [ 24 ] ;
184
+ if ( spanFormattable . TryFormat ( tempBuffer , out var written , default , null ) )
185
+ {
186
+ Replace ( oldValue , tempBuffer [ ..written ] , startIndex , count ) ;
187
+ }
188
+ }
189
+ else
190
+ {
191
+ Replace ( oldValue , ( ReadOnlySpan < char > ) newValue ? . ToString ( ) , startIndex , count ) ;
192
+ }
193
+ }
196
194
}
0 commit comments