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

Unified Diff: pkg/analyzer/lib/src/generated/element.dart

Issue 928613002: Use better hash computer. (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 | « pkg/analyzer/lib/src/generated/constant.dart ('k') | pkg/analyzer/lib/src/generated/java_engine.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/element.dart
diff --git a/pkg/analyzer/lib/src/generated/element.dart b/pkg/analyzer/lib/src/generated/element.dart
index 1879700fa69061607f17c1437647467428f45a74..f160505e2e4923fb26fc6f0d5c511ed953e32a3d 100644
--- a/pkg/analyzer/lib/src/generated/element.dart
+++ b/pkg/analyzer/lib/src/generated/element.dart
@@ -21,6 +21,7 @@ import 'sdk.dart' show DartSdk;
import 'source.dart';
import 'utilities_collection.dart';
import 'utilities_dart.dart';
+import 'package:analyzer/src/generated/utilities_general.dart';
/**
@@ -3279,22 +3280,29 @@ class ElementLocationImpl implements ElementLocation {
*/
class ElementPair {
/**
- * The first [Element]
+ * The first [Element].
*/
final Element _first;
/**
- * The second [Element]
+ * The second [Element].
*/
final Element _second;
/**
+ * A cached copy of the calculated hashCode for this element.
+ */
+ int _cachedHashCode;
+
+ /**
* The sole constructor for this class, taking two [Element]s.
*
* @param first the first element
* @param second the second element
*/
- ElementPair(this._first, this._second);
+ ElementPair(this._first, this._second) {
+ _cachedHashCode = JenkinsSmiHash.hash2(_first.hashCode, _second.hashCode);
+ }
/**
* Return the first element.
@@ -3304,8 +3312,9 @@ class ElementPair {
Element get firstElt => _first;
@override
- int get hashCode =>
- ObjectUtilities.combineHashCodes(_first.hashCode, _second.hashCode);
+ int get hashCode {
+ return _cachedHashCode;
+ }
/**
* Return the second element
@@ -3319,11 +3328,9 @@ class ElementPair {
if (identical(object, this)) {
return true;
}
- if (object is ElementPair) {
- ElementPair elementPair = object;
- return (_first == elementPair._first) && (_second == elementPair._second);
- }
- return false;
+ return object is ElementPair &&
+ _first == object._first &&
+ _second == object._second;
}
}
@@ -9282,8 +9289,7 @@ class PropertyAccessorElementImpl extends ExecutableElementImpl implements
}
@override
- int get hashCode =>
- ObjectUtilities.combineHashCodes(super.hashCode, isGetter ? 1 : 2);
+ int get hashCode => JenkinsSmiHash.hash2(super.hashCode, isGetter ? 1 : 2);
@override
String get identifier {
« no previous file with comments | « pkg/analyzer/lib/src/generated/constant.dart ('k') | pkg/analyzer/lib/src/generated/java_engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698