OLD | NEW |
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 Loading... |
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 } | |
182 | |
183 | 177 |
184 private: | 178 private: |
185 Handle<FixedArray> array_; | 179 Handle<FixedArray> array_; |
186 int length_; | 180 int length_; |
187 bool has_non_smi_elements_; | 181 bool has_non_smi_elements_; |
188 }; | 182 }; |
189 | 183 |
190 | 184 |
191 class ReplacementStringBuilder { | 185 class ReplacementStringBuilder { |
192 public: | 186 public: |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 DCHECK_EQ(String::TWO_BYTE_ENCODING, encoding_); | 432 DCHECK_EQ(String::TWO_BYTE_ENCODING, encoding_); |
439 SeqTwoByteString::cast(*current_part_) | 433 SeqTwoByteString::cast(*current_part_) |
440 ->SeqTwoByteStringSet(current_index_++, c); | 434 ->SeqTwoByteStringSet(current_index_++, c); |
441 } | 435 } |
442 if (current_index_ == part_length_) Extend(); | 436 if (current_index_ == part_length_) Extend(); |
443 } | 437 } |
444 } // namespace internal | 438 } // namespace internal |
445 } // namespace v8 | 439 } // namespace v8 |
446 | 440 |
447 #endif // V8_STRING_BUILDER_H_ | 441 #endif // V8_STRING_BUILDER_H_ |
OLD | NEW |