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

Commit 5e79b52

Browse files
Adding more perf to zip
1 parent a55be49 commit 5e79b52

35 files changed

Lines changed: 287 additions & 197 deletions

dist/rx.all.compat.js

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4563,22 +4563,22 @@ var ObserveOnObservable = (function (__super__) {
45634563
var ZipObservable = (function(__super__) {
45644564
inherits(ZipObservable, __super__);
45654565
function ZipObservable(sources, resultSelector) {
4566-
var len = sources.length;
45674566
this._s = sources;
45684567
this._cb = resultSelector;
4569-
this._done = arrayInitialize(len, falseFactory);
4570-
this._q = arrayInitialize(len, emptyArrayFactory);
45714568
__super__.call(this);
45724569
}
45734570

45744571
ZipObservable.prototype.subscribeCore = function(observer) {
4575-
var n = this._s.length, subscriptions = new Array(n);
4572+
var n = this._s.length,
4573+
subscriptions = new Array(n);
4574+
done = arrayInitialize(n, falseFactory),
4575+
q = arrayInitialize(n, emptyArrayFactory);
45764576

45774577
for (var i = 0; i < n; i++) {
45784578
var source = this._s[i], sad = new SingleAssignmentDisposable();
4579-
subscriptions[i] = sad;
45804579
isPromise(source) && (source = observableFromPromise(source));
4581-
sad.setDisposable(source.subscribe(new ZipObserver(observer, i, this)));
4580+
sad.setDisposable(source.subscribe(new ZipObserver(observer, i, this, q, done)));
4581+
subscriptions[i] = sad;
45824582
}
45834583

45844584
return new NAryDisposable(subscriptions);
@@ -4589,21 +4589,31 @@ var ObserveOnObservable = (function (__super__) {
45894589

45904590
var ZipObserver = (function (__super__) {
45914591
inherits(ZipObserver, __super__);
4592-
function ZipObserver(o, i, p) {
4592+
function ZipObserver(o, i, p, q, d) {
45934593
this._o = o;
45944594
this._i = i;
45954595
this._p = p;
4596+
this._q = q;
4597+
this._d = d;
45964598
__super__.call(this);
45974599
}
45984600

4601+
function notEmpty(x) { return x.length > 0; }
4602+
function shiftEach(x) { return x.shift(); }
4603+
function notTheSame(i) {
4604+
return function (x, j) {
4605+
return j !== i;
4606+
};
4607+
}
4608+
45994609
ZipObserver.prototype.next = function (x) {
4600-
this._p._q[this._i].push(x);
4601-
if (this._p._q.every(function (x) { return x.length > 0; })) {
4602-
var queuedValues = this._p._q.map(function (x) { return x.shift(); });
4610+
this._q[this._i].push(x);
4611+
if (this._q.every(notEmpty)) {
4612+
var queuedValues = this._q.map(shiftEach);
46034613
var res = tryCatch(this._p._cb).apply(null, queuedValues);
46044614
if (res === errorObj) { return this._o.onError(res.e); }
46054615
this._o.onNext(res);
4606-
} else if (this._p._done.filter(function (x, j) { return j !== this._i; }, this).every(identity)) {
4616+
} else if (this._d.filter(notTheSame(this._i)).every(identity)) {
46074617
this._o.onCompleted();
46084618
}
46094619
};
@@ -4613,8 +4623,8 @@ var ObserveOnObservable = (function (__super__) {
46134623
};
46144624

46154625
ZipObserver.prototype.completed = function () {
4616-
this._p._done[this._i] = true;
4617-
this._p._done.every(identity) && this._o.onCompleted();
4626+
this._d[this._i] = true;
4627+
this._d.every(identity) && this._o.onCompleted();
46184628
};
46194629

46204630
return ZipObserver;
@@ -7362,12 +7372,12 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
73627372
};
73637373

73647374
Observable.wrap = function (fn) {
7365-
createObservable.__generatorFunction__ = fn;
7366-
return createObservable;
7367-
73687375
function createObservable() {
73697376
return Observable.spawn.call(this, fn.apply(this, arguments));
73707377
}
7378+
7379+
createObservable.__generatorFunction__ = fn;
7380+
return createObservable;
73717381
};
73727382

73737383
var spawn = Observable.spawn = function () {
@@ -7383,14 +7393,14 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
73837393
return o.onCompleted();
73847394
}
73857395

7386-
processGenerator();
7387-
73887396
function processGenerator(res) {
73897397
var ret = tryCatch(gen.next).call(gen, res);
73907398
if (ret === errorObj) { return o.onError(ret.e); }
73917399
next(ret);
73927400
}
73937401

7402+
processGenerator();
7403+
73947404
function onError(err) {
73957405
var ret = tryCatch(gen.next).call(gen, err);
73967406
if (ret === errorObj) { return o.onError(ret.e); }
@@ -7696,7 +7706,7 @@ Observable.fromNodeCallback = function (fn, ctx, selector) {
76967706
inherits(EventObservable, __super__);
76977707
function EventObservable(el, name, fn) {
76987708
this._el = el;
7699-
this._name = name;
7709+
this._n = name;
77007710
this._fn = fn;
77017711
__super__.call(this);
77027712
}

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: 5 additions & 5 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: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4241,22 +4241,22 @@ var ObserveOnObservable = (function (__super__) {
42414241
var ZipObservable = (function(__super__) {
42424242
inherits(ZipObservable, __super__);
42434243
function ZipObservable(sources, resultSelector) {
4244-
var len = sources.length;
42454244
this._s = sources;
42464245
this._cb = resultSelector;
4247-
this._done = arrayInitialize(len, falseFactory);
4248-
this._q = arrayInitialize(len, emptyArrayFactory);
42494246
__super__.call(this);
42504247
}
42514248

42524249
ZipObservable.prototype.subscribeCore = function(observer) {
4253-
var n = this._s.length, subscriptions = new Array(n);
4250+
var n = this._s.length,
4251+
subscriptions = new Array(n);
4252+
done = arrayInitialize(n, falseFactory),
4253+
q = arrayInitialize(n, emptyArrayFactory);
42544254

42554255
for (var i = 0; i < n; i++) {
42564256
var source = this._s[i], sad = new SingleAssignmentDisposable();
4257-
subscriptions[i] = sad;
42584257
isPromise(source) && (source = observableFromPromise(source));
4259-
sad.setDisposable(source.subscribe(new ZipObserver(observer, i, this)));
4258+
sad.setDisposable(source.subscribe(new ZipObserver(observer, i, this, q, done)));
4259+
subscriptions[i] = sad;
42604260
}
42614261

42624262
return new NAryDisposable(subscriptions);
@@ -4267,21 +4267,31 @@ var ObserveOnObservable = (function (__super__) {
42674267

42684268
var ZipObserver = (function (__super__) {
42694269
inherits(ZipObserver, __super__);
4270-
function ZipObserver(o, i, p) {
4270+
function ZipObserver(o, i, p, q, d) {
42714271
this._o = o;
42724272
this._i = i;
42734273
this._p = p;
4274+
this._q = q;
4275+
this._d = d;
42744276
__super__.call(this);
42754277
}
42764278

4279+
function notEmpty(x) { return x.length > 0; }
4280+
function shiftEach(x) { return x.shift(); }
4281+
function notTheSame(i) {
4282+
return function (x, j) {
4283+
return j !== i;
4284+
};
4285+
}
4286+
42774287
ZipObserver.prototype.next = function (x) {
4278-
this._p._q[this._i].push(x);
4279-
if (this._p._q.every(function (x) { return x.length > 0; })) {
4280-
var queuedValues = this._p._q.map(function (x) { return x.shift(); });
4288+
this._q[this._i].push(x);
4289+
if (this._q.every(notEmpty)) {
4290+
var queuedValues = this._q.map(shiftEach);
42814291
var res = tryCatch(this._p._cb).apply(null, queuedValues);
42824292
if (res === errorObj) { return this._o.onError(res.e); }
42834293
this._o.onNext(res);
4284-
} else if (this._p._done.filter(function (x, j) { return j !== this._i; }, this).every(identity)) {
4294+
} else if (this._d.filter(notTheSame(this._i)).every(identity)) {
42854295
this._o.onCompleted();
42864296
}
42874297
};
@@ -4291,8 +4301,8 @@ var ObserveOnObservable = (function (__super__) {
42914301
};
42924302

42934303
ZipObserver.prototype.completed = function () {
4294-
this._p._done[this._i] = true;
4295-
this._p._done.every(identity) && this._o.onCompleted();
4304+
this._d[this._i] = true;
4305+
this._d.every(identity) && this._o.onCompleted();
42964306
};
42974307

42984308
return ZipObserver;
@@ -7083,12 +7093,12 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
70837093
};
70847094

70857095
Observable.wrap = function (fn) {
7086-
createObservable.__generatorFunction__ = fn;
7087-
return createObservable;
7088-
70897096
function createObservable() {
70907097
return Observable.spawn.call(this, fn.apply(this, arguments));
70917098
}
7099+
7100+
createObservable.__generatorFunction__ = fn;
7101+
return createObservable;
70927102
};
70937103

70947104
var spawn = Observable.spawn = function () {
@@ -7104,14 +7114,14 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
71047114
return o.onCompleted();
71057115
}
71067116

7107-
processGenerator();
7108-
71097117
function processGenerator(res) {
71107118
var ret = tryCatch(gen.next).call(gen, res);
71117119
if (ret === errorObj) { return o.onError(ret.e); }
71127120
next(ret);
71137121
}
71147122

7123+
processGenerator();
7124+
71157125
function onError(err) {
71167126
var ret = tryCatch(gen.next).call(gen, err);
71177127
if (ret === errorObj) { return o.onError(ret.e); }
@@ -7417,7 +7427,7 @@ Observable.fromNodeCallback = function (fn, ctx, selector) {
74177427
inherits(EventObservable, __super__);
74187428
function EventObservable(el, name, fn) {
74197429
this._el = el;
7420-
this._name = name;
7430+
this._n = name;
74217431
this._fn = fn;
74227432
__super__.call(this);
74237433
}

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: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.async.compat.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@
7373
}
7474

7575
Observable.wrap = function (fn) {
76-
createObservable.__generatorFunction__ = fn;
77-
return createObservable;
78-
7976
function createObservable() {
8077
return Observable.spawn.call(this, fn.apply(this, arguments));
8178
}
79+
80+
createObservable.__generatorFunction__ = fn;
81+
return createObservable;
8282
};
8383

8484
var spawn = Observable.spawn = function () {
@@ -94,14 +94,14 @@
9494
return o.onCompleted();
9595
}
9696

97-
processGenerator();
98-
9997
function processGenerator(res) {
10098
var ret = tryCatch(gen.next).call(gen, res);
10199
if (ret === errorObj) { return o.onError(ret.e); }
102100
next(ret);
103101
}
104102

103+
processGenerator();
104+
105105
function onError(err) {
106106
var ret = tryCatch(gen.next).call(gen, err);
107107
if (ret === errorObj) { return o.onError(ret.e); }
@@ -407,7 +407,7 @@ Observable.fromNodeCallback = function (fn, ctx, selector) {
407407
inherits(EventObservable, __super__);
408408
function EventObservable(el, name, fn) {
409409
this._el = el;
410-
this._name = name;
410+
this._n = name;
411411
this._fn = fn;
412412
__super__.call(this);
413413
}

dist/rx.async.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.

0 commit comments

Comments
 (0)