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

Unified Diff: runtime/vm/object.h

Issue 2952193002: VM: Speed up output of UTF8 for 1-byte strings.
Patch Set: Add test that would have caught bug pointed out by Slava Created 3 years, 3 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 | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 343bc0bd4dc79bbfcf6b17c648543744852507d1..3c179214d5759a3f50f133b2745b98a553db905c 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -7166,6 +7166,11 @@ class OneByteString : public AllStatic {
return &str.UnsafeMutableNonPointer(raw_ptr(str)->data())[index];
}
+ static uint8_t* DataStart(const String& str) {
+ ASSERT(str.IsOneByteString());
+ return &str.UnsafeMutableNonPointer(raw_ptr(str)->data())[0];
+ }
+
static RawOneByteString* ReadFrom(SnapshotReader* reader,
intptr_t object_id,
intptr_t tags,
@@ -7178,6 +7183,7 @@ class OneByteString : public AllStatic {
friend class ExternalOneByteString;
friend class SnapshotReader;
friend class StringHasher;
+ friend class Utf8;
};
class TwoByteString : public AllStatic {
@@ -7283,6 +7289,11 @@ class TwoByteString : public AllStatic {
return &str.UnsafeMutableNonPointer(raw_ptr(str)->data())[index];
}
+ static uint16_t* DataStart(const String& str) {
+ ASSERT(str.IsTwoByteString());
+ return &str.UnsafeMutableNonPointer(raw_ptr(str)->data())[0];
+ }
+
static RawTwoByteString* ReadFrom(SnapshotReader* reader,
intptr_t object_id,
intptr_t tags,
@@ -7349,6 +7360,11 @@ class ExternalOneByteString : public AllStatic {
return &(raw_ptr(str)->external_data_->data()[index]);
}
+ static const uint8_t* DataStart(const String& str) {
+ ASSERT(str.IsExternalOneByteString());
+ return &(raw_ptr(str)->external_data_->data()[0]);
+ }
+
static void SetExternalData(const String& str,
ExternalStringData<uint8_t>* data) {
ASSERT(str.IsExternalOneByteString());
@@ -7376,6 +7392,7 @@ class ExternalOneByteString : public AllStatic {
friend class String;
friend class SnapshotReader;
friend class Symbols;
+ friend class Utf8;
};
class ExternalTwoByteString : public AllStatic {
@@ -7428,6 +7445,11 @@ class ExternalTwoByteString : public AllStatic {
return &(raw_ptr(str)->external_data_->data()[index]);
}
+ static const uint16_t* DataStart(const String& str) {
+ ASSERT(str.IsExternalTwoByteString());
+ return &(raw_ptr(str)->external_data_->data()[0]);
+ }
+
static void SetExternalData(const String& str,
ExternalStringData<uint16_t>* data) {
ASSERT(str.IsExternalTwoByteString());
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698