Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: src/heap.cc

Issue 466001: Fix adding short external ascii strings... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/test-strings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 // If the resulting string is small make a flat string. 1812 // If the resulting string is small make a flat string.
1813 if (length < String::kMinNonFlatLength) { 1813 if (length < String::kMinNonFlatLength) {
1814 ASSERT(first->IsFlat()); 1814 ASSERT(first->IsFlat());
1815 ASSERT(second->IsFlat()); 1815 ASSERT(second->IsFlat());
1816 if (is_ascii) { 1816 if (is_ascii) {
1817 Object* result = AllocateRawAsciiString(length); 1817 Object* result = AllocateRawAsciiString(length);
1818 if (result->IsFailure()) return result; 1818 if (result->IsFailure()) return result;
1819 // Copy the characters into the new object. 1819 // Copy the characters into the new object.
1820 char* dest = SeqAsciiString::cast(result)->GetChars(); 1820 char* dest = SeqAsciiString::cast(result)->GetChars();
1821 // Copy first part. 1821 // Copy first part.
1822 char* src = SeqAsciiString::cast(first)->GetChars(); 1822 const char* src;
1823 if (first->IsExternalString()) {
1824 src = ExternalAsciiString::cast(first)->resource()->data();
1825 } else {
1826 src = SeqAsciiString::cast(first)->GetChars();
1827 }
1823 for (int i = 0; i < first_length; i++) *dest++ = src[i]; 1828 for (int i = 0; i < first_length; i++) *dest++ = src[i];
1824 // Copy second part. 1829 // Copy second part.
1825 src = SeqAsciiString::cast(second)->GetChars(); 1830 if (second->IsExternalString()) {
1831 src = ExternalAsciiString::cast(second)->resource()->data();
1832 } else {
1833 src = SeqAsciiString::cast(second)->GetChars();
1834 }
1826 for (int i = 0; i < second_length; i++) *dest++ = src[i]; 1835 for (int i = 0; i < second_length; i++) *dest++ = src[i];
1827 return result; 1836 return result;
1828 } else { 1837 } else {
1829 Object* result = AllocateRawTwoByteString(length); 1838 Object* result = AllocateRawTwoByteString(length);
1830 if (result->IsFailure()) return result; 1839 if (result->IsFailure()) return result;
1831 // Copy the characters into the new object. 1840 // Copy the characters into the new object.
1832 uc16* dest = SeqTwoByteString::cast(result)->GetChars(); 1841 uc16* dest = SeqTwoByteString::cast(result)->GetChars();
1833 String::WriteToFlat(first, dest, 0, first_length); 1842 String::WriteToFlat(first, dest, 0, first_length);
1834 String::WriteToFlat(second, dest + first_length, 0, second_length); 1843 String::WriteToFlat(second, dest + first_length, 0, second_length);
1835 return result; 1844 return result;
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3956 for (int i = 0; i < kNumberOfCaches; i++) { 3965 for (int i = 0; i < kNumberOfCaches; i++) {
3957 if (caches_[i] != NULL) { 3966 if (caches_[i] != NULL) {
3958 delete caches_[i]; 3967 delete caches_[i];
3959 caches_[i] = NULL; 3968 caches_[i] = NULL;
3960 } 3969 }
3961 } 3970 }
3962 } 3971 }
3963 3972
3964 3973
3965 } } // namespace v8::internal 3974 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698