Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Unified Diff: pkg/analyzer/lib/src/summary/summarize_elements.dart

Issue 1710093002: Avoid duplicate effort in _getElementReferenceId (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/summarize_elements.dart
diff --git a/pkg/analyzer/lib/src/summary/summarize_elements.dart b/pkg/analyzer/lib/src/summary/summarize_elements.dart
index 944d0534c73c194a1ce73eba97d9d0f669f8eabc..2580e38c7255379dff7c29eaaf5ceea0054686d0 100644
--- a/pkg/analyzer/lib/src/summary/summarize_elements.dart
+++ b/pkg/analyzer/lib/src/summary/summarize_elements.dart
@@ -991,23 +991,16 @@ class _CompilationUnitSerializer {
int _getElementReferenceId(Element element, {bool linked: false}) {
return referenceMap.putIfAbsent(element, () {
- LibraryElement dependentLibrary;
+ LibraryElement dependentLibrary = librarySerializer.libraryElement;
+ int unit = 0;
if (element != null) {
Element enclosingElement = element.enclosingElement;
if (enclosingElement is CompilationUnitElement) {
dependentLibrary = enclosingElement.library;
+ unit = dependentLibrary.units.indexOf(enclosingElement);
+ assert(unit != -1);
}
}
- int unit;
- if (dependentLibrary == null) {
- unit = 0;
- dependentLibrary = librarySerializer.libraryElement;
- } else {
- CompilationUnitElement unitElement =
- element.getAncestor((Element e) => e is CompilationUnitElement);
- unit = dependentLibrary.units.indexOf(unitElement);
- assert(unit != -1);
- }
ReferenceKind kind = _getReferenceKind(element);
String name = element == null ? 'void' : element.name;
int index;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698