mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:07:57 +00:00
Macro. Parse merged code only if there are optimization edits.
This saves another 120 ms. Bug: https://github.com/dart-lang/sdk/issues/55784 Change-Id: I4b195f977b7e49cc5b07dcecd4836b3f25399428 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372820 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
1d38fc4bf2
commit
755d4e0531
|
@ -533,18 +533,6 @@ class LibraryBuilder with MacroApplicationsContainer {
|
|||
return;
|
||||
}
|
||||
|
||||
var mergedUnit = performance.run(
|
||||
'mergedUnit',
|
||||
(performance) {
|
||||
performance.getDataInt('length').add(augmentationCode.length);
|
||||
return kind.file.parseCode(
|
||||
code: augmentationCode,
|
||||
errorListener: AnalysisErrorListener.NULL_LISTENER,
|
||||
performance: performance,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
kind.disposeMacroAugmentations(disposeFiles: true);
|
||||
|
||||
// Remove import for partial macro augmentations.
|
||||
|
@ -636,12 +624,26 @@ class LibraryBuilder with MacroApplicationsContainer {
|
|||
unitElement: unitElement,
|
||||
augmentation: augmentation,
|
||||
).perform(updateConstants: () {
|
||||
MacroUpdateConstantsForOptimizedCode(
|
||||
libraryElement: element,
|
||||
unitNode: mergedUnit,
|
||||
codeEdits: optimizedCodeEdits,
|
||||
unitElement: unitElement,
|
||||
).perform();
|
||||
if (optimizedCodeEdits.isNotEmpty) {
|
||||
var mergedUnit = performance.run(
|
||||
'mergedUnit',
|
||||
(performance) {
|
||||
performance.getDataInt('length').add(augmentationCode.length);
|
||||
return kind.file.parseCode(
|
||||
code: augmentationCode,
|
||||
errorListener: AnalysisErrorListener.NULL_LISTENER,
|
||||
performance: performance,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
MacroUpdateConstantsForOptimizedCode(
|
||||
libraryElement: element,
|
||||
unitNode: mergedUnit,
|
||||
codeEdits: optimizedCodeEdits,
|
||||
unitElement: unitElement,
|
||||
).perform();
|
||||
}
|
||||
});
|
||||
|
||||
// Set offsets the same way as when reading from summary.
|
||||
|
|
Loading…
Reference in a new issue