Skip to content

Commit

Permalink
perf(combineLatest): remove tryCatch/errorObject, 156k -> 221k ops/sec
Browse files Browse the repository at this point in the history
  • Loading branch information
benlesh committed Jan 27, 2016
1 parent ccba39d commit 1c7d639
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/operator/combineLatest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {Scheduler} from '../Scheduler';
import {isScheduler} from '../util/isScheduler';
import {Operator} from '../Operator';
import {Subscriber} from '../Subscriber';
import {tryCatch} from '../util/tryCatch';
import {errorObject} from '../util/errorObject';
import {OuterSubscriber} from '../OuterSubscriber';
import {subscribeToResult} from '../util/subscribeToResult';

Expand Down Expand Up @@ -131,19 +129,22 @@ export class CombineLatestSubscriber<T, R> extends OuterSubscriber<T, R> {
}

if (toRespond.length === 0) {
const project = this.project;
const destination = this.destination;

if (project) {
const result = tryCatch(project).apply(this, values);
if (result === errorObject) {
destination.error(errorObject.e);
} else {
destination.next(result);
}
if (this.project) {
this._tryProject(values);
} else {
destination.next(values);
this.destination.next(values);
}
}
}

private _tryProject(values: any[]) {
let result: any;
try {
result = this.project.apply(this, values);
} catch (err) {
this.destination.error(err);
return;
}
this.destination.next(result);
}
}

0 comments on commit 1c7d639

Please sign in to comment.