Chromium Code Reviews| Index: src/heap.cc |
| diff --git a/src/heap.cc b/src/heap.cc |
| index dac28f34b22636ca359851615926a9e111bf258d..6dd83d422587ace5824f45db0fb96eab0e44909d 100644 |
| --- a/src/heap.cc |
| +++ b/src/heap.cc |
| @@ -4534,6 +4534,28 @@ MaybeObject* Heap::AllocateStringFromOneByte(Vector<const char> string, |
| } |
| +MaybeObject* Heap::AllocateStringFromAsciiSafe(Vector<const char> string, |
| + PretenureFlag pretenure) { |
| + if (string.length() == 1) { |
| + return Heap::LookupSingleCharacterStringFromCode(string |
| + [0] & String::kMaxAsciiCharCodeU); |
| + } |
| + Object* result; |
| + { MaybeObject* maybe_result = |
| + AllocateRawAsciiString(string.length(), pretenure); |
| + if (!maybe_result->ToObject(&result)) return maybe_result; |
| + } |
| + |
| + // Copy the characters into the new object. |
| + SeqAsciiString* string_result = SeqAsciiString::cast(result); |
| + for (int i = 0; i < string.length(); i++) { |
| + string_result->SeqAsciiStringSet(i, |
|
bnoordhuis1
2012/12/07 04:54:47
AllocateRawAsciiString and SeqAsciiString don't ex
|
| + string[i] & String::kMaxAsciiCharCodeU); |
| + } |
| + return result; |
| +} |
| + |
| + |
| MaybeObject* Heap::AllocateStringFromUtf8Slow(Vector<const char> string, |
| int non_ascii_start, |
| PretenureFlag pretenure) { |