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

Commit a0772f7

Browse files
Updating perf on first/last
1 parent 1e8e6ed commit a0772f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+824
-256
lines changed

dist/rx.aggregates.js

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@
131131
return ExtremaByObserver;
132132
}(AbstractObserver));
133133

134-
function extremaBy(source, keySelector, comparer) {
135-
return new ExtremaByObservable(source, keySelector, comparer);
136-
}
137-
138134
function firstOnly(x) {
139135
if (x.length === 0) { throw new EmptyError(); }
140136
return x[0];
@@ -484,7 +480,7 @@
484480
*/
485481
observableProto.minBy = function (keySelector, comparer) {
486482
comparer || (comparer = defaultSubComparer);
487-
return extremaBy(this, keySelector, function (x, y) { return comparer(x, y) * -1; });
483+
return new ExtremaByObservable(this, keySelector, function (x, y) { return comparer(x, y) * -1; });
488484
};
489485

490486
/**
@@ -510,7 +506,7 @@
510506
*/
511507
observableProto.maxBy = function (keySelector, comparer) {
512508
comparer || (comparer = defaultSubComparer);
513-
return extremaBy(this, keySelector, comparer);
509+
return new ExtremaByObservable(this, keySelector, comparer);
514510
};
515511

516512
/**
@@ -764,6 +760,21 @@
764760
}, source);
765761
};
766762

763+
var FirstObservable = (function (__super__) {
764+
inherits(FirstObservable, __super__);
765+
function FirstObservable(source, obj) {
766+
this.source = source;
767+
this._obj = obj;
768+
__super__.call(this);
769+
}
770+
771+
FirstObservable.prototype.subscribeCore = function (o) {
772+
return this.source.subscribe(new FirstObserver(o, this._obj, this.source));
773+
};
774+
775+
return FirstObservable;
776+
}(ObservableBase));
777+
767778
var FirstObserver = (function(__super__) {
768779
inherits(FirstObserver, __super__);
769780
function FirstObserver(o, obj, s) {
@@ -819,11 +830,24 @@
819830
var fn = obj.predicate;
820831
obj.predicate = bindCallback(fn, obj.thisArg, 3);
821832
}
822-
return new AnonymousObservable(function (o) {
823-
return source.subscribe(new FirstObserver(o, obj, source));
824-
}, source);
833+
return new FirstObservable(this, obj);
825834
};
826835

836+
var LastObservable = (function (__super__) {
837+
inherits(LastObservable, __super__);
838+
function LastObservable(source, obj) {
839+
this.source = source;
840+
this._obj = obj;
841+
__super__.call(this);
842+
}
843+
844+
LastObservable.prototype.subscribeCore = function (o) {
845+
return this.source.subscribe(new LastObserver(o, this._obj, this.source));
846+
};
847+
848+
return LastObservable;
849+
}(ObservableBase));
850+
827851
var LastObserver = (function(__super__) {
828852
inherits(LastObserver, __super__);
829853
function LastObserver(o, obj, s) {
@@ -886,9 +910,7 @@
886910
var fn = obj.predicate;
887911
obj.predicate = bindCallback(fn, obj.thisArg, 3);
888912
}
889-
return new AnonymousObservable(function (o) {
890-
return source.subscribe(new LastObserver(o, obj, source));
891-
}, source);
913+
return new LastObservable(this, obj);
892914
};
893915

894916
var FindValueObserver = (function(__super__) {

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

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.js

Lines changed: 94 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4507,15 +4507,41 @@ observableProto.zipIterable = function () {
45074507
.filter(notEmpty);
45084508
};
45094509

4510+
var DematerializeObservable = (function (__super__) {
4511+
inherits(DematerializeObservable, __super__);
4512+
function DematerializeObservable(source, fn) {
4513+
this.source = source;
4514+
__super__.call(this);
4515+
}
4516+
4517+
DematerializeObservable.prototype.subscribeCore = function (o) {
4518+
return this.source.subscribe(new DematerializeObserver(o));
4519+
};
4520+
4521+
return DematerializeObservable;
4522+
}(ObservableBase));
4523+
4524+
var DematerializeObserver = (function (__super__) {
4525+
inherits(DematerializeObserver, __super__);
4526+
4527+
function DematerializeObserver(o) {
4528+
this._o = o;
4529+
__super__.call(this);
4530+
}
4531+
4532+
DematerializeObserver.prototype.next = function (x) { x.accept(this._o); };
4533+
DematerializeObserver.prototype.error = function (e) { this._o.onError(e); };
4534+
DematerializeObserver.prototype.completed = function () { this._o.onCompleted(); };
4535+
4536+
return DematerializeObserver;
4537+
}(AbstractObserver));
4538+
45104539
/**
45114540
* Dematerializes the explicit notification values of an observable sequence as implicit notifications.
45124541
* @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.
45134542
*/
45144543
observableProto.dematerialize = function () {
4515-
var source = this;
4516-
return new AnonymousObservable(function (o) {
4517-
return source.subscribe(function (x) { return x.accept(o); }, function(e) { o.onError(e); }, function () { o.onCompleted(); });
4518-
}, this);
4544+
return new DematerializeObservable(this);
45194545
};
45204546

45214547
var DistinctUntilChangedObservable = (function(__super__) {
@@ -4741,23 +4767,41 @@ observableProto.zipIterable = function () {
47414767
return new IgnoreElementsObservable(this);
47424768
};
47434769

4770+
var MaterializeObservable = (function (__super__) {
4771+
inherits(MaterializeObservable, __super__);
4772+
function MaterializeObservable(source, fn) {
4773+
this.source = source;
4774+
__super__.call(this);
4775+
}
4776+
4777+
MaterializeObservable.prototype.subscribeCore = function (o) {
4778+
return this.source.subscribe(new MaterializeObserver(o));
4779+
};
4780+
4781+
return MaterializeObservable;
4782+
}(ObservableBase));
4783+
4784+
var MaterializeObserver = (function (__super__) {
4785+
inherits(MaterializeObserver, __super__);
4786+
4787+
function MaterializeObserver(o) {
4788+
this._o = o;
4789+
__super__.call(this);
4790+
}
4791+
4792+
MaterializeObserver.prototype.next = function (x) { this._o.onNext(notificationCreateOnNext(x)) };
4793+
MaterializeObserver.prototype.error = function (e) { this._o.onNext(notificationCreateOnError(e)); this._o.onCompleted(); };
4794+
MaterializeObserver.prototype.completed = function () { this._o.onNext(notificationCreateOnCompleted()); this._o.onCompleted(); };
4795+
4796+
return MaterializeObserver;
4797+
}(AbstractObserver));
4798+
47444799
/**
47454800
* Materializes the implicit notifications of an observable sequence as explicit notification values.
47464801
* @returns {Observable} An observable sequence containing the materialized notification values from the source sequence.
47474802
*/
47484803
observableProto.materialize = function () {
4749-
var source = this;
4750-
return new AnonymousObservable(function (observer) {
4751-
return source.subscribe(function (value) {
4752-
observer.onNext(notificationCreateOnNext(value));
4753-
}, function (e) {
4754-
observer.onNext(notificationCreateOnError(e));
4755-
observer.onCompleted();
4756-
}, function () {
4757-
observer.onNext(notificationCreateOnCompleted());
4758-
observer.onCompleted();
4759-
});
4760-
}, source);
4804+
return new MaterializeObservable(this);
47614805
};
47624806

47634807
/**
@@ -5783,10 +5827,6 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
57835827
return ExtremaByObserver;
57845828
}(AbstractObserver));
57855829

5786-
function extremaBy(source, keySelector, comparer) {
5787-
return new ExtremaByObservable(source, keySelector, comparer);
5788-
}
5789-
57905830
function firstOnly(x) {
57915831
if (x.length === 0) { throw new EmptyError(); }
57925832
return x[0];
@@ -6136,7 +6176,7 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
61366176
*/
61376177
observableProto.minBy = function (keySelector, comparer) {
61386178
comparer || (comparer = defaultSubComparer);
6139-
return extremaBy(this, keySelector, function (x, y) { return comparer(x, y) * -1; });
6179+
return new ExtremaByObservable(this, keySelector, function (x, y) { return comparer(x, y) * -1; });
61406180
};
61416181

61426182
/**
@@ -6162,7 +6202,7 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
61626202
*/
61636203
observableProto.maxBy = function (keySelector, comparer) {
61646204
comparer || (comparer = defaultSubComparer);
6165-
return extremaBy(this, keySelector, comparer);
6205+
return new ExtremaByObservable(this, keySelector, comparer);
61666206
};
61676207

61686208
/**
@@ -6416,6 +6456,21 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
64166456
}, source);
64176457
};
64186458

6459+
var FirstObservable = (function (__super__) {
6460+
inherits(FirstObservable, __super__);
6461+
function FirstObservable(source, obj) {
6462+
this.source = source;
6463+
this._obj = obj;
6464+
__super__.call(this);
6465+
}
6466+
6467+
FirstObservable.prototype.subscribeCore = function (o) {
6468+
return this.source.subscribe(new FirstObserver(o, this._obj, this.source));
6469+
};
6470+
6471+
return FirstObservable;
6472+
}(ObservableBase));
6473+
64196474
var FirstObserver = (function(__super__) {
64206475
inherits(FirstObserver, __super__);
64216476
function FirstObserver(o, obj, s) {
@@ -6471,11 +6526,24 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
64716526
var fn = obj.predicate;
64726527
obj.predicate = bindCallback(fn, obj.thisArg, 3);
64736528
}
6474-
return new AnonymousObservable(function (o) {
6475-
return source.subscribe(new FirstObserver(o, obj, source));
6476-
}, source);
6529+
return new FirstObservable(this, obj);
64776530
};
64786531

6532+
var LastObservable = (function (__super__) {
6533+
inherits(LastObservable, __super__);
6534+
function LastObservable(source, obj) {
6535+
this.source = source;
6536+
this._obj = obj;
6537+
__super__.call(this);
6538+
}
6539+
6540+
LastObservable.prototype.subscribeCore = function (o) {
6541+
return this.source.subscribe(new LastObserver(o, this._obj, this.source));
6542+
};
6543+
6544+
return LastObservable;
6545+
}(ObservableBase));
6546+
64796547
var LastObserver = (function(__super__) {
64806548
inherits(LastObserver, __super__);
64816549
function LastObserver(o, obj, s) {
@@ -6538,9 +6606,7 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
65386606
var fn = obj.predicate;
65396607
obj.predicate = bindCallback(fn, obj.thisArg, 3);
65406608
}
6541-
return new AnonymousObservable(function (o) {
6542-
return source.subscribe(new LastObserver(o, obj, source));
6543-
}, source);
6609+
return new LastObservable(this, obj);
65446610
};
65456611

65466612
var FindValueObserver = (function(__super__) {

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

0 commit comments

Comments
 (0)