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

Side by Side Diff: sdk/lib/core/string.dart

Issue 212423003: Optimize String.fromCharCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Shortcut List creation. Created 6 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
« no previous file with comments | « sdk/lib/_internal/lib/js_helper.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) 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 * A sequence of characters. 8 * A sequence of characters.
9 * 9 *
10 * A string can be either single or multiline. Single line strings are 10 * A string can be either single or multiline. Single line strings are
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 external factory String.fromCharCodes(Iterable<int> charCodes); 109 external factory String.fromCharCodes(Iterable<int> charCodes);
110 110
111 /** 111 /**
112 * Allocates a new String for the specified [charCode]. 112 * Allocates a new String for the specified [charCode].
113 * 113 *
114 * If the [charCode] can be represented by a single UTF-16 code unit, the new 114 * If the [charCode] can be represented by a single UTF-16 code unit, the new
115 * string contains a single code unit. Otherwise, the [length] is 2 and 115 * string contains a single code unit. Otherwise, the [length] is 2 and
116 * the code units form a surrogate pair. See documentation for 116 * the code units form a surrogate pair. See documentation for
117 * [fromCharCodes]. 117 * [fromCharCodes].
118 * 118 *
119 * Creating a String with half of a surrogate pair is legal but generally 119 * Creating a String with half of a surrogate pair is allowed.
120 * discouraged.
121 */ 120 */
122 factory String.fromCharCode(int charCode) { 121 external factory String.fromCharCode(int charCode);
123 List<int> charCodes = new List<int>.filled(1, charCode);
124 return new String.fromCharCodes(charCodes);
125 }
126 122
127 /** 123 /**
128 * Returns the string value of the environment declaration [name]. 124 * Returns the string value of the environment declaration [name].
129 * 125 *
130 * Environment declarations are provided by the surrounding system compiling 126 * Environment declarations are provided by the surrounding system compiling
131 * or running the Dart program. Declarations map a string key to a string 127 * or running the Dart program. Declarations map a string key to a string
132 * value. 128 * value.
133 * 129 *
134 * If [name] is not declared in the environment, the result is instead 130 * If [name] is not declared in the environment, the result is instead
135 * [defaultValue]. 131 * [defaultValue].
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 _position = position - 1; 727 _position = position - 1;
732 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); 728 _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit);
733 return true; 729 return true;
734 } 730 }
735 } 731 }
736 _position = position; 732 _position = position;
737 _currentCodePoint = codeUnit; 733 _currentCodePoint = codeUnit;
738 return true; 734 return true;
739 } 735 }
740 } 736 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/lib/js_helper.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698