Chromium Code Reviews| Index: src/objects-inl.h |
| diff --git a/src/objects-inl.h b/src/objects-inl.h |
| index 7772cfefe2d17a53da79042a890f88ab59c89449..0ff5fc2e725d3a070d923270aec0e6a1af270206 100644 |
| --- a/src/objects-inl.h |
| +++ b/src/objects-inl.h |
| @@ -2845,21 +2845,37 @@ String* ConsStringIteratorOp::ContinueOperation(int32_t* type_out, |
| uint16_t StringCharacterStream::GetNext() { |
| - ASSERT((buffer8_ == NULL && end_ == NULL) || buffer8_ < end_); |
| + ASSERT(buffer8_ != NULL && end_ != NULL); |
| + // Advance cursor if needed. |
| + // TODO(dcarney): Ensure uses of the api call HasMore first and avoid this. |
| + if (buffer8_ == end_) HasMore(); |
| + ASSERT(buffer8_ < end_); |
| return is_one_byte_ ? *buffer8_++ : *buffer16_++; |
| } |
| -StringCharacterStream::StringCharacterStream( |
| - String* string, unsigned offset, ConsStringIteratorOp* op) |
| - : is_one_byte_(false), |
| - buffer8_(NULL), |
| - end_(NULL), |
| - op_(op) { |
| - op->Reset(); |
| +StringCharacterStream::StringCharacterStream(String* string, |
| + ConsStringIteratorOp* op) |
| + : op_(op) { |
|
Yang
2012/12/21 09:21:48
Please initialize is_one_byte_, some compilers whi
|
| + Reset(string); |
| +} |
| + |
| + |
| +StringCharacterStream::StringCharacterStream(String* string, |
| + unsigned offset, |
| + ConsStringIteratorOp* op) |
|
Yang
2012/12/21 09:21:48
Wouldn't it be cleaner to put offset as last and o
|
| + : op_(op) { |
| + Reset(string, offset); |
| +} |
| + |
| + |
| +void StringCharacterStream::Reset(String* string, unsigned offset) { |
| + op_->Reset(); |
| + buffer8_ = NULL; |
| + end_ = NULL; |
| int32_t type = string->map()->instance_type(); |
| unsigned length = string->length(); |
| - String::Visit(string, offset, *this, *op, type, length); |
| + String::Visit(string, offset, *this, *op_, type, length); |
| } |