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

Improve development build performance (remove the Error instances created for autotracking transactions) #1066

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions packages/@glimmer/validator/lib/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { DEBUG } from '@glimmer/env';

interface AutotrackingTransactionSourceData {
context?: string;
error: Error;
}

export let runInAutotrackingTransaction:
Expand All @@ -22,7 +21,7 @@ export let assertTagNotConsumed:
| undefined
| (<T>(tag: Tag, obj?: T, keyName?: keyof T | string | symbol, forceHardError?: boolean) => void);

export let markTagAsConsumed: undefined | ((_tag: Tag, sourceError: Error) => void);
export let markTagAsConsumed: undefined | ((_tag: Tag) => void);

if (DEBUG) {
let DEPRECATE_IN_AUTOTRACKING_TRANSACTION = false;
Expand Down Expand Up @@ -145,25 +144,16 @@ if (DEBUG) {
message.push(`\`${String(keyName)}\` was first used:\n\n${sourceData.context}`);
}

if (sourceData.error.stack) {
let sourceStack = sourceData.error.stack;
let thirdIndex = nthIndex(sourceStack, '\n', 3);
sourceStack = sourceStack.substr(thirdIndex);

message.push(`Stack trace for the first usage: ${sourceStack}`);
}

message.push(`Stack trace for the update:`);

return message.join('\n\n');
};

markTagAsConsumed = (_tag: Tag, sourceError: Error) => {
markTagAsConsumed = (_tag: Tag) => {
if (!AUTOTRACKING_TRANSACTION || AUTOTRACKING_TRANSACTION.has(_tag)) return;

AUTOTRACKING_TRANSACTION.set(_tag, {
context: debuggingContexts!.map(c => c.replace(/^/gm, ' ').replace(/^ /, '-')).join('\n\n'),
error: sourceError,
});

// We need to mark the tag and all of its subtags as consumed, so we need to
Expand All @@ -172,11 +162,11 @@ if (DEBUG) {
let tag = _tag as any;

if (tag.subtag) {
markTagAsConsumed!(tag.subtag, sourceError);
markTagAsConsumed!(tag.subtag);
}

if (tag.subtags) {
tag.subtags.forEach((tag: Tag) => markTagAsConsumed!(tag, sourceError));
tag.subtags.forEach((tag: Tag) => markTagAsConsumed!(tag));
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/@glimmer/validator/lib/tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Tracker {
this.tags.add(tag);

if (DEBUG) {
markTagAsConsumed!(tag, new Error());
markTagAsConsumed!(tag);
}

this.last = tag;
Expand Down