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

Side by Side Diff: src/string-builder.h

Issue 2433923003: [regexp] Add fast-path for global, callable replace (Closed)
Patch Set: Rebase Created 4 years, 1 month 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
« no previous file with comments | « src/runtime/runtime-regexp.cc ('k') | 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_STRING_BUILDER_H_ 5 #ifndef V8_STRING_BUILDER_H_
6 #define V8_STRING_BUILDER_H_ 6 #define V8_STRING_BUILDER_H_
7 7
8 #include "src/assert-scope.h" 8 #include "src/assert-scope.h"
9 #include "src/factory.h" 9 #include "src/factory.h"
10 #include "src/handles.h" 10 #include "src/handles.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 array_->set(length_, value); 167 array_->set(length_, value);
168 length_++; 168 length_++;
169 } 169 }
170 170
171 Handle<FixedArray> array() { return array_; } 171 Handle<FixedArray> array() { return array_; }
172 172
173 int length() { return length_; } 173 int length() { return length_; }
174 174
175 int capacity() { return array_->length(); } 175 int capacity() { return array_->length(); }
176 176
177 Handle<JSArray> ToJSArray(Handle<JSArray> target_array) {
178 JSArray::SetContent(target_array, array_);
179 target_array->set_length(Smi::FromInt(length_));
180 return target_array;
181 }
177 182
178 private: 183 private:
179 Handle<FixedArray> array_; 184 Handle<FixedArray> array_;
180 int length_; 185 int length_;
181 bool has_non_smi_elements_; 186 bool has_non_smi_elements_;
182 }; 187 };
183 188
184 189
185 class ReplacementStringBuilder { 190 class ReplacementStringBuilder {
186 public: 191 public:
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 DCHECK_EQ(String::TWO_BYTE_ENCODING, encoding_); 437 DCHECK_EQ(String::TWO_BYTE_ENCODING, encoding_);
433 SeqTwoByteString::cast(*current_part_) 438 SeqTwoByteString::cast(*current_part_)
434 ->SeqTwoByteStringSet(current_index_++, c); 439 ->SeqTwoByteStringSet(current_index_++, c);
435 } 440 }
436 if (current_index_ == part_length_) Extend(); 441 if (current_index_ == part_length_) Extend();
437 } 442 }
438 } // namespace internal 443 } // namespace internal
439 } // namespace v8 444 } // namespace v8
440 445
441 #endif // V8_STRING_BUILDER_H_ 446 #endif // V8_STRING_BUILDER_H_
OLDNEW
« no previous file with comments | « src/runtime/runtime-regexp.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698