@@ -185,10 +185,11 @@ public IAppendPrepend Prepend(TSource value)
185
185
internal sealed class _ : IdentitySink < TSource >
186
186
{
187
187
private readonly IObservable < TSource > _source ;
188
- private readonly TSource [ ] _appends ;
188
+ private readonly Node < TSource > _appends ;
189
189
private readonly IScheduler _scheduler ;
190
190
191
191
private Node < TSource > _currentPrependNode ;
192
+ private TSource [ ] _appendArray ;
192
193
private int _currentAppendIndex ;
193
194
private volatile bool _disposed ;
194
195
@@ -198,11 +199,7 @@ public _(Recursive parent, IObserver<TSource> observer)
198
199
_source = parent . _source ;
199
200
_scheduler = parent . Scheduler ;
200
201
_currentPrependNode = parent . _prepends ;
201
-
202
- if ( parent . _appends != null )
203
- {
204
- _appends = parent . _appends . ToReverseArray ( ) ;
205
- }
202
+ _appends = parent . _appends ;
206
203
}
207
204
208
205
public void Run ( )
@@ -230,6 +227,7 @@ public override void OnCompleted()
230
227
}
231
228
else
232
229
{
230
+ _appendArray = _appends . ToReverseArray ( ) ;
233
231
//
234
232
// We never allow the scheduled work to be cancelled. Instead, the _disposed flag
235
233
// is used to have LoopRec bail out and perform proper clean-up of the
@@ -284,12 +282,12 @@ private IDisposable AppendValues(IScheduler scheduler)
284
282
return Disposable . Empty ;
285
283
}
286
284
287
- var current = _appends [ _currentAppendIndex ] ;
285
+ var current = _appendArray [ _currentAppendIndex ] ;
288
286
ForwardOnNext ( current ) ;
289
287
290
288
_currentAppendIndex ++ ;
291
289
292
- if ( _currentAppendIndex == _appends . Length )
290
+ if ( _currentAppendIndex == _appendArray . Length )
293
291
{
294
292
ForwardOnCompleted ( ) ;
295
293
}
@@ -350,7 +348,7 @@ internal sealed class _ : IdentitySink<TSource>
350
348
{
351
349
private readonly IObservable < TSource > _source ;
352
350
private readonly Node < TSource > _prepends ;
353
- private readonly TSource [ ] _appends ;
351
+ private readonly Node < TSource > _appends ;
354
352
private readonly ISchedulerLongRunning _scheduler ;
355
353
356
354
private IDisposable _schedulerDisposable ;
@@ -360,12 +358,8 @@ public _(LongRunning parent, IObserver<TSource> observer)
360
358
{
361
359
_source = parent . _source ;
362
360
_scheduler = parent . _longRunningScheduler ;
363
-
364
361
_prepends = parent . _prepends ;
365
- if ( parent . _appends != null )
366
- {
367
- _appends = parent . _appends . ToReverseArray ( ) ;
368
- }
362
+ _appends = parent . _appends ;
369
363
}
370
364
371
365
public void Run ( )
@@ -423,7 +417,7 @@ private void PrependValues(ICancelable cancel)
423
417
424
418
private void AppendValues ( ICancelable cancel )
425
419
{
426
- var array = _appends ;
420
+ var array = _appends . ToReverseArray ( ) ;
427
421
var i = 0 ;
428
422
429
423
while ( ! cancel . IsDisposed )
0 commit comments