Skip to content

Commit

Permalink
perf(Stream): speed up Stream next, error, complete handlers
Browse files Browse the repository at this point in the history
By avoiding an array copy operation if not needed.
  • Loading branch information
staltz committed Feb 3, 2017
1 parent 04031c6 commit b32ffe3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ export class Stream<T> implements InternalListener<T> {
const a = this._ils;
const L = a.length;
if (this._d) this._dl._n(t);
if (L == 1) a[0]._n(t); else {
if (L == 1) a[0]._n(t); else if (L == 0) return; else {
const b = cp(a);
for (let i = 0; i < L; i++) b[i]._n(t);
}
Expand All @@ -1233,7 +1233,7 @@ export class Stream<T> implements InternalListener<T> {
const L = a.length;
this._x();
if (this._d) this._dl._e(err);
if (L == 1) a[0]._e(err); else {
if (L == 1) a[0]._e(err); else if (L == 0) return; else {
const b = cp(a);
for (let i = 0; i < L; i++) b[i]._e(err);
}
Expand All @@ -1245,7 +1245,7 @@ export class Stream<T> implements InternalListener<T> {
const L = a.length;
this._x();
if (this._d) this._dl._c();
if (L == 1) a[0]._c(); else {
if (L == 1) a[0]._c(); else if (L == 0) return; else {
const b = cp(a);
for (let i = 0; i < L; i++) b[i]._c();
}
Expand Down

0 comments on commit b32ffe3

Please sign in to comment.