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

Unified Diff: runtime/vm/unicode.cc

Issue 10452006: Implement a heap profiler for the Dart managed heap. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: added basic test code Created 8 years, 7 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/unicode.cc
diff --git a/runtime/vm/unicode.cc b/runtime/vm/unicode.cc
index 34fc381560575d21bcb32244be790b8bed4a6dc0..77dc65aae8abf6eb24c0b2339f6f46b9be50f7a5 100644
--- a/runtime/vm/unicode.cc
+++ b/runtime/vm/unicode.cc
@@ -127,24 +127,29 @@ intptr_t Utf8::Length(const String& str) {
}
-void Utf8::Encode(int32_t ch, char* dst) {
+intptr_t Utf8::Encode(int32_t ch, char* dst) {
static const int kMask = ~(1 << 6);
if (ch <= kMaxOneByteChar) {
dst[0] = ch;
- } else if (ch <= kMaxTwoByteChar) {
+ return 1;
+ }
+ if (ch <= kMaxTwoByteChar) {
dst[0] = 0xC0 | (ch >> 6);
dst[1] = 0x80 | (ch & kMask);
- } else if (ch <= kMaxThreeByteChar) {
+ return 2;
+ }
+ if (ch <= kMaxThreeByteChar) {
dst[0] = 0xE0 | (ch >> 12);
dst[1] = 0x80 | ((ch >> 6) & kMask);
dst[2] = 0x80 | (ch & kMask);
- } else {
- ASSERT(ch <= kMaxFourByteChar);
- dst[0] = 0xF0 | (ch >> 18);
- dst[1] = 0x80 | ((ch >> 12) & kMask);
- dst[2] = 0x80 | ((ch >> 6) & kMask);
- dst[3] = 0x80 | (ch & kMask);
+ return 3;
}
+ ASSERT(ch <= kMaxFourByteChar);
+ dst[0] = 0xF0 | (ch >> 18);
+ dst[1] = 0x80 | ((ch >> 12) & kMask);
+ dst[2] = 0x80 | ((ch >> 6) & kMask);
+ dst[3] = 0x80 | (ch & kMask);
+ return 4;
}
« runtime/vm/raw_object.h ('K') | « runtime/vm/unicode.h ('k') | runtime/vm/visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698