Skip to content

Commit 379f07d

Browse files
committed
shouldSubscribe boolean variable not required
1 parent a85a11e commit 379f07d

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/main/java/rx/internal/operators/OperatorMulticast.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,13 @@ public void call(Subscriber<? super R> subscriber) {
7979
public void connect(Action1<? super Subscription> connection) {
8080
// each time we connect we create a new Subject and Subscription
8181

82-
boolean shouldSubscribe = false;
83-
8482
// subscription is the state of whether we are connected or not
8583
synchronized (guard) {
8684
if (subscription != null) {
8785
// already connected
8886
connection.call(guardedSubscription);
8987
return;
9088
} else {
91-
shouldSubscribe = true;
9289
// we aren't connected, so let's create a new Subject and connect
9390
final Subject<? super T, ? extends R> subject = subjectFactory.call();
9491
// create new Subscriber that will pass-thru to the subject we just created
@@ -143,18 +140,16 @@ public void call() {
143140
}
144141

145142
// in the lock above we determined we should subscribe, do it now outside the lock
146-
if (shouldSubscribe) {
147-
// register a subscription that will shut this down
148-
connection.call(guardedSubscription);
143+
// register a subscription that will shut this down
144+
connection.call(guardedSubscription);
149145

150-
// now that everything is hooked up let's subscribe
151-
// as long as the subscription is not null (which can happen if already unsubscribed)
152-
Subscriber<T> sub;
153-
synchronized (guard) {
154-
sub = subscription;
155-
}
156-
if (sub != null)
157-
source.subscribe(sub);
146+
// now that everything is hooked up let's subscribe
147+
// as long as the subscription is not null (which can happen if already unsubscribed)
148+
Subscriber<T> sub;
149+
synchronized (guard) {
150+
sub = subscription;
158151
}
152+
if (sub != null)
153+
source.subscribe(sub);
159154
}
160155
}

0 commit comments

Comments
 (0)