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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/scanner/keyword.dart

Issue 12328104: Change new List(n) to return fixed length list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head. Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 part of scanner; 5 part of scanner;
6 6
7 /** 7 /**
8 * A keyword in the Dart programming language. 8 * A keyword in the Dart programming language.
9 */ 9 */
10 class Keyword extends Iterable<int> implements SourceString { 10 class Keyword extends Iterable<int> implements SourceString {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 KeywordState(this.keyword); 129 KeywordState(this.keyword);
130 130
131 bool isLeaf(); 131 bool isLeaf();
132 KeywordState next(int c); 132 KeywordState next(int c);
133 final Keyword keyword; 133 final Keyword keyword;
134 134
135 static KeywordState _KEYWORD_STATE; 135 static KeywordState _KEYWORD_STATE;
136 static KeywordState get KEYWORD_STATE { 136 static KeywordState get KEYWORD_STATE {
137 if (_KEYWORD_STATE == null) { 137 if (_KEYWORD_STATE == null) {
138 List<String> strings = 138 List<String> strings =
139 new List<String>.fixedLength(Keyword.values.length); 139 new List<String>(Keyword.values.length);
140 for (int i = 0; i < Keyword.values.length; i++) { 140 for (int i = 0; i < Keyword.values.length; i++) {
141 strings[i] = Keyword.values[i].syntax; 141 strings[i] = Keyword.values[i].syntax;
142 } 142 }
143 strings.sort((a,b) => a.compareTo(b)); 143 strings.sort((a,b) => a.compareTo(b));
144 _KEYWORD_STATE = computeKeywordStateTable(0, strings, 0, strings.length); 144 _KEYWORD_STATE = computeKeywordStateTable(0, strings, 0, strings.length);
145 } 145 }
146 return _KEYWORD_STATE; 146 return _KEYWORD_STATE;
147 } 147 }
148 148
149 static KeywordState computeKeywordStateTable(int start, List<String> strings, 149 static KeywordState computeKeywordStateTable(int start, List<String> strings,
150 int offset, int length) { 150 int offset, int length) {
151 List<KeywordState> result = new List<KeywordState>.fixedLength(26); 151 List<KeywordState> result = new List<KeywordState>(26);
152 assert(length != 0); 152 assert(length != 0);
153 int chunk = 0; 153 int chunk = 0;
154 int chunkStart = -1; 154 int chunkStart = -1;
155 bool isLeaf = false; 155 bool isLeaf = false;
156 for (int i = offset; i < offset + length; i++) { 156 for (int i = offset; i < offset + length; i++) {
157 if (strings[i].length == start) { 157 if (strings[i].length == start) {
158 isLeaf = true; 158 isLeaf = true;
159 } 159 }
160 if (strings[i].length > start) { 160 if (strings[i].length > start) {
161 int c = strings[i].codeUnitAt(start); 161 int c = strings[i].codeUnitAt(start);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 */ 225 */
226 class LeafKeywordState extends KeywordState { 226 class LeafKeywordState extends KeywordState {
227 LeafKeywordState(String syntax) : super(Keyword.keywords[syntax]); 227 LeafKeywordState(String syntax) : super(Keyword.keywords[syntax]);
228 228
229 bool isLeaf() => true; 229 bool isLeaf() => true;
230 230
231 KeywordState next(int c) => null; 231 KeywordState next(int c) => null;
232 232
233 String toString() => keyword.syntax; 233 String toString() => keyword.syntax;
234 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698