Revision: 3528 Author: [email protected] Date: Mon Dec 28 05:01:03 2009 Log: Faster handling of string indexing using [] with a SMI index.
Instead of falling back to calling GetObjectProperty we call GetCharAt directly if the object is a string and the key in a SMI. Review URL: http://codereview.chromium.org/522015 http://code.google.com/p/v8/source/detail?r=3528 Modified: /branches/bleeding_edge/src/runtime.cc ======================================= --- /branches/bleeding_edge/src/runtime.cc Wed Dec 16 07:43:20 2009 +++ /branches/bleeding_edge/src/runtime.cc Mon Dec 28 05:01:03 2009 @@ -2722,7 +2722,6 @@ return Runtime::GetObjectProperty(object, key); } - // KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric. @@ -2776,6 +2775,13 @@ // If value is the hole do the general lookup. } } + } else if (args[0]->IsString() && args[1]->IsSmi()) { + // Fast case for string indexing using [] with a smi index. + HandleScope scope; + Handle<String> str = args.at<String>(0); + int index = Smi::cast(args[1])->value(); + Handle<Object> result = GetCharAt(str, index); + return *result; } // Fall back to GetObjectProperty. -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
