Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Commit 5e6bf3f

Browse files
more perf to concat
1 parent 017422f commit 5e6bf3f

27 files changed

Lines changed: 536 additions & 329 deletions

Gruntfile.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ module.exports = function (grunt) {
9999
'src/core/linq/observable/combinelatestproto.js',
100100
'src/core/perf/operators/combinelatest.js',
101101
'src/core/linq/observable/concatproto.js',
102-
'src/core/linq/observable/concat.js',
102+
'src/core/perf/operators/concat.js',
103103
'src/core/linq/observable/concatall.js',
104104
'src/core/perf/operators/mergeproto.js',
105105
'src/core/linq/observable/merge.js',
@@ -392,7 +392,7 @@ module.exports = function (grunt) {
392392
'src/core/linq/observable/combinelatestproto.js',
393393
'src/core/perf/operators/combinelatest.js',
394394
'src/core/linq/observable/concatproto.js',
395-
'src/core/linq/observable/concat.js',
395+
'src/core/perf/operators/concat.js',
396396
'src/core/linq/observable/concatall.js',
397397
'src/core/perf/operators/mergeproto.js',
398398
'src/core/linq/observable/merge.js',
@@ -685,7 +685,7 @@ module.exports = function (grunt) {
685685
'src/core/linq/observable/combinelatestproto.js',
686686
'src/core/perf/operators/combinelatest.js',
687687
'src/core/linq/observable/concatproto.js',
688-
'src/core/linq/observable/concat.js',
688+
'src/core/perf/operators/concat.js',
689689
'src/core/linq/observable/concatall.js',
690690
'src/core/perf/operators/mergeproto.js',
691691
'src/core/linq/observable/merge.js',
@@ -833,7 +833,7 @@ module.exports = function (grunt) {
833833
'src/core/linq/observable/combinelatestproto.js',
834834
'src/core/perf/operators/combinelatest.js',
835835
'src/core/linq/observable/concatproto.js',
836-
'src/core/linq/observable/concat.js',
836+
'src/core/perf/operators/concat.js',
837837
'src/core/linq/observable/concatall.js',
838838
'src/core/perf/operators/mergeproto.js',
839839
'src/core/linq/observable/merge.js',
@@ -965,7 +965,7 @@ module.exports = function (grunt) {
965965
'src/core/linq/observable/combinelatestproto.js',
966966
'src/core/perf/operators/combinelatest.js',
967967
'src/core/linq/observable/concatproto.js',
968-
'src/core/linq/observable/concat.js',
968+
'src/core/perf/operators/concat.js',
969969
'src/core/linq/observable/concatall.js',
970970
'src/core/perf/operators/mergeproto.js',
971971
'src/core/linq/observable/merge.js',
@@ -1134,7 +1134,7 @@ module.exports = function (grunt) {
11341134
'src/core/linq/observable/combinelatestproto.js',
11351135
'src/core/perf/operators/combinelatest.js',
11361136
'src/core/linq/observable/concatproto.js',
1137-
'src/core/linq/observable/concat.js',
1137+
'src/core/perf/operators/concat.js',
11381138
'src/core/linq/observable/concatall.js',
11391139
'src/core/perf/operators/mergeproto.js',
11401140
'src/core/linq/observable/merge.js',

dist/rx.all.compat.js

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,14 +2242,14 @@
22422242

22432243
var Enumerable = Rx.internals.Enumerable = function () { };
22442244

2245-
var ConcatObservable = (function(__super__) {
2246-
inherits(ConcatObservable, __super__);
2247-
function ConcatObservable(sources) {
2245+
var ConcatEnumerableObservable = (function(__super__) {
2246+
inherits(ConcatEnumerableObservable, __super__);
2247+
function ConcatEnumerableObservable(sources) {
22482248
this.sources = sources;
22492249
__super__.call(this);
22502250
}
22512251

2252-
ConcatObservable.prototype.subscribeCore = function (o) {
2252+
ConcatEnumerableObservable.prototype.subscribeCore = function (o) {
22532253
var isDisposed, subscription = new SerialDisposable();
22542254
var cancelable = immediateScheduler.scheduleRecursiveWithState(this.sources[$iterator$](), function (e, self) {
22552255
if (isDisposed) { return; }
@@ -2303,11 +2303,11 @@
23032303
return false;
23042304
};
23052305

2306-
return ConcatObservable;
2306+
return ConcatEnumerableObservable;
23072307
}(ObservableBase));
23082308

23092309
Enumerable.prototype.concat = function () {
2310-
return new ConcatObservable(this);
2310+
return new ConcatEnumerableObservable(this);
23112311
};
23122312

23132313
var CatchErrorObservable = (function(__super__) {
@@ -2346,34 +2346,6 @@
23462346
}));
23472347
};
23482348

2349-
function InnerObserver(o, s) {
2350-
this.o = o;
2351-
this.s = s;
2352-
this.isStopped = false;
2353-
}
2354-
InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.o.onNext(x); } };
2355-
InnerObserver.prototype.onError = function (err) {
2356-
if (!this.isStopped) {
2357-
this.isStopped = true;
2358-
this.s(err);
2359-
}
2360-
};
2361-
InnerObserver.prototype.onCompleted = function () {
2362-
if (!this.isStopped) {
2363-
this.isStopped = true;
2364-
this.onCompleted();
2365-
}
2366-
};
2367-
InnerObserver.prototype.dispose = function () { this.isStopped = true; };
2368-
InnerObserver.prototype.fail = function (err) {
2369-
if (!this.isStopped) {
2370-
this.isStopped = true
2371-
this.o.onError(err);
2372-
return true;
2373-
}
2374-
return false;
2375-
};
2376-
23772349
return CatchErrorObservable;
23782350
}(ObservableBase));
23792351

@@ -3511,6 +3483,52 @@
35113483
return observableConcat.apply(null, args);
35123484
};
35133485

3486+
var ConcatObservable = (function(__super__) {
3487+
inherits(ConcatObservable, __super__);
3488+
function ConcatObservable(sources) {
3489+
this.sources = sources;
3490+
__super__.call(this);
3491+
}
3492+
3493+
ConcatObservable.prototype.subscribeCore = function(o) {
3494+
var sink = new ConcatSink(this.sources, o);
3495+
return sink.run();
3496+
};
3497+
3498+
function ConcatSink(sources, o) {
3499+
this.sources = sources;
3500+
this.o = o;
3501+
}
3502+
ConcatSink.prototype.run = function () {
3503+
var isDisposed, subscription = new SerialDisposable(), sources = this.sources, length = sources.length, o = this.o;
3504+
var cancelable = immediateScheduler.scheduleRecursiveWithState(0, function (i, self) {
3505+
if (isDisposed) { return; }
3506+
if (i === length) {
3507+
return o.onCompleted();
3508+
}
3509+
3510+
// Check if promise
3511+
var currentValue = sources[i];
3512+
isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
3513+
3514+
var d = new SingleAssignmentDisposable();
3515+
subscription.setDisposable(d);
3516+
d.setDisposable(currentValue.subscribe(
3517+
function (x) { o.onNext(x); },
3518+
function (e) { o.onError(e); },
3519+
function () { self(i + 1); }
3520+
));
3521+
});
3522+
3523+
return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
3524+
isDisposed = true;
3525+
}));
3526+
};
3527+
3528+
3529+
return ConcatObservable;
3530+
}(ObservableBase));
3531+
35143532
/**
35153533
* Concatenates all the observable sequences.
35163534
* @param {Array | Arguments} args Arguments or an array to concat to the observable sequence.
@@ -3524,7 +3542,7 @@
35243542
args = new Array(arguments.length);
35253543
for(var i = 0, len = arguments.length; i < len; i++) { args[i] = arguments[i]; }
35263544
}
3527-
return enumerableOf(args).concat();
3545+
return new ConcatObservable(args);
35283546
};
35293547

35303548
/**

dist/rx.all.compat.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.compat.min.js

Lines changed: 4 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.js

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,14 +2051,14 @@
20512051

20522052
var Enumerable = Rx.internals.Enumerable = function () { };
20532053

2054-
var ConcatObservable = (function(__super__) {
2055-
inherits(ConcatObservable, __super__);
2056-
function ConcatObservable(sources) {
2054+
var ConcatEnumerableObservable = (function(__super__) {
2055+
inherits(ConcatEnumerableObservable, __super__);
2056+
function ConcatEnumerableObservable(sources) {
20572057
this.sources = sources;
20582058
__super__.call(this);
20592059
}
20602060

2061-
ConcatObservable.prototype.subscribeCore = function (o) {
2061+
ConcatEnumerableObservable.prototype.subscribeCore = function (o) {
20622062
var isDisposed, subscription = new SerialDisposable();
20632063
var cancelable = immediateScheduler.scheduleRecursiveWithState(this.sources[$iterator$](), function (e, self) {
20642064
if (isDisposed) { return; }
@@ -2112,11 +2112,11 @@
21122112
return false;
21132113
};
21142114

2115-
return ConcatObservable;
2115+
return ConcatEnumerableObservable;
21162116
}(ObservableBase));
21172117

21182118
Enumerable.prototype.concat = function () {
2119-
return new ConcatObservable(this);
2119+
return new ConcatEnumerableObservable(this);
21202120
};
21212121

21222122
var CatchErrorObservable = (function(__super__) {
@@ -2155,34 +2155,6 @@
21552155
}));
21562156
};
21572157

2158-
function InnerObserver(o, s) {
2159-
this.o = o;
2160-
this.s = s;
2161-
this.isStopped = false;
2162-
}
2163-
InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.o.onNext(x); } };
2164-
InnerObserver.prototype.onError = function (err) {
2165-
if (!this.isStopped) {
2166-
this.isStopped = true;
2167-
this.s(err);
2168-
}
2169-
};
2170-
InnerObserver.prototype.onCompleted = function () {
2171-
if (!this.isStopped) {
2172-
this.isStopped = true;
2173-
this.onCompleted();
2174-
}
2175-
};
2176-
InnerObserver.prototype.dispose = function () { this.isStopped = true; };
2177-
InnerObserver.prototype.fail = function (err) {
2178-
if (!this.isStopped) {
2179-
this.isStopped = true
2180-
this.o.onError(err);
2181-
return true;
2182-
}
2183-
return false;
2184-
};
2185-
21862158
return CatchErrorObservable;
21872159
}(ObservableBase));
21882160

@@ -3366,6 +3338,52 @@
33663338
return observableConcat.apply(null, args);
33673339
};
33683340

3341+
var ConcatObservable = (function(__super__) {
3342+
inherits(ConcatObservable, __super__);
3343+
function ConcatObservable(sources) {
3344+
this.sources = sources;
3345+
__super__.call(this);
3346+
}
3347+
3348+
ConcatObservable.prototype.subscribeCore = function(o) {
3349+
var sink = new ConcatSink(this.sources, o);
3350+
return sink.run();
3351+
};
3352+
3353+
function ConcatSink(sources, o) {
3354+
this.sources = sources;
3355+
this.o = o;
3356+
}
3357+
ConcatSink.prototype.run = function () {
3358+
var isDisposed, subscription = new SerialDisposable(), sources = this.sources, length = sources.length, o = this.o;
3359+
var cancelable = immediateScheduler.scheduleRecursiveWithState(0, function (i, self) {
3360+
if (isDisposed) { return; }
3361+
if (i === length) {
3362+
return o.onCompleted();
3363+
}
3364+
3365+
// Check if promise
3366+
var currentValue = sources[i];
3367+
isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
3368+
3369+
var d = new SingleAssignmentDisposable();
3370+
subscription.setDisposable(d);
3371+
d.setDisposable(currentValue.subscribe(
3372+
function (x) { o.onNext(x); },
3373+
function (e) { o.onError(e); },
3374+
function () { self(i + 1); }
3375+
));
3376+
});
3377+
3378+
return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
3379+
isDisposed = true;
3380+
}));
3381+
};
3382+
3383+
3384+
return ConcatObservable;
3385+
}(ObservableBase));
3386+
33693387
/**
33703388
* Concatenates all the observable sequences.
33713389
* @param {Array | Arguments} args Arguments or an array to concat to the observable sequence.
@@ -3379,7 +3397,7 @@
33793397
args = new Array(arguments.length);
33803398
for(var i = 0, len = arguments.length; i < len; i++) { args[i] = arguments[i]; }
33813399
}
3382-
return enumerableOf(args).concat();
3400+
return new ConcatObservable(args);
33833401
};
33843402

33853403
/**

dist/rx.all.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.min.js

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)