-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.x Operators ReactiveType::AmbArray + ReactiveType::AmbIterable vs ReactiveType::Amb #4633
Comments
Sure. |
I'm following the
if (sources == null) {
sources = new Publisher[8];
for (Publisher<? extends T> p : sourcesIterable) {
if (count == sources.length) {
Publisher<? extends T>[] b = new Publisher[count + (count >> 2)];
System.arraycopy(sources, 0, b, 0, count);
sources = b;
}
sources[count++] = p;
}
} If the
if (sources == null) {
sources = new SingleSource[8];
int count = 0;
for (SingleSource<? extends T> element : sourcesIterable) {
if (count == sources.length) {
SingleSource<? extends T>[] b = new SingleSource[count + (count >> 2)];
System.arraycopy(sources, 0, b, 0, count);
sources = b;
}
sources[count++] = element;
}
} But that's not the case for But, all this overhead could be avoided just converting internally from array to
Is there any particular reason for not be doing that (performance?)? And, what approach should I take for SingleAmb? Thanks. |
Just look a further bit down to see that The separate implementations were there to reduce overhead and branching during subscription time. Null checks should be enforced everywhere. |
Thanks @akarnokd for the explanation. I'll change the for-each loop implementation for a classic loop using the |
It seems that for the implementation of the operators
AmbArray
andAmbIterable
different strategies have been adopted depending on the reactive type.Single
usesSingleAmbArray
andSingleAmbIterable
Maybe
usesMaybeAmbArray
andMaybeAmbIterable
Completable
usesCompletableAmbArray
andCompletableAmbIterable
Observable
usesObservableAmb
Flowable
usesFlowableAmb
I propose to adopt the same approach for
Single
,Maybe
andCompletable
, merging xAmbArray and xAmbIterable into one single class, xAmb, just likeObservable
andFlowable
.I think this will increase the test coverage for the internal operators.
Should I create a PR?
The text was updated successfully, but these errors were encountered: