Commit e9cc1804 authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Make one-character strings into symbols more agressively.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9175 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 81e7f597
......@@ -3623,6 +3623,9 @@ MaybeObject* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor,
MaybeObject* Heap::AllocateStringFromAscii(Vector<const char> string,
PretenureFlag pretenure) {
if (string.length() == 1) {
return Heap::LookupSingleCharacterStringFromCode(string[0]);
}
Object* result;
{ MaybeObject* maybe_result =
AllocateRawAsciiString(string.length(), pretenure);
......
......@@ -37,16 +37,16 @@ TEST(TokenEnumerator) {
TokenEnumerator te;
CHECK_EQ(TokenEnumerator::kNoSecurityToken, te.GetTokenId(NULL));
v8::HandleScope hs;
v8::Local<v8::String> token1(v8::String::New("1"));
v8::Local<v8::String> token1(v8::String::New("1x"));
CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
v8::Local<v8::String> token2(v8::String::New("2"));
v8::Local<v8::String> token2(v8::String::New("2x"));
CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2)));
CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2)));
CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
{
v8::HandleScope hs;
v8::Local<v8::String> token3(v8::String::New("3"));
v8::Local<v8::String> token3(v8::String::New("3x"));
CHECK_EQ(2, te.GetTokenId(*v8::Utils::OpenHandle(*token3)));
CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2)));
CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
......
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