Commit 00c0784a authored by feng@chromium.org's avatar feng@chromium.org

Make one-ascii-character-string a symbol in its cache.

Review URL: http://codereview.chromium.org/7521

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@539 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 711ada81
......@@ -1503,16 +1503,20 @@ Object* Heap::AllocateExternalStringFromTwoByte(
}
Object* Heap:: LookupSingleCharacterStringFromCode(uint16_t code) {
Object* Heap::LookupSingleCharacterStringFromCode(uint16_t code) {
if (code <= String::kMaxAsciiCharCode) {
Object* value = Heap::single_character_string_cache()->get(code);
if (value != Heap::undefined_value()) return value;
Object* result = Heap::AllocateRawAsciiString(1);
char buffer[1];
buffer[0] = static_cast<char>(code);
Object* result = LookupSymbol(Vector<const char>(buffer, 1));
if (result->IsFailure()) return result;
String::cast(result)->Set(0, code);
Heap::single_character_string_cache()->set(code, result);
return result;
}
Object* result = Heap::AllocateRawTwoByteString(1);
if (result->IsFailure()) return result;
String::cast(result)->Set(0, code);
......
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