Skip to content

Commit a1b0e52

Browse files
committed
perf(zip): extra 1x-2x factor gains from custom tryCatch member function
1 parent c4ce2fb commit a1b0e52

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/operator/zip.ts

+13-10
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import {isArray} from '../util/isArray';
44
import {Operator} from '../Operator';
55
import {Observer} from '../Observer';
66
import {Subscriber} from '../Subscriber';
7-
import {tryCatch} from '../util/tryCatch';
8-
import {errorObject} from '../util/errorObject';
97
import {OuterSubscriber} from '../OuterSubscriber';
108
import {subscribeToResult} from '../util/subscribeToResult';
119
import {SymbolShim} from '../util/SymbolShim';
@@ -117,14 +115,8 @@ export class ZipSubscriber<T, R> extends Subscriber<T> {
117115
args.push(result.value);
118116
}
119117

120-
const project = this.project;
121-
if (project) {
122-
let result = tryCatch(project).apply(this, args);
123-
if (result === errorObject) {
124-
destination.error(errorObject.e);
125-
} else {
126-
destination.next(result);
127-
}
118+
if (this.project) {
119+
this._tryProject(args);
128120
} else {
129121
destination.next(args);
130122
}
@@ -133,6 +125,17 @@ export class ZipSubscriber<T, R> extends Subscriber<T> {
133125
destination.complete();
134126
}
135127
}
128+
129+
protected _tryProject(args: any[]) {
130+
let result: any;
131+
try {
132+
result = this.project.apply(this, args);
133+
} catch (err) {
134+
this.destination.error(err);
135+
return;
136+
}
137+
this.destination.next(result);
138+
}
136139
}
137140

138141
interface LookAheadIterator<T> extends Iterator<T> {

0 commit comments

Comments
 (0)