File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
src/libraries/System.Collections/src/System/Collections/Generic Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -228,7 +228,9 @@ IEnumerator IEnumerable.GetEnumerator()
228
228
public T Dequeue ( )
229
229
{
230
230
if ( _size == 0 )
231
- throw new InvalidOperationException ( SR . InvalidOperation_EmptyQueue ) ;
231
+ {
232
+ ThrowForEmptyQueue ( ) ;
233
+ }
232
234
233
235
T removed = _array [ _head ] ;
234
236
_array [ _head ] = default ( T ) ;
@@ -244,8 +246,10 @@ public T Dequeue()
244
246
public T Peek ( )
245
247
{
246
248
if ( _size == 0 )
247
- throw new InvalidOperationException ( SR . InvalidOperation_EmptyQueue ) ;
248
-
249
+ {
250
+ ThrowForEmptyQueue ( ) ;
251
+ }
252
+
249
253
return _array [ _head ] ;
250
254
}
251
255
@@ -328,6 +332,12 @@ private void MoveNext(ref int index)
328
332
index = ( tmp == _array . Length ) ? 0 : tmp ;
329
333
}
330
334
335
+ private void ThrowForEmptyQueue ( )
336
+ {
337
+ Debug . Assert ( _size == 0 ) ;
338
+ throw new InvalidOperationException ( SR . InvalidOperation_EmptyQueue ) ;
339
+ }
340
+
331
341
public void TrimExcess ( )
332
342
{
333
343
int threshold = ( int ) ( ( ( double ) _array . Length ) * 0.9 ) ;
You can’t perform that action at this time.
0 commit comments