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

Unified Diff: runtime/vm/symbols.cc

Issue 11318018: - Represent strings internally in UTF-16 format, this makes it (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
Index: runtime/vm/symbols.cc
===================================================================
--- runtime/vm/symbols.cc (revision 14314)
+++ runtime/vm/symbols.cc (working copy)
@@ -94,23 +94,23 @@
RawString* Symbols::New(const char* str) {
- intptr_t width = 0;
- intptr_t len = Utf8::CodePointCount(str, &width);
+ ASSERT(str != NULL);
+ Utf8::Type type;
+ intptr_t str_len = strlen(str);
+ const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(str);
+ intptr_t len = Utf8::CodePointCount(utf8_array, str_len, &type);
Zone* zone = Isolate::Current()->current_zone();
if (len == 0) {
return Symbols::New(reinterpret_cast<uint8_t*>(NULL), 0);
- } else if (width == 1) {
+ }
+ if (type == Utf8::kAscii) {
uint8_t* characters = zone->Alloc<uint8_t>(len);
- Utf8::Decode(str, characters, len);
+ Utf8::DecodeToAscii(utf8_array, str_len, characters, len);
return New(characters, len);
- } else if (width == 2) {
- uint16_t* characters = zone->Alloc<uint16_t>(len);
- Utf8::Decode(str, characters, len);
- return New(characters, len);
}
- ASSERT(width == 4);
- uint32_t* characters = zone->Alloc<uint32_t>(len);
- Utf8::Decode(str, characters, len);
+ ASSERT((type == Utf8::kBMP) || (type == Utf8::kSMP));
+ uint16_t* characters = zone->Alloc<uint16_t>(len);
+ Utf8::DecodeToUTF16(utf8_array, str_len, characters, len);
return New(characters, len);
}
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/symbols.h ('k') | runtime/vm/unicode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698