diff --git a/src/isolate.h b/src/isolate.h index 1706b4867c..52c7145e2c 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -871,14 +871,6 @@ class Isolate { RuntimeState* runtime_state() { return &runtime_state_; } - StringInputBuffer* liveedit_compare_substrings_buf1() { - return &liveedit_compare_substrings_buf1_; - } - - StringInputBuffer* liveedit_compare_substrings_buf2() { - return &liveedit_compare_substrings_buf2_; - } - StaticResource* compiler_safe_string_input_buffer() { return &compiler_safe_string_input_buffer_; } @@ -1144,8 +1136,6 @@ class Isolate { ThreadManager* thread_manager_; AstSentinels* ast_sentinels_; RuntimeState runtime_state_; - StringInputBuffer liveedit_compare_substrings_buf1_; - StringInputBuffer liveedit_compare_substrings_buf2_; StaticResource compiler_safe_string_input_buffer_; Builtins builtins_; StringTracker* string_tracker_; diff --git a/src/liveedit.cc b/src/liveedit.cc index 69cb3aa37b..8488170117 100644 --- a/src/liveedit.cc +++ b/src/liveedit.cc @@ -268,17 +268,10 @@ void Comparator::CalculateDifference(Comparator::Input* input, } -static bool CompareSubstrings(Isolate* isolate, Handle s1, int pos1, +static bool CompareSubstrings(Handle s1, int pos1, Handle s2, int pos2, int len) { - StringInputBuffer& buf1 = *isolate->liveedit_compare_substrings_buf1(); - StringInputBuffer& buf2 = *isolate->liveedit_compare_substrings_buf2(); - buf1.Reset(*s1); - buf1.Seek(pos1); - buf2.Reset(*s2); - buf2.Seek(pos2); for (int i = 0; i < len; i++) { - ASSERT(buf1.has_more() && buf2.has_more()); - if (buf1.GetNext() != buf2.GetNext()) { + if (s1->Get(i + pos1) != s2->Get(i + pos2)) { return false; } } @@ -410,9 +403,9 @@ class LineEndsWrapper { // Represents 2 strings as 2 arrays of lines. class LineArrayCompareInput : public Comparator::Input { public: - LineArrayCompareInput(Isolate* isolate, Handle s1, Handle s2, + LineArrayCompareInput(Handle s1, Handle s2, LineEndsWrapper line_ends1, LineEndsWrapper line_ends2) - : isolate_(isolate), s1_(s1), s2_(s2), line_ends1_(line_ends1), + : s1_(s1), s2_(s2), line_ends1_(line_ends1), line_ends2_(line_ends2) { } int getLength1() { @@ -431,12 +424,11 @@ class LineArrayCompareInput : public Comparator::Input { if (len1 != len2) { return false; } - return CompareSubstrings(isolate_, s1_, line_start1, s2_, line_start2, + return CompareSubstrings(s1_, line_start1, s2_, line_start2, len1); } private: - Isolate* isolate_; Handle s1_; Handle s2_; LineEndsWrapper line_ends1_; @@ -492,11 +484,13 @@ class TokenizingLineArrayCompareOutput : public Comparator::Output { Handle LiveEdit::CompareStrings(Handle s1, Handle s2) { + s1 = FlattenGetString(s1); + s2 = FlattenGetString(s2); + LineEndsWrapper line_ends1(s1); LineEndsWrapper line_ends2(s2); - LineArrayCompareInput - input(Isolate::Current(), s1, s2, line_ends1, line_ends2); + LineArrayCompareInput input(s1, s2, line_ends1, line_ends2); TokenizingLineArrayCompareOutput output(line_ends1, line_ends2, s1, s2); Comparator::CalculateDifference(&input, &output);