| OLD | NEW |
| 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 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2073 } else if (length == 2) { | 2073 } else if (length == 2) { |
| 2074 // Optimization for 2-byte strings often used as keys in a decompression | 2074 // Optimization for 2-byte strings often used as keys in a decompression |
| 2075 // dictionary. Check whether we already have the string in the symbol | 2075 // dictionary. Check whether we already have the string in the symbol |
| 2076 // table to prevent creation of many unneccesary strings. | 2076 // table to prevent creation of many unneccesary strings. |
| 2077 unsigned c1 = buffer->Get(start); | 2077 unsigned c1 = buffer->Get(start); |
| 2078 unsigned c2 = buffer->Get(start + 1); | 2078 unsigned c2 = buffer->Get(start + 1); |
| 2079 return MakeOrFindTwoCharacterString(c1, c2); | 2079 return MakeOrFindTwoCharacterString(c1, c2); |
| 2080 } | 2080 } |
| 2081 | 2081 |
| 2082 // Make an attempt to flatten the buffer to reduce access time. | 2082 // Make an attempt to flatten the buffer to reduce access time. |
| 2083 buffer->TryFlatten(); | 2083 buffer = buffer->TryFlattenGetString(); |
| 2084 | 2084 |
| 2085 Object* result = buffer->IsAsciiRepresentation() | 2085 Object* result = buffer->IsAsciiRepresentation() |
| 2086 ? AllocateRawAsciiString(length, pretenure ) | 2086 ? AllocateRawAsciiString(length, pretenure ) |
| 2087 : AllocateRawTwoByteString(length, pretenure); | 2087 : AllocateRawTwoByteString(length, pretenure); |
| 2088 if (result->IsFailure()) return result; | 2088 if (result->IsFailure()) return result; |
| 2089 String* string_result = String::cast(result); | 2089 String* string_result = String::cast(result); |
| 2090 // Copy the characters into the new object. | 2090 // Copy the characters into the new object. |
| 2091 if (buffer->IsAsciiRepresentation()) { | 2091 if (buffer->IsAsciiRepresentation()) { |
| 2092 ASSERT(string_result->IsAsciiRepresentation()); | 2092 ASSERT(string_result->IsAsciiRepresentation()); |
| 2093 char* dest = SeqAsciiString::cast(string_result)->GetChars(); | 2093 char* dest = SeqAsciiString::cast(string_result)->GetChars(); |
| (...skipping 2407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4501 void ExternalStringTable::TearDown() { | 4501 void ExternalStringTable::TearDown() { |
| 4502 new_space_strings_.Free(); | 4502 new_space_strings_.Free(); |
| 4503 old_space_strings_.Free(); | 4503 old_space_strings_.Free(); |
| 4504 } | 4504 } |
| 4505 | 4505 |
| 4506 | 4506 |
| 4507 List<Object*> ExternalStringTable::new_space_strings_; | 4507 List<Object*> ExternalStringTable::new_space_strings_; |
| 4508 List<Object*> ExternalStringTable::old_space_strings_; | 4508 List<Object*> ExternalStringTable::old_space_strings_; |
| 4509 | 4509 |
| 4510 } } // namespace v8::internal | 4510 } } // namespace v8::internal |
| OLD | NEW |