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

Side by Side Diff: pkg/i18n/lib/date_format_helpers.dart

Issue 10836319: Improve i18n date/time test performance (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | « no previous file | pkg/i18n/test/date_time_format_test.dart » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 5 /**
6 * A class for holding onto the data for a date so that it can be built 6 * A class for holding onto the data for a date so that it can be built
7 * up incrementally. 7 * up incrementally.
8 */ 8 */
9 class _DateBuilder { 9 class _DateBuilder {
10 int year = 0, 10 int year = 0,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 while (!atEnd()) { 118 while (!atEnd()) {
119 if (f(next())) results.add(index - 1); 119 if (f(next())) results.add(index - 1);
120 } 120 }
121 return results; 121 return results;
122 } 122 }
123 123
124 /** 124 /**
125 * Assuming that the contents are characters, read as many digits as we 125 * Assuming that the contents are characters, read as many digits as we
126 * can see and then return the corresponding integer. Advance the stream. 126 * can see and then return the corresponding integer. Advance the stream.
127 */ 127 */
128 var digitMatcher = const RegExp(@'\d');
128 int nextInteger() { 129 int nextInteger() {
129 var validDigits = '0123456789'; 130 // Doing this with a regular expression is slightly slower on the VM,
131 // but makes a moderate difference in Javascript right now.
Emily Fortuna 2012/08/18 00:46:30 perhaps we could do something a little fancier lik
130 var digits = []; 132 var digits = [];
131 while (!atEnd() && (validDigits.contains(peek()))) { 133 while (!atEnd() && (digitMatcher.hasMatch(peek()))) {
132 digits.add(next().charCodeAt(0)); 134 digits.add(next().charCodeAt(0));
133 } 135 }
134 return Math.parseInt(new String.fromCharCodes(digits)); 136 return Math.parseInt(new String.fromCharCodes(digits));
135 } 137 }
136 } 138 }
OLDNEW
« no previous file with comments | « no previous file | pkg/i18n/test/date_time_format_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698