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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 INLINE(bool CurrentPartCanFit(int length)) { | 303 INLINE(bool CurrentPartCanFit(int length)) { |
304 return part_length_ - current_index_ > length; | 304 return part_length_ - current_index_ > length; |
305 } | 305 } |
306 | 306 |
307 void AppendString(Handle<String> string); | 307 void AppendString(Handle<String> string); |
308 | 308 |
309 MaybeHandle<String> Finish(); | 309 MaybeHandle<String> Finish(); |
310 | 310 |
311 INLINE(bool HasOverflowed()) const { return overflowed_; } | 311 INLINE(bool HasOverflowed()) const { return overflowed_; } |
312 | 312 |
| 313 INLINE(int Length()) const { return accumulator_->length() + current_index_; } |
| 314 |
313 // Change encoding to two-byte. | 315 // Change encoding to two-byte. |
314 void ChangeEncoding() { | 316 void ChangeEncoding() { |
315 DCHECK_EQ(String::ONE_BYTE_ENCODING, encoding_); | 317 DCHECK_EQ(String::ONE_BYTE_ENCODING, encoding_); |
316 ShrinkCurrentPart(); | 318 ShrinkCurrentPart(); |
317 encoding_ = String::TWO_BYTE_ENCODING; | 319 encoding_ = String::TWO_BYTE_ENCODING; |
318 Extend(); | 320 Extend(); |
319 } | 321 } |
320 | 322 |
321 template <typename DestChar> | 323 template <typename DestChar> |
322 class NoExtend { | 324 class NoExtend { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 DCHECK_EQ(String::TWO_BYTE_ENCODING, encoding_); | 439 DCHECK_EQ(String::TWO_BYTE_ENCODING, encoding_); |
438 SeqTwoByteString::cast(*current_part_) | 440 SeqTwoByteString::cast(*current_part_) |
439 ->SeqTwoByteStringSet(current_index_++, c); | 441 ->SeqTwoByteStringSet(current_index_++, c); |
440 } | 442 } |
441 if (current_index_ == part_length_) Extend(); | 443 if (current_index_ == part_length_) Extend(); |
442 } | 444 } |
443 } // namespace internal | 445 } // namespace internal |
444 } // namespace v8 | 446 } // namespace v8 |
445 | 447 |
446 #endif // V8_STRING_BUILDER_H_ | 448 #endif // V8_STRING_BUILDER_H_ |
OLD | NEW |