From 4e34c0d2474eb5ea8ff0493778b6146b85f38846 Mon Sep 17 00:00:00 2001 From: "scheglov@google.com" Date: Wed, 18 Feb 2015 01:12:43 +0000 Subject: [PATCH] Generate artificial hashCode for often used classes. By avoiding calling Object.hashCode we analyze about 1% faster. R=brianwilkerson@google.com, paulberry@google.com BUG= Review URL: https://codereview.chromium.org//934113002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43832 260f80e4-7a28-3924-810f-c04153c831b5 --- .../lib/src/services/index/index.dart | 13 +++++++++++++ pkg/analyzer/lib/src/generated/engine.dart | 13 +++++++++++++ pkg/analyzer/lib/src/generated/resolver.dart | 13 +++++++++++++ 3 files changed, 39 insertions(+) diff --git a/pkg/analysis_server/lib/src/services/index/index.dart b/pkg/analysis_server/lib/src/services/index/index.dart index e80a190e328..cea7395cd6f 100644 --- a/pkg/analysis_server/lib/src/services/index/index.dart +++ b/pkg/analysis_server/lib/src/services/index/index.dart @@ -319,6 +319,16 @@ class Relationship { */ static Map _RELATIONSHIP_MAP = {}; + /** + * The next artificial hash code. + */ + static int _NEXT_HASH_CODE = 0; + + /** + * The artifitial hash code for this object. + */ + final int _hashCode = _NEXT_HASH_CODE++; + /** * The unique identifier for this relationship. */ @@ -329,6 +339,9 @@ class Relationship { */ Relationship(this.identifier); + @override + int get hashCode => _hashCode; + @override String toString() => identifier; diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart index 32b9f69cbf8..5b43f575c5b 100644 --- a/pkg/analyzer/lib/src/generated/engine.dart +++ b/pkg/analyzer/lib/src/generated/engine.dart @@ -8663,6 +8663,16 @@ class DartEntry extends SourceEntry { * be stored in the cache. */ class DataDescriptor { + /** + * The next artificial hash code. + */ + static int _NEXT_HASH_CODE = 0; + + /** + * The artifitial hash code for this object. + */ + final int _hashCode = _NEXT_HASH_CODE++; + /** * The name of the descriptor, used for debugging purposes. */ @@ -8679,6 +8689,9 @@ class DataDescriptor { */ DataDescriptor(this._name, [this.defaultValue = null]); + @override + int get hashCode => _hashCode; + @override String toString() => _name; } diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart index 209e9fdcbe9..fc2696d417c 100644 --- a/pkg/analyzer/lib/src/generated/resolver.dart +++ b/pkg/analyzer/lib/src/generated/resolver.dart @@ -10077,6 +10077,16 @@ class ResolvableLibrary { */ static List _EMPTY_ARRAY = new List(0); + /** + * The next artificial hash code. + */ + static int _NEXT_HASH_CODE = 0; + + /** + * The artifitial hash code for this object. + */ + final int _hashCode = _NEXT_HASH_CODE++; + /** * The source specifying the defining compilation unit of this library. */ @@ -10197,6 +10207,9 @@ class ResolvableLibrary { */ List get exports => _exportedLibraries; + @override + int get hashCode => _hashCode; + /** * Set the libraries that are imported into this library to be those in the given array. *