@@ -194,19 +194,20 @@ private void ReadjustKeys()
194194 /// <returns>Inner ItemsSource Index.</returns>
195195 private int ToInnerIndex ( int outerIndex )
196196 {
197- #if DEBUG
198197 if ( ( uint ) outerIndex >= Count )
199198 {
200- throw new ArgumentOutOfRangeException ( nameof ( outerIndex ) ) ;
199+ ThrowArgumentOutOfRangeException ( ) ;
201200 }
202201
203202 if ( _interspersedObjects . ContainsKey ( outerIndex ) )
204203 {
205- throw new ArgumentException ( "The outer index can't be inserted as a key to the original collection." ) ;
204+ ThrowArgumentException ( ) ;
206205 }
207- #endif
208206
209207 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." ) ;
210211 }
211212
212213 /// <summary>
@@ -216,12 +217,10 @@ private int ToInnerIndex(int outerIndex)
216217 /// <returns>Index into the entire collection.</returns>
217218 private int ToOuterIndex ( int innerIndex )
218219 {
219- #if DEBUG
220220 if ( ( uint ) innerIndex >= ItemsSource . Count )
221221 {
222- throw new ArgumentOutOfRangeException ( nameof ( innerIndex ) ) ;
222+ ThrowArgumentOutOfRangeException ( ) ;
223223 }
224- #endif
225224
226225 var keys = _interspersedObjects . OrderBy ( v => v . Key ) ;
227226
@@ -238,6 +237,8 @@ private int ToOuterIndex(int innerIndex)
238237 }
239238
240239 return innerIndex ;
240+
241+ static void ThrowArgumentOutOfRangeException ( ) => throw new ArgumentOutOfRangeException ( nameof ( innerIndex ) ) ;
241242 }
242243
243244 /// <summary>
@@ -247,12 +248,10 @@ private int ToOuterIndex(int innerIndex)
247248 /// <returns>Projected index in the entire collection.</returns>
248249 private int ToOuterIndexAfterRemoval ( int innerIndexToProject )
249250 {
250- #if DEBUG
251251 if ( ( uint ) innerIndexToProject >= ItemsSource . Count + 1 )
252252 {
253- throw new ArgumentOutOfRangeException ( nameof ( innerIndexToProject ) ) ;
253+ ThrowArgumentOutOfRangeException ( ) ;
254254 }
255- #endif
256255
257256 //// TODO: Deal with bounds (0 / Count)? Or is it the same?
258257
@@ -271,6 +270,8 @@ private int ToOuterIndexAfterRemoval(int innerIndexToProject)
271270 }
272271
273272 return innerIndexToProject ;
273+
274+ static void ThrowArgumentOutOfRangeException ( ) => throw new ArgumentOutOfRangeException ( nameof ( innerIndexToProject ) ) ;
274275 }
275276
276277 /// <summary>
0 commit comments