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

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 1805613002: Make ElementLocationImpl.hashCode SMI, improve performance. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.dart.element.element; 5 library analyzer.src.dart.element.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2243 if (i > 0) { 2243 if (i > 0) {
2244 buffer.writeCharCode(_SEPARATOR_CHAR); 2244 buffer.writeCharCode(_SEPARATOR_CHAR);
2245 } 2245 }
2246 _encode(buffer, _components[i]); 2246 _encode(buffer, _components[i]);
2247 } 2247 }
2248 return buffer.toString(); 2248 return buffer.toString();
2249 } 2249 }
2250 2250
2251 @override 2251 @override
2252 int get hashCode { 2252 int get hashCode {
2253 int result = 1; 2253 int result = 0;
2254 for (int i = 0; i < _components.length; i++) { 2254 for (int i = 0; i < _components.length; i++) {
2255 String component = _components[i]; 2255 String component = _components[i];
2256 result = 31 * result + component.hashCode; 2256 result = JenkinsSmiHash.combine(result, component.hashCode);
2257 } 2257 }
2258 return result; 2258 return result;
2259 } 2259 }
2260 2260
2261 @override 2261 @override
2262 bool operator ==(Object object) { 2262 bool operator ==(Object object) {
2263 if (identical(this, object)) { 2263 if (identical(this, object)) {
2264 return true; 2264 return true;
2265 } 2265 }
2266 if (object is! ElementLocationImpl) { 2266 if (object is! ElementLocationImpl) {
(...skipping 2664 matching lines...) Expand 10 before | Expand all | Expand 10 after
4931 4931
4932 @override 4932 @override
4933 void visitElement(Element element) { 4933 void visitElement(Element element) {
4934 int offset = element.nameOffset; 4934 int offset = element.nameOffset;
4935 if (offset != -1) { 4935 if (offset != -1) {
4936 map[offset] = element; 4936 map[offset] = element;
4937 } 4937 }
4938 super.visitElement(element); 4938 super.visitElement(element);
4939 } 4939 }
4940 } 4940 }
OLDNEW
« 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