Skip to content

Commit

Permalink
perf(zip): extra 1x-2x factor gains from custom tryCatch member function
Browse files Browse the repository at this point in the history
  • Loading branch information
benlesh committed Jan 27, 2016
1 parent c4ce2fb commit a1b0e52
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/operator/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {isArray} from '../util/isArray';
import {Operator} from '../Operator';
import {Observer} from '../Observer';
import {Subscriber} from '../Subscriber';
import {tryCatch} from '../util/tryCatch';
import {errorObject} from '../util/errorObject';
import {OuterSubscriber} from '../OuterSubscriber';
import {subscribeToResult} from '../util/subscribeToResult';
import {SymbolShim} from '../util/SymbolShim';
Expand Down Expand Up @@ -117,14 +115,8 @@ export class ZipSubscriber<T, R> extends Subscriber<T> {
args.push(result.value);
}

const project = this.project;
if (project) {
let result = tryCatch(project).apply(this, args);
if (result === errorObject) {
destination.error(errorObject.e);
} else {
destination.next(result);
}
if (this.project) {
this._tryProject(args);
} else {
destination.next(args);
}
Expand All @@ -133,6 +125,17 @@ export class ZipSubscriber<T, R> extends Subscriber<T> {
destination.complete();
}
}

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

interface LookAheadIterator<T> extends Iterator<T> {
Expand Down

0 comments on commit a1b0e52

Please sign in to comment.