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

Unified Diff: runtime/lib/string.dart

Issue 8333001: Implement case mapping using the Unicode default case mapping algorithm. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Renamed result string variables. Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/string.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/string.dart
diff --git a/runtime/lib/string.dart b/runtime/lib/string.dart
index 9f1c3fbce6def6ed0773eb4f5c90842d59c26827..b5c1e38df6c85b9b685017457e94b28659966ec5 100644
--- a/runtime/lib/string.dart
+++ b/runtime/lib/string.dart
@@ -334,42 +334,9 @@ class StringBase {
return result;
}
- String toLowerCase() {
- final int aCode = "A".charCodeAt(0);
- final int zCode = "Z".charCodeAt(0);
- final int delta = aCode - "a".charCodeAt(0);
- return _convert(this, aCode, zCode, delta);
- }
-
- String toUpperCase() {
- final int aCode = "a".charCodeAt(0);
- final int zCode = "z".charCodeAt(0);
- final int delta = aCode - "A".charCodeAt(0);
- return _convert(this, aCode, zCode, delta);
- }
-
- static String _convert(String str, int startCode, int endCode, int delta) {
- final int len = str.length;
- int i = 0;
- // Check if we can just return the string.
- for (; i < len; i++) {
- int code = str.charCodeAt(i);
- if ((startCode <= code) && (code <= endCode)) break;
- }
- if (i == len) return str;
-
- Array<int> charCodes = new Array<int>(len);
- for (i = 0; i < len; i++) {
- int code = str.charCodeAt(i);
- if ((startCode <= code) && (code <= endCode)) {
- code = code - delta;
- }
- charCodes[i] = code;
- }
- return StringBase.createFromCharCodes(charCodes);
- }
-
+ String toUpperCase() native "String_toUpperCase";
+ String toLowerCase() native "String_toLowerCase";
// Implementations of Strings methods follow below.
static String join(Array<String> strings, String separator) {
« no previous file with comments | « runtime/lib/string.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698