@@ -194,19 +194,20 @@ private void ReadjustKeys()
194
194
/// <returns>Inner ItemsSource Index.</returns>
195
195
private int ToInnerIndex ( int outerIndex )
196
196
{
197
- #if DEBUG
198
197
if ( ( uint ) outerIndex >= Count )
199
198
{
200
- throw new ArgumentOutOfRangeException ( nameof ( outerIndex ) ) ;
199
+ ThrowArgumentOutOfRangeException ( ) ;
201
200
}
202
201
203
202
if ( _interspersedObjects . ContainsKey ( outerIndex ) )
204
203
{
205
- throw new ArgumentException ( "The outer index can't be inserted as a key to the original collection." ) ;
204
+ ThrowArgumentException ( ) ;
206
205
}
207
- #endif
208
206
209
207
return outerIndex - _interspersedObjects . Keys . Count ( key => key . Value <= outerIndex ) ;
208
+
209
+ static void ThrowArgumentOutOfRangeException ( ) => throw new ArgumentOutOfRangeException ( nameof ( outerIndex ) ) ;
210
+ static void ThrowArgumentException ( ) => throw new ArgumentException ( "The outer index can't be inserted as a key to the original collection." ) ;
210
211
}
211
212
212
213
/// <summary>
@@ -216,12 +217,10 @@ private int ToInnerIndex(int outerIndex)
216
217
/// <returns>Index into the entire collection.</returns>
217
218
private int ToOuterIndex ( int innerIndex )
218
219
{
219
- #if DEBUG
220
220
if ( ( uint ) innerIndex >= ItemsSource . Count )
221
221
{
222
- throw new ArgumentOutOfRangeException ( nameof ( innerIndex ) ) ;
222
+ ThrowArgumentOutOfRangeException ( ) ;
223
223
}
224
- #endif
225
224
226
225
var keys = _interspersedObjects . OrderBy ( v => v . Key ) ;
227
226
@@ -238,6 +237,8 @@ private int ToOuterIndex(int innerIndex)
238
237
}
239
238
240
239
return innerIndex ;
240
+
241
+ static void ThrowArgumentOutOfRangeException ( ) => throw new ArgumentOutOfRangeException ( nameof ( innerIndex ) ) ;
241
242
}
242
243
243
244
/// <summary>
@@ -247,12 +248,10 @@ private int ToOuterIndex(int innerIndex)
247
248
/// <returns>Projected index in the entire collection.</returns>
248
249
private int ToOuterIndexAfterRemoval ( int innerIndexToProject )
249
250
{
250
- #if DEBUG
251
251
if ( ( uint ) innerIndexToProject >= ItemsSource . Count + 1 )
252
252
{
253
- throw new ArgumentOutOfRangeException ( nameof ( innerIndexToProject ) ) ;
253
+ ThrowArgumentOutOfRangeException ( ) ;
254
254
}
255
- #endif
256
255
257
256
//// TODO: Deal with bounds (0 / Count)? Or is it the same?
258
257
@@ -271,6 +270,8 @@ private int ToOuterIndexAfterRemoval(int innerIndexToProject)
271
270
}
272
271
273
272
return innerIndexToProject ;
273
+
274
+ static void ThrowArgumentOutOfRangeException ( ) => throw new ArgumentOutOfRangeException ( nameof ( innerIndexToProject ) ) ;
274
275
}
275
276
276
277
/// <summary>
0 commit comments