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 25 matching lines...) Expand all Loading... |
36 using namespace v8::internal; | 36 using namespace v8::internal; |
37 | 37 |
38 // Anonymous namespace. | 38 // Anonymous namespace. |
39 namespace { | 39 namespace { |
40 | 40 |
41 class StringCompareInput : public Compare::Input { | 41 class StringCompareInput : public Compare::Input { |
42 public: | 42 public: |
43 StringCompareInput(const char* s1, const char* s2) : s1_(s1), s2_(s2) { | 43 StringCompareInput(const char* s1, const char* s2) : s1_(s1), s2_(s2) { |
44 } | 44 } |
45 int getLength1() { | 45 int getLength1() { |
46 return strlen(s1_); | 46 return StrLength(s1_); |
47 } | 47 } |
48 int getLength2() { | 48 int getLength2() { |
49 return strlen(s2_); | 49 return StrLength(s2_); |
50 } | 50 } |
51 bool equals(int index1, int index2) { | 51 bool equals(int index1, int index2) { |
52 return s1_[index1] == s2_[index2]; | 52 return s1_[index1] == s2_[index2]; |
53 } | 53 } |
54 | 54 |
55 private: | 55 private: |
56 const char* s1_; | 56 const char* s1_; |
57 const char* s2_; | 57 const char* s2_; |
58 }; | 58 }; |
59 | 59 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 int expected_diff_parameter = -1) { | 93 int expected_diff_parameter = -1) { |
94 StringCompareInput input(s1, s2); | 94 StringCompareInput input(s1, s2); |
95 | 95 |
96 ZoneScope zone_scope(DELETE_ON_EXIT); | 96 ZoneScope zone_scope(DELETE_ON_EXIT); |
97 | 97 |
98 DiffChunkStruct* first_chunk; | 98 DiffChunkStruct* first_chunk; |
99 ListDiffOutputWriter writer(&first_chunk); | 99 ListDiffOutputWriter writer(&first_chunk); |
100 | 100 |
101 Compare::CalculateDifference(&input, &writer); | 101 Compare::CalculateDifference(&input, &writer); |
102 | 102 |
103 int len1 = strlen(s1); | 103 int len1 = StrLength(s1); |
104 int len2 = strlen(s2); | 104 int len2 = StrLength(s2); |
105 | 105 |
106 int pos1 = 0; | 106 int pos1 = 0; |
107 int pos2 = 0; | 107 int pos2 = 0; |
108 | 108 |
109 int diff_parameter = 0; | 109 int diff_parameter = 0; |
110 | 110 |
111 for (DiffChunkStruct* chunk = first_chunk; | 111 for (DiffChunkStruct* chunk = first_chunk; |
112 chunk != NULL; | 112 chunk != NULL; |
113 chunk = chunk->next) { | 113 chunk = chunk->next) { |
114 int diff_pos1 = chunk->pos1; | 114 int diff_pos1 = chunk->pos1; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 CompareStrings("cat", "cut", 2); | 165 CompareStrings("cat", "cut", 2); |
166 CompareStrings("ct", "cut", 1); | 166 CompareStrings("ct", "cut", 1); |
167 CompareStrings("cat", "ct", 1); | 167 CompareStrings("cat", "ct", 1); |
168 CompareStrings("cat", "cat", 0); | 168 CompareStrings("cat", "cat", 0); |
169 CompareStrings("", "", 0); | 169 CompareStrings("", "", 0); |
170 CompareStrings("cat", "", 3); | 170 CompareStrings("cat", "", 3); |
171 CompareStrings("a cat", "a capybara", 7); | 171 CompareStrings("a cat", "a capybara", 7); |
172 CompareStrings("abbabababababaaabbabababababbabbbbbbbababa", | 172 CompareStrings("abbabababababaaabbabababababbabbbbbbbababa", |
173 "bbbbabababbbabababbbabababababbabbababa"); | 173 "bbbbabababbbabababbbabababababbabbababa"); |
174 } | 174 } |
OLD | NEW |