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

Unified Diff: src/objects-inl.h

Issue 740673002: Do fewer encoding checks in FlatStringReader used in the JSON stringifier. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix windows build Created 6 years, 1 month 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 | « src/objects.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 62f04b831aeb91b86630e487cdaa4ae64d25b621..e9b325b4cde476c317e29457fbcbc2b2ae9ff8b8 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -473,12 +473,24 @@ STATIC_ASSERT((kExternalStringTag | kTwoByteStringTag) ==
STATIC_ASSERT(v8::String::TWO_BYTE_ENCODING == kTwoByteStringTag);
+
uc32 FlatStringReader::Get(int index) {
- DCHECK(0 <= index && index <= length_);
if (is_one_byte_) {
- return static_cast<const byte*>(start_)[index];
+ return Get<uint8_t>(index);
+ } else {
+ return Get<uc16>(index);
+ }
+}
+
+
+template <typename Char>
+Char FlatStringReader::Get(int index) {
+ DCHECK_EQ(is_one_byte_, sizeof(Char) == 1);
+ DCHECK(0 <= index && index <= length_);
+ if (sizeof(Char) == 1) {
+ return static_cast<Char>(static_cast<const uint8_t*>(start_)[index]);
} else {
- return static_cast<const uc16*>(start_)[index];
+ return static_cast<Char>(static_cast<const uc16*>(start_)[index]);
}
}
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698