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

Unified Diff: pkg/analysis_server/lib/src/services/index/store/codec.dart

Issue 953913003: Optimize IntArrayToIntMap and ElementCodec.encodeHash(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | pkg/analysis_server/lib/src/services/index/store/collection.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/index/store/codec.dart
diff --git a/pkg/analysis_server/lib/src/services/index/store/codec.dart b/pkg/analysis_server/lib/src/services/index/store/codec.dart
index ef36535b54c3d62b686b4262f64975e635fd1bd1..d340abc6592c60857666eb1664cbef3f657f5583 100644
--- a/pkg/analysis_server/lib/src/services/index/store/codec.dart
+++ b/pkg/analysis_server/lib/src/services/index/store/codec.dart
@@ -11,6 +11,7 @@ import 'package:analysis_server/src/services/index/store/collection.dart';
import 'package:analyzer/src/generated/element.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
+import 'package:analyzer/src/generated/utilities_general.dart';
/**
@@ -136,12 +137,19 @@ class ElementCodec {
}
/**
- * Returns an integer that corresponds to an approximated location of [element].
+ * Returns an integer that corresponds to the name of [element].
*/
int encodeHash(Element element) {
- List<int> path = _getLocationPathLimited(element);
- int index = _encodePath(path);
- return index;
+ String elementName = element.displayName;
+ int elementNameId = _stringCodec.encode(elementName);
+ LibraryElement libraryElement = element.library;
+ if (libraryElement != null) {
+ String libraryPath = libraryElement.source.fullName;
+ int libraryPathId = _stringCodec.encode(libraryPath);
+ return JenkinsSmiHash.combine(libraryPathId, elementNameId);
+ } else {
+ return elementNameId;
+ }
}
/**
@@ -243,25 +251,6 @@ class ElementCodec {
}
}
- /**
- * Returns an approximation of the [element]'s location.
- */
- List<int> _getLocationPathLimited(Element element) {
- String firstComponent;
- {
- LibraryElement libraryElement = element.library;
- if (libraryElement != null) {
- firstComponent = libraryElement.source.fullName;
- } else {
- firstComponent = 'null';
- }
- }
- String lastComponent = element.displayName;
- int firstId = _stringCodec.encode(firstComponent);
- int lastId = _stringCodec.encode(lastComponent);
- return <int>[firstId, lastId];
- }
-
static bool _hasLocalOffset(List<String> components) {
for (String component in components) {
if (component.indexOf('@') != -1) {
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/index/store/collection.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698