| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 }; | 339 }; |
| 340 | 340 |
| 341 template <typename DestChar> | 341 template <typename DestChar> |
| 342 class NoExtendString : public NoExtend<DestChar> { | 342 class NoExtendString : public NoExtend<DestChar> { |
| 343 public: | 343 public: |
| 344 NoExtendString(Handle<String> string, int required_length) | 344 NoExtendString(Handle<String> string, int required_length) |
| 345 : NoExtend<DestChar>(string, 0), string_(string) { | 345 : NoExtend<DestChar>(string, 0), string_(string) { |
| 346 DCHECK(string->length() >= required_length); | 346 DCHECK(string->length() >= required_length); |
| 347 } | 347 } |
| 348 | 348 |
| 349 ~NoExtendString() { | 349 Handle<String> Finalize() { |
| 350 Handle<SeqString> string = Handle<SeqString>::cast(string_); | 350 Handle<SeqString> string = Handle<SeqString>::cast(string_); |
| 351 int length = NoExtend<DestChar>::written(); | 351 int length = NoExtend<DestChar>::written(); |
| 352 *string_.location() = *SeqString::Truncate(string, length); | 352 Handle<String> result = SeqString::Truncate(string, length); |
| 353 string_ = Handle<String>(); |
| 354 return result; |
| 353 } | 355 } |
| 354 | 356 |
| 355 private: | 357 private: |
| 356 Handle<String> string_; | 358 Handle<String> string_; |
| 357 }; | 359 }; |
| 358 | 360 |
| 359 template <typename DestChar> | 361 template <typename DestChar> |
| 360 class NoExtendBuilder : public NoExtend<DestChar> { | 362 class NoExtendBuilder : public NoExtend<DestChar> { |
| 361 public: | 363 public: |
| 362 NoExtendBuilder(IncrementalStringBuilder* builder, int required_length) | 364 NoExtendBuilder(IncrementalStringBuilder* builder, int required_length) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 DCHECK_EQ(String::TWO_BYTE_ENCODING, encoding_); | 428 DCHECK_EQ(String::TWO_BYTE_ENCODING, encoding_); |
| 427 SeqTwoByteString::cast(*current_part_) | 429 SeqTwoByteString::cast(*current_part_) |
| 428 ->SeqTwoByteStringSet(current_index_++, c); | 430 ->SeqTwoByteStringSet(current_index_++, c); |
| 429 } | 431 } |
| 430 if (current_index_ == part_length_) Extend(); | 432 if (current_index_ == part_length_) Extend(); |
| 431 } | 433 } |
| 432 } // namespace internal | 434 } // namespace internal |
| 433 } // namespace v8 | 435 } // namespace v8 |
| 434 | 436 |
| 435 #endif // V8_STRING_BUILDER_H_ | 437 #endif // V8_STRING_BUILDER_H_ |
| OLD | NEW |