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

Side by Side Diff: src/heap.cc

Issue 7237023: Check for empty substring. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 6 months 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2616 matching lines...) Expand 10 before | Expand all | Expand 10 after
2627 WriteBarrierMode mode = cons_string->GetWriteBarrierMode(no_gc); 2627 WriteBarrierMode mode = cons_string->GetWriteBarrierMode(no_gc);
2628 cons_string->set_length(length); 2628 cons_string->set_length(length);
2629 cons_string->set_hash_field(String::kEmptyHashField); 2629 cons_string->set_hash_field(String::kEmptyHashField);
2630 cons_string->set_first(first, mode); 2630 cons_string->set_first(first, mode);
2631 cons_string->set_second(second, mode); 2631 cons_string->set_second(second, mode);
2632 return result; 2632 return result;
2633 } 2633 }
2634 2634
2635 2635
2636 MaybeObject* Heap::AllocateSubString(String* buffer, 2636 MaybeObject* Heap::AllocateSubString(String* buffer,
2637 int start, 2637 int start,
2638 int end, 2638 int end,
2639 PretenureFlag pretenure) { 2639 PretenureFlag pretenure) {
2640 int length = end - start; 2640 int length = end - start;
2641 2641 if (length == 0) {
2642 if (length == 1) { 2642 return empty_string();
2643 } else if (length == 1) {
2643 return LookupSingleCharacterStringFromCode(buffer->Get(start)); 2644 return LookupSingleCharacterStringFromCode(buffer->Get(start));
2644 } else if (length == 2) { 2645 } else if (length == 2) {
2645 // Optimization for 2-byte strings often used as keys in a decompression 2646 // Optimization for 2-byte strings often used as keys in a decompression
2646 // dictionary. Check whether we already have the string in the symbol 2647 // dictionary. Check whether we already have the string in the symbol
2647 // table to prevent creation of many unneccesary strings. 2648 // table to prevent creation of many unneccesary strings.
2648 unsigned c1 = buffer->Get(start); 2649 unsigned c1 = buffer->Get(start);
2649 unsigned c2 = buffer->Get(start + 1); 2650 unsigned c2 = buffer->Get(start + 1);
2650 return MakeOrFindTwoCharacterString(this, c1, c2); 2651 return MakeOrFindTwoCharacterString(this, c1, c2);
2651 } 2652 }
2652 2653
(...skipping 3381 matching lines...) Expand 10 before | Expand all | Expand 10 after
6034 } 6035 }
6035 6036
6036 6037
6037 void ExternalStringTable::TearDown() { 6038 void ExternalStringTable::TearDown() {
6038 new_space_strings_.Free(); 6039 new_space_strings_.Free();
6039 old_space_strings_.Free(); 6040 old_space_strings_.Free();
6040 } 6041 }
6041 6042
6042 6043
6043 } } // namespace v8::internal 6044 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698