Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(@angular-devkit/core): avoid RxJS performance penalty in sync fs calls #18549

Merged
merged 1 commit into from Aug 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/angular_devkit/core/src/virtual-fs/host/sync.ts
Expand Up @@ -37,11 +37,13 @@ export class SyncDelegateHost<T extends object = {}> {
let completed = false;
let result: ResultT | undefined = undefined;
let errorResult: Error | undefined = undefined;
observable.subscribe({
next(x: ResultT) { result = x; },
error(err: Error) { errorResult = err; },
complete() { completed = true; },
});
// Perf note: this is not using an observer object to avoid a performance penalty in RxJS.
// See https://github.com/ReactiveX/rxjs/pull/5646 for details.
observable.subscribe(
(x: ResultT) => result = x,
(err: Error) => errorResult = err,
() => completed = true,
);

if (errorResult !== undefined) {
throw errorResult;
Expand Down