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

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

Issue 951463005: Small improvements for indexing NameElements. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/services/index/index.dart ('k') | 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 services.src.index.store.codec; 5 library services.src.index.store.codec;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analysis_server/src/services/index/index.dart'; 9 import 'package:analysis_server/src/services/index/index.dart';
10 import 'package:analysis_server/src/services/index/store/collection.dart'; 10 import 'package:analysis_server/src/services/index/store/collection.dart';
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return context.getElement(location); 97 return context.getElement(location);
98 } 98 }
99 99
100 /** 100 /**
101 * Returns a unique integer that corresponds to the given [Element]. 101 * Returns a unique integer that corresponds to the given [Element].
102 * 102 *
103 * If [forKey] is `true` then [element] is a part of a key, so it should use 103 * If [forKey] is `true` then [element] is a part of a key, so it should use
104 * file paths instead of [Element] location URIs. 104 * file paths instead of [Element] location URIs.
105 */ 105 */
106 int encode(Element element, bool forKey) { 106 int encode(Element element, bool forKey) {
107 if (element is NameElement) {
108 String name = element.name;
109 int nameId = _stringCodec.encode(name);
110 return _encodePath(<int>[nameId]);
111 }
112 // check the location has a cached id
107 ElementLocationImpl location = element.location; 113 ElementLocationImpl location = element.location;
108 // check the location has a cached id
109 if (!identical(location.indexOwner, this)) { 114 if (!identical(location.indexOwner, this)) {
110 location.indexKeyId = null; 115 location.indexKeyId = null;
111 location.indexLocationId = null; 116 location.indexLocationId = null;
112 } 117 }
113 if (forKey) { 118 if (forKey) {
114 int id = location.indexKeyId; 119 int id = location.indexKeyId;
115 if (id != null) { 120 if (id != null) {
116 return id; 121 return id;
117 } 122 }
118 } else { 123 } else {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 int encode(String name) { 312 int encode(String name) {
308 int index = nameToIndex[name]; 313 int index = nameToIndex[name];
309 if (index == null) { 314 if (index == null) {
310 index = _indexToName.length; 315 index = _indexToName.length;
311 nameToIndex[name] = index; 316 nameToIndex[name] = index;
312 _indexToName.add(name); 317 _indexToName.add(name);
313 } 318 }
314 return index; 319 return index;
315 } 320 }
316 } 321 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/index/index.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698