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

Commit 2d5c671

Browse files
Fixing map/filter inlining
1 parent 1b76408 commit 2d5c671

26 files changed

Lines changed: 128 additions & 72 deletions

dist/rx.all.compat.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5034,10 +5034,13 @@
50345034
this.selector = bindCallback(selector, thisArg, 3);
50355035
__super__.call(this);
50365036
}
5037+
5038+
function innerMap(selector, self) {
5039+
return function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }
5040+
}
50375041

50385042
MapObservable.prototype.internalMap = function (selector, thisArg) {
5039-
var self = this;
5040-
return new MapObservable(this.source, function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }, thisArg)
5043+
return new MapObservable(this.source, innerMap(selector, this), thisArg);
50415044
};
50425045

50435046
MapObservable.prototype.subscribeCore = function (observer) {
@@ -5058,7 +5061,7 @@
50585061

50595062
MapObserver.prototype.onNext = function(x) {
50605063
if (this.isStopped) { return; }
5061-
var result = tryCatch(this.selector).call(this, x, this.i++, this.source);
5064+
var result = tryCatch(this.selector)(x, this.i++, this.source);
50625065
if (result === errorObj) {
50635066
return this.observer.onError(result.e);
50645067
}
@@ -5418,10 +5421,13 @@
54185421
FilterObservable.prototype.subscribeCore = function (observer) {
54195422
return this.source.subscribe(new FilterObserver(observer, this.predicate, this));
54205423
};
5424+
5425+
function innerPredicate(predicate, self) {
5426+
return function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }
5427+
}
54215428

54225429
FilterObservable.prototype.internalFilter = function(predicate, thisArg) {
5423-
var self = this;
5424-
return new FilterObservable(this.source, function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }, thisArg);
5430+
return new FilterObservable(this.source, innerPredicate(predicate, this), thisArg);
54255431
};
54265432

54275433
return FilterObservable;

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: 2 additions & 3 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: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4889,10 +4889,13 @@
48894889
this.selector = bindCallback(selector, thisArg, 3);
48904890
__super__.call(this);
48914891
}
4892+
4893+
function innerMap(selector, self) {
4894+
return function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }
4895+
}
48924896

48934897
MapObservable.prototype.internalMap = function (selector, thisArg) {
4894-
var self = this;
4895-
return new MapObservable(this.source, function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }, thisArg)
4898+
return new MapObservable(this.source, innerMap(selector, this), thisArg);
48964899
};
48974900

48984901
MapObservable.prototype.subscribeCore = function (observer) {
@@ -4913,7 +4916,7 @@
49134916

49144917
MapObserver.prototype.onNext = function(x) {
49154918
if (this.isStopped) { return; }
4916-
var result = tryCatch(this.selector).call(this, x, this.i++, this.source);
4919+
var result = tryCatch(this.selector)(x, this.i++, this.source);
49174920
if (result === errorObj) {
49184921
return this.observer.onError(result.e);
49194922
}
@@ -5273,10 +5276,13 @@
52735276
FilterObservable.prototype.subscribeCore = function (observer) {
52745277
return this.source.subscribe(new FilterObserver(observer, this.predicate, this));
52755278
};
5279+
5280+
function innerPredicate(predicate, self) {
5281+
return function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }
5282+
}
52765283

52775284
FilterObservable.prototype.internalFilter = function(predicate, thisArg) {
5278-
var self = this;
5279-
return new FilterObservable(this.source, function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }, thisArg);
5285+
return new FilterObservable(this.source, innerPredicate(predicate, this), thisArg);
52805286
};
52815287

52825288
return FilterObservable;

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

dist/rx.compat.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4920,10 +4920,13 @@
49204920
this.selector = bindCallback(selector, thisArg, 3);
49214921
__super__.call(this);
49224922
}
4923+
4924+
function innerMap(selector, self) {
4925+
return function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }
4926+
}
49234927

49244928
MapObservable.prototype.internalMap = function (selector, thisArg) {
4925-
var self = this;
4926-
return new MapObservable(this.source, function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }, thisArg)
4929+
return new MapObservable(this.source, innerMap(selector, this), thisArg);
49274930
};
49284931

49294932
MapObservable.prototype.subscribeCore = function (observer) {
@@ -4944,7 +4947,7 @@
49444947

49454948
MapObserver.prototype.onNext = function(x) {
49464949
if (this.isStopped) { return; }
4947-
var result = tryCatch(this.selector).call(this, x, this.i++, this.source);
4950+
var result = tryCatch(this.selector)(x, this.i++, this.source);
49484951
if (result === errorObj) {
49494952
return this.observer.onError(result.e);
49504953
}
@@ -5304,10 +5307,13 @@
53045307
FilterObservable.prototype.subscribeCore = function (observer) {
53055308
return this.source.subscribe(new FilterObserver(observer, this.predicate, this));
53065309
};
5310+
5311+
function innerPredicate(predicate, self) {
5312+
return function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }
5313+
}
53075314

53085315
FilterObservable.prototype.internalFilter = function(predicate, thisArg) {
5309-
var self = this;
5310-
return new FilterObservable(this.source, function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }, thisArg);
5316+
return new FilterObservable(this.source, innerPredicate(predicate, this), thisArg);
53115317
};
53125318

53135319
return FilterObservable;

dist/rx.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.compat.min.js

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

dist/rx.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4729,10 +4729,13 @@
47294729
this.selector = bindCallback(selector, thisArg, 3);
47304730
__super__.call(this);
47314731
}
4732+
4733+
function innerMap(selector, self) {
4734+
return function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }
4735+
}
47324736

47334737
MapObservable.prototype.internalMap = function (selector, thisArg) {
4734-
var self = this;
4735-
return new MapObservable(this.source, function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }, thisArg)
4738+
return new MapObservable(this.source, innerMap(selector, this), thisArg);
47364739
};
47374740

47384741
MapObservable.prototype.subscribeCore = function (observer) {
@@ -4753,7 +4756,7 @@
47534756

47544757
MapObserver.prototype.onNext = function(x) {
47554758
if (this.isStopped) { return; }
4756-
var result = tryCatch(this.selector).call(this, x, this.i++, this.source);
4759+
var result = tryCatch(this.selector)(x, this.i++, this.source);
47574760
if (result === errorObj) {
47584761
return this.observer.onError(result.e);
47594762
}
@@ -5113,10 +5116,13 @@
51135116
FilterObservable.prototype.subscribeCore = function (observer) {
51145117
return this.source.subscribe(new FilterObserver(observer, this.predicate, this));
51155118
};
5119+
5120+
function innerPredicate(predicate, self) {
5121+
return function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }
5122+
}
51165123

51175124
FilterObservable.prototype.internalFilter = function(predicate, thisArg) {
5118-
var self = this;
5119-
return new FilterObservable(this.source, function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }, thisArg);
5125+
return new FilterObservable(this.source, innerPredicate(predicate, this), thisArg);
51205126
};
51215127

51225128
return FilterObservable;

0 commit comments

Comments
 (0)