Force inline Stirng::GetCharVector<>.
authoryangguo <yangguo@chromium.org>
Tue, 25 Nov 2014 15:29:50 +0000 (07:29 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 25 Nov 2014 15:30:03 +0000 (15:30 +0000)
R=mvstanton@chromium.org
BUG=chromium:436447

Review URL: https://codereview.chromium.org/756983003

Cr-Commit-Position: refs/heads/master@{#25504}

src/objects-inl.h
src/objects.cc
src/objects.h
src/runtime/runtime-uri.cc

index 9a65e16..9172257 100644 (file)
@@ -3581,6 +3581,22 @@ ConsString* String::VisitFlat(Visitor* visitor,
 }
 
 
+template <>
+inline Vector<const uint8_t> String::GetCharVector() {
+  String::FlatContent flat = GetFlatContent();
+  DCHECK(flat.IsOneByte());
+  return flat.ToOneByteVector();
+}
+
+
+template <>
+inline Vector<const uc16> String::GetCharVector() {
+  String::FlatContent flat = GetFlatContent();
+  DCHECK(flat.IsTwoByte());
+  return flat.ToUC16Vector();
+}
+
+
 uint16_t SeqOneByteString::SeqOneByteStringGet(int index) {
   DCHECK(index >= 0 && index < length());
   return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
index 82ff09b..5262ed6 100644 (file)
@@ -8298,22 +8298,6 @@ String::FlatContent String::GetFlatContent() {
 }
 
 
-template <>
-Vector<const uint8_t> String::GetCharVector() {
-  String::FlatContent flat = GetFlatContent();
-  DCHECK(flat.IsOneByte());
-  return flat.ToOneByteVector();
-}
-
-
-template <>
-Vector<const uc16> String::GetCharVector() {
-  String::FlatContent flat = GetFlatContent();
-  DCHECK(flat.IsTwoByte());
-  return flat.ToUC16Vector();
-}
-
-
 SmartArrayPointer<char> String::ToCString(AllowNullsFlag allow_nulls,
                                           RobustnessFlag robust_flag,
                                           int offset,
index 502d263..664a506 100644 (file)
@@ -8815,7 +8815,7 @@ class String: public Name {
   };
 
   template <typename Char>
-  Vector<const Char> GetCharVector();
+  INLINE(Vector<const Char> GetCharVector());
 
   // Get and set the length of the string.
   inline int length() const;
index 16e80b5..477071a 100644 (file)
 namespace v8 {
 namespace internal {
 
-template <typename Char>
-static INLINE(Vector<const Char> GetCharVector(Handle<String> string));
-
-
-template <>
-Vector<const uint8_t> GetCharVector(Handle<String> string) {
-  String::FlatContent flat = string->GetFlatContent();
-  DCHECK(flat.IsOneByte());
-  return flat.ToOneByteVector();
-}
-
-
-template <>
-Vector<const uc16> GetCharVector(Handle<String> string) {
-  String::FlatContent flat = string->GetFlatContent();
-  DCHECK(flat.IsTwoByte());
-  return flat.ToUC16Vector();
-}
-
-
 class URIUnescape : public AllStatic {
  public:
   template <typename Char>
@@ -72,7 +52,7 @@ MaybeHandle<String> URIUnescape::Unescape(Isolate* isolate,
   {
     DisallowHeapAllocation no_allocation;
     StringSearch<uint8_t, Char> search(isolate, STATIC_CHAR_VECTOR("%"));
-    index = search.Search(GetCharVector<Char>(source), 0);
+    index = search.Search(source->GetCharVector<Char>(), 0);
     if (index < 0) return source;
   }
   return UnescapeSlow<Char>(isolate, source, index);
@@ -89,7 +69,7 @@ MaybeHandle<String> URIUnescape::UnescapeSlow(Isolate* isolate,
   int unescaped_length = 0;
   {
     DisallowHeapAllocation no_allocation;
-    Vector<const Char> vector = GetCharVector<Char>(string);
+    Vector<const Char> vector = string->GetCharVector<Char>();
     for (int i = start_index; i < length; unescaped_length++) {
       int step;
       if (UnescapeChar(vector, i, length, &step) >
@@ -112,7 +92,7 @@ MaybeHandle<String> URIUnescape::UnescapeSlow(Isolate* isolate,
                                         ->NewRawOneByteString(unescaped_length)
                                         .ToHandleChecked();
     DisallowHeapAllocation no_allocation;
-    Vector<const Char> vector = GetCharVector<Char>(string);
+    Vector<const Char> vector = string->GetCharVector<Char>();
     for (int i = start_index; i < length; dest_position++) {
       int step;
       dest->SeqOneByteStringSet(dest_position,
@@ -125,7 +105,7 @@ MaybeHandle<String> URIUnescape::UnescapeSlow(Isolate* isolate,
                                         ->NewRawTwoByteString(unescaped_length)
                                         .ToHandleChecked();
     DisallowHeapAllocation no_allocation;
-    Vector<const Char> vector = GetCharVector<Char>(string);
+    Vector<const Char> vector = string->GetCharVector<Char>();
     for (int i = start_index; i < length; dest_position++) {
       int step;
       dest->SeqTwoByteStringSet(dest_position,
@@ -221,7 +201,7 @@ MaybeHandle<String> URIEscape::Escape(Isolate* isolate, Handle<String> string) {
 
   {
     DisallowHeapAllocation no_allocation;
-    Vector<const Char> vector = GetCharVector<Char>(string);
+    Vector<const Char> vector = string->GetCharVector<Char>();
     for (int i = 0; i < length; i++) {
       uint16_t c = vector[i];
       if (c >= 256) {
@@ -249,7 +229,7 @@ MaybeHandle<String> URIEscape::Escape(Isolate* isolate, Handle<String> string) {
 
   {
     DisallowHeapAllocation no_allocation;
-    Vector<const Char> vector = GetCharVector<Char>(string);
+    Vector<const Char> vector = string->GetCharVector<Char>();
     for (int i = 0; i < length; i++) {
       uint16_t c = vector[i];
       if (c >= 256) {