Commit 39d0b854 authored by yangguo's avatar yangguo Committed by Commit bot

Force inline Stirng::GetCharVector<>.

R=mvstanton@chromium.org
BUG=chromium:436447

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

Cr-Commit-Position: refs/heads/master@{#25504}
parent f1d8668e
...@@ -3581,6 +3581,22 @@ ConsString* String::VisitFlat(Visitor* visitor, ...@@ -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) { uint16_t SeqOneByteString::SeqOneByteStringGet(int index) {
DCHECK(index >= 0 && index < length()); DCHECK(index >= 0 && index < length());
return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
......
...@@ -8298,22 +8298,6 @@ String::FlatContent String::GetFlatContent() { ...@@ -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, SmartArrayPointer<char> String::ToCString(AllowNullsFlag allow_nulls,
RobustnessFlag robust_flag, RobustnessFlag robust_flag,
int offset, int offset,
......
...@@ -8815,7 +8815,7 @@ class String: public Name { ...@@ -8815,7 +8815,7 @@ class String: public Name {
}; };
template <typename Char> template <typename Char>
Vector<const Char> GetCharVector(); INLINE(Vector<const Char> GetCharVector());
// Get and set the length of the string. // Get and set the length of the string.
inline int length() const; inline int length() const;
......
...@@ -14,26 +14,6 @@ ...@@ -14,26 +14,6 @@
namespace v8 { namespace v8 {
namespace internal { 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 { class URIUnescape : public AllStatic {
public: public:
template <typename Char> template <typename Char>
...@@ -72,7 +52,7 @@ MaybeHandle<String> URIUnescape::Unescape(Isolate* isolate, ...@@ -72,7 +52,7 @@ MaybeHandle<String> URIUnescape::Unescape(Isolate* isolate,
{ {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
StringSearch<uint8_t, Char> search(isolate, STATIC_CHAR_VECTOR("%")); 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; if (index < 0) return source;
} }
return UnescapeSlow<Char>(isolate, source, index); return UnescapeSlow<Char>(isolate, source, index);
...@@ -89,7 +69,7 @@ MaybeHandle<String> URIUnescape::UnescapeSlow(Isolate* isolate, ...@@ -89,7 +69,7 @@ MaybeHandle<String> URIUnescape::UnescapeSlow(Isolate* isolate,
int unescaped_length = 0; int unescaped_length = 0;
{ {
DisallowHeapAllocation no_allocation; 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++) { for (int i = start_index; i < length; unescaped_length++) {
int step; int step;
if (UnescapeChar(vector, i, length, &step) > if (UnescapeChar(vector, i, length, &step) >
...@@ -112,7 +92,7 @@ MaybeHandle<String> URIUnescape::UnescapeSlow(Isolate* isolate, ...@@ -112,7 +92,7 @@ MaybeHandle<String> URIUnescape::UnescapeSlow(Isolate* isolate,
->NewRawOneByteString(unescaped_length) ->NewRawOneByteString(unescaped_length)
.ToHandleChecked(); .ToHandleChecked();
DisallowHeapAllocation no_allocation; 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++) { for (int i = start_index; i < length; dest_position++) {
int step; int step;
dest->SeqOneByteStringSet(dest_position, dest->SeqOneByteStringSet(dest_position,
...@@ -125,7 +105,7 @@ MaybeHandle<String> URIUnescape::UnescapeSlow(Isolate* isolate, ...@@ -125,7 +105,7 @@ MaybeHandle<String> URIUnescape::UnescapeSlow(Isolate* isolate,
->NewRawTwoByteString(unescaped_length) ->NewRawTwoByteString(unescaped_length)
.ToHandleChecked(); .ToHandleChecked();
DisallowHeapAllocation no_allocation; 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++) { for (int i = start_index; i < length; dest_position++) {
int step; int step;
dest->SeqTwoByteStringSet(dest_position, dest->SeqTwoByteStringSet(dest_position,
...@@ -221,7 +201,7 @@ MaybeHandle<String> URIEscape::Escape(Isolate* isolate, Handle<String> string) { ...@@ -221,7 +201,7 @@ MaybeHandle<String> URIEscape::Escape(Isolate* isolate, Handle<String> string) {
{ {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
Vector<const Char> vector = GetCharVector<Char>(string); Vector<const Char> vector = string->GetCharVector<Char>();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
uint16_t c = vector[i]; uint16_t c = vector[i];
if (c >= 256) { if (c >= 256) {
...@@ -249,7 +229,7 @@ MaybeHandle<String> URIEscape::Escape(Isolate* isolate, Handle<String> string) { ...@@ -249,7 +229,7 @@ MaybeHandle<String> URIEscape::Escape(Isolate* isolate, Handle<String> string) {
{ {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
Vector<const Char> vector = GetCharVector<Char>(string); Vector<const Char> vector = string->GetCharVector<Char>();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
uint16_t c = vector[i]; uint16_t c = vector[i];
if (c >= 256) { if (c >= 256) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment