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

Side by Side Diff: sdk/lib/core/string.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) 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 part of dart.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * The String class represents sequences of characters. Strings are 8 * The String class represents sequences of characters. Strings are
9 * immutable. A string is represented by a sequence of Unicode UTF-16 9 * immutable. A string is represented by a sequence of Unicode UTF-16
10 * code units accessible through the [codeUnitAt] or the 10 * code units accessible through the [codeUnitAt] or the
(...skipping 20 matching lines...) Expand all
31 * Allocates a new String for the specified [charCode]. 31 * Allocates a new String for the specified [charCode].
32 * 32 *
33 * The new string contains a single code unit if the [charCode] can be 33 * The new string contains a single code unit if the [charCode] can be
34 * represented by a single UTF-16 code unit. Otherwise the [length] is 2 and 34 * represented by a single UTF-16 code unit. Otherwise the [length] is 2 and
35 * the code units form a surrogate pair. 35 * the code units form a surrogate pair.
36 * 36 *
37 * It is allowed (though generally discouraged) to create a String with only 37 * It is allowed (though generally discouraged) to create a String with only
38 * one half of a surrogate pair. 38 * one half of a surrogate pair.
39 */ 39 */
40 factory String.fromCharCode(int charCode) { 40 factory String.fromCharCode(int charCode) {
41 List<int> charCodes = new List<int>.fixedLength(1, fill: charCode); 41 List<int> charCodes = new List<int>.filled(1, charCode);
42 return new String.fromCharCodes(charCodes); 42 return new String.fromCharCodes(charCodes);
43 } 43 }
44 44
45 /** 45 /**
46 * Gets the character (as [String]) at the given [index]. 46 * Gets the character (as [String]) at the given [index].
47 * 47 *
48 * The returned string represents exactly one UTF-16 code unit which may be 48 * The returned string represents exactly one UTF-16 code unit which may be
49 * half of a surrogate pair. For example the Unicode character for a 49 * half of a surrogate pair. For example the Unicode character for a
50 * musical G-clef ("𝄞") with rune value 0x1D11E consists of a UTF-16 surrogate 50 * musical G-clef ("𝄞") with rune value 0x1D11E consists of a UTF-16 surrogate
51 * pair: `0xD834` and `0xDD1E`. Using the index-operator on this string yields 51 * pair: `0xD834` and `0xDD1E`. Using the index-operator on this string yields
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 _position = position - 1; 450 _position = position - 1;
451 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); 451 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit);
452 return true; 452 return true;
453 } 453 }
454 } 454 }
455 _position = position; 455 _position = position;
456 _currentCodePoint = codeUnit; 456 _currentCodePoint = codeUnit;
457 return true; 457 return true;
458 } 458 }
459 } 459 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698