Check for empty substring.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8419 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
sandholm@chromium.org 2011-06-24 13:44:27 +00:00
parent b55a673177
commit 22abf6a579

View File

@ -2634,12 +2634,13 @@ MaybeObject* Heap::AllocateConsString(String* first, String* second) {
MaybeObject* Heap::AllocateSubString(String* buffer, MaybeObject* Heap::AllocateSubString(String* buffer,
int start, int start,
int end, int end,
PretenureFlag pretenure) { PretenureFlag pretenure) {
int length = end - start; int length = end - start;
if (length == 0) {
if (length == 1) { return empty_string();
} else if (length == 1) {
return LookupSingleCharacterStringFromCode(buffer->Get(start)); return LookupSingleCharacterStringFromCode(buffer->Get(start));
} else if (length == 2) { } else if (length == 2) {
// Optimization for 2-byte strings often used as keys in a decompression // Optimization for 2-byte strings often used as keys in a decompression