| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 int pos1; | 69 int pos1; |
| 70 int pos2; | 70 int pos2; |
| 71 int len1; | 71 int len1; |
| 72 int len2; | 72 int len2; |
| 73 DiffChunkStruct* next; | 73 DiffChunkStruct* next; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 | 76 |
| 77 class ListDiffOutputWriter : public Comparator::Output { | 77 class ListDiffOutputWriter : public Comparator::Output { |
| 78 public: | 78 public: |
| 79 explicit ListDiffOutputWriter(DiffChunkStruct** next_chunk_pointer) | 79 explicit ListDiffOutputWriter(DiffChunkStruct** next_chunk_pointer, |
| 80 : next_chunk_pointer_(next_chunk_pointer) { | 80 Zone* zone) |
| 81 : next_chunk_pointer_(next_chunk_pointer), zone_(zone) { |
| 81 (*next_chunk_pointer_) = NULL; | 82 (*next_chunk_pointer_) = NULL; |
| 82 } | 83 } |
| 83 void AddChunk(int pos1, int pos2, int len1, int len2) { | 84 void AddChunk(int pos1, int pos2, int len1, int len2) { |
| 84 current_chunk_ = new(Isolate::Current()->runtime_zone()) DiffChunkStruct( | 85 current_chunk_ = new(zone_) DiffChunkStruct(pos1, pos2, len1, len2); |
| 85 pos1, pos2, len1, len2); | |
| 86 (*next_chunk_pointer_) = current_chunk_; | 86 (*next_chunk_pointer_) = current_chunk_; |
| 87 next_chunk_pointer_ = ¤t_chunk_->next; | 87 next_chunk_pointer_ = ¤t_chunk_->next; |
| 88 } | 88 } |
| 89 private: | 89 private: |
| 90 DiffChunkStruct** next_chunk_pointer_; | 90 DiffChunkStruct** next_chunk_pointer_; |
| 91 DiffChunkStruct* current_chunk_; | 91 DiffChunkStruct* current_chunk_; |
| 92 Zone* zone_; |
| 92 }; | 93 }; |
| 93 | 94 |
| 94 | 95 |
| 95 void CompareStringsOneWay(const char* s1, const char* s2, | 96 void CompareStringsOneWay(const char* s1, const char* s2, |
| 96 int expected_diff_parameter = -1) { | 97 int expected_diff_parameter = -1) { |
| 97 StringCompareInput input(s1, s2); | 98 StringCompareInput input(s1, s2); |
| 98 | 99 |
| 99 ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); | 100 Zone zone(Isolate::Current()); |
| 100 | 101 |
| 101 DiffChunkStruct* first_chunk; | 102 DiffChunkStruct* first_chunk; |
| 102 ListDiffOutputWriter writer(&first_chunk); | 103 ListDiffOutputWriter writer(&first_chunk, &zone); |
| 103 | 104 |
| 104 Comparator::CalculateDifference(&input, &writer); | 105 Comparator::CalculateDifference(&input, &writer); |
| 105 | 106 |
| 106 int len1 = StrLength(s1); | 107 int len1 = StrLength(s1); |
| 107 int len2 = StrLength(s2); | 108 int len2 = StrLength(s2); |
| 108 | 109 |
| 109 int pos1 = 0; | 110 int pos1 = 0; |
| 110 int pos2 = 0; | 111 int pos2 = 0; |
| 111 | 112 |
| 112 int diff_parameter = 0; | 113 int diff_parameter = 0; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 CompareStrings("cat", "ct", 1); | 172 CompareStrings("cat", "ct", 1); |
| 172 CompareStrings("cat", "cat", 0); | 173 CompareStrings("cat", "cat", 0); |
| 173 CompareStrings("", "", 0); | 174 CompareStrings("", "", 0); |
| 174 CompareStrings("cat", "", 3); | 175 CompareStrings("cat", "", 3); |
| 175 CompareStrings("a cat", "a capybara", 7); | 176 CompareStrings("a cat", "a capybara", 7); |
| 176 CompareStrings("abbabababababaaabbabababababbabbbbbbbababa", | 177 CompareStrings("abbabababababaaabbabababababbabbbbbbbababa", |
| 177 "bbbbabababbbabababbbabababababbabbababa"); | 178 "bbbbabababbbabababbbabababababbabbababa"); |
| 178 } | 179 } |
| 179 | 180 |
| 180 #endif // ENABLE_DEBUGGER_SUPPORT | 181 #endif // ENABLE_DEBUGGER_SUPPORT |
| OLD | NEW |