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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/element/ElementImpl.java

Issue 207853002: Optimizations for hashCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/type/TypeImpl.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/element/ElementImpl.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/element/ElementImpl.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/element/ElementImpl.java
index 5910023d67b2978ae2c15de57b7e06d826639ae4..8113ee98ebb287e0ac99495f757f851fe457912f 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/element/ElementImpl.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/element/ElementImpl.java
@@ -198,7 +198,13 @@ public abstract class ElementImpl implements Element {
// TODO: We might want to re-visit this optimization in the future.
// We cache the hash code value as this is a very frequently called method.
if (cachedHashCode == 0) {
- cachedHashCode = getLocation().hashCode();
+ int hashIdentifier = getIdentifier().hashCode();
Brian Wilkerson 2014/03/21 14:04:14 ElementLocation goes to extra work to not include
scheglov 2014/03/21 16:41:10 1. Most ElementImpl use new implementation. 2. Lib
+ Element enclosing = getEnclosingElement();
+ if (enclosing != null) {
+ cachedHashCode = hashIdentifier + enclosing.hashCode();
Brian Wilkerson 2014/03/21 14:04:14 ElementLocation used a more complex calculation fo
scheglov 2014/03/21 16:41:10 Done.
scheglov 2014/03/21 16:55:05 Actually I spoke too fast. It costs about 100 ms o
+ } else {
+ cachedHashCode = hashIdentifier;
+ }
}
return cachedHashCode;
}
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/type/TypeImpl.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698