Source:
void drain() { if (wip.getAndIncrement() != 0) { return; } final Subscriber<? super List<T>> a = actual; final Queue<Object> q = queue; int missed = 1; for (;;) { long r = requested.get(); long e = 0L; long f = 0L; List<T> b = buffer; while (e != r) { if (a.isUnsubscribed()) { return; } boolean d = done; if (d) { Throwable ex = error; if (ex != null) { buffer = null; a.onError(ex); return; } } Object o = q.poll(); boolean empty = o == null; if (d && empty) { buffer = null; if (!b.isEmpty()) { a.onNext(b); } a.onCompleted(); return; } if (empty) { break; } T v = nl.getValue(o); b.add(v); f++; boolean emit; try { emit = predicate.call(v); } catch (Throwable ex) { unsubscribe(); buffer = null; Exceptions.throwOrReport(ex, a, v); return; } if (emit) { a.onNext(b); b = new ArrayList<T>(capacityHint); buffer = b; e++; } } if (e == r) { if (a.isUnsubscribed()) { return; } boolean d = done; if (d) { Throwable ex = error; if (ex != null) { buffer = null; a.onError(ex); return; } else if (q.isEmpty() && b.isEmpty()) { buffer = null; a.onCompleted(); return; } } } if (e != 0L) { BackpressureUtils.produced(requested, e); } if (f != 0L) { long p = upstreamConsumed + f; if (p >= limit) { upstreamConsumed = 0L; request(p); } else { upstreamConsumed = p; } } missed = wip.addAndGet(-missed); if (missed == 0) { break; } } }

Target:
void drain() { if (wip.getAndIncrement() != 0) { return; } final Subscriber<? super List<T>> localSubscriber = actual; final Queue<Object> localQueue = queue; int missed = 1; for (;;) { long localRequested = requested.get(); long localEmission = 0L; long localConsumption = 0L; List<T> localBuffer = buffer; while (localEmission != localRequested) { if (localSubscriber.isUnsubscribed()) { return; } boolean mainDone = done; if (mainDone) { Throwable exception = error; if (exception != null) { buffer = null; localSubscriber.onError(exception); return; } } Object notification = localQueue.poll(); boolean empty = notification == null; if (mainDone && empty) { buffer = null; if (!localBuffer.isEmpty()) { localSubscriber.onNext(localBuffer); } localSubscriber.onCompleted(); return; } if (empty) { break; } T value = nl.getValue(notification); localBuffer.add(value); localConsumption++; boolean emit; try { emit = predicate.call(value); } catch (Throwable ex) { unsubscribe(); buffer = null; Exceptions.throwOrReport(ex, localSubscriber, value); return; } if (emit) { localSubscriber.onNext(localBuffer); localBuffer = new ArrayList<T>(capacityHint); buffer = localBuffer; localEmission++; } } if (localEmission == localRequested) { if (localSubscriber.isUnsubscribed()) { return; } boolean mainDone = done; if (mainDone) { Throwable exception = error; if (exception != null) { buffer = null; localSubscriber.onError(exception); return; } else if (localQueue.isEmpty() && localBuffer.isEmpty()) { buffer = null; localSubscriber.onCompleted(); return; } } } if (localEmission != 0L) { BackpressureUtils.produced(requested, localEmission); } if (localConsumption != 0L) { long p = upstreamConsumed + localConsumption; if (p >= limit) { upstreamConsumed = 0L; request(p); } else { upstreamConsumed = p; } } missed = wip.addAndGet(-missed); if (missed == 0) { break; } } }