| Index: src/objects.cc
|
| ===================================================================
|
| --- src/objects.cc (revision 1519)
|
| +++ src/objects.cc (working copy)
|
| @@ -575,10 +575,9 @@
|
| // We don't use the BBC's overcorrect "an historic occasion" though if
|
| // you speak a dialect you may well say "an 'istoric occasion".
|
| static bool AnWord(String* str) {
|
| - StringShape shape(str);
|
| - if (str->length(shape) == 0) return false; // A nothing.
|
| - int c0 = str->Get(shape, 0);
|
| - int c1 = str->length(shape) > 1 ? str->Get(shape, 1) : 0;
|
| + if (str->length() == 0) return false; // A nothing.
|
| + int c0 = str->Get(0);
|
| + int c1 = str->length() > 1 ? str->Get(1) : 0;
|
| if (c0 == 'U') {
|
| if (c1 > 'Z') {
|
| return true; // An Umpire, but a UTF8String, a U.
|
| @@ -594,7 +593,7 @@
|
| }
|
|
|
|
|
| -Object* String::TryFlatten(StringShape shape) {
|
| +Object* String::TryFlatten() {
|
| #ifdef DEBUG
|
| // Do not attempt to flatten in debug mode when allocation is not
|
| // allowed. This is to avoid an assertion failure when allocating.
|
| @@ -603,7 +602,7 @@
|
| if (!Heap::IsAllocationAllowed()) return this;
|
| #endif
|
|
|
| - switch (shape.representation_tag()) {
|
| + switch (StringShape(this).representation_tag()) {
|
| case kSlicedStringTag: {
|
| SlicedString* ss = SlicedString::cast(this);
|
| // The SlicedString constructor should ensure that there are no
|
| @@ -611,7 +610,7 @@
|
| // SlicedStrings.
|
| String* buf = ss->buffer();
|
| ASSERT(!buf->IsSlicedString());
|
| - Object* ok = buf->TryFlatten(StringShape(buf));
|
| + Object* ok = buf->TryFlatten();
|
| if (ok->IsFailure()) return ok;
|
| // Under certain circumstances (TryFlattenIfNotFlat fails in
|
| // String::Slice) we can have a cons string under a slice.
|
| @@ -630,21 +629,19 @@
|
| // cons string is in old space. It can never get GCed until there is
|
| // an old space GC.
|
| PretenureFlag tenure = Heap::InNewSpace(this) ? NOT_TENURED : TENURED;
|
| - int len = length(shape);
|
| + int len = length();
|
| Object* object;
|
| String* result;
|
| - if (shape.IsAsciiRepresentation()) {
|
| + if (StringShape(this).IsAsciiRepresentation()) {
|
| object = Heap::AllocateRawAsciiString(len, tenure);
|
| if (object->IsFailure()) return object;
|
| result = String::cast(object);
|
| String* first = cs->first();
|
| - StringShape first_shape(first);
|
| - int first_length = first->length(first_shape);
|
| + int first_length = first->length();
|
| char* dest = SeqAsciiString::cast(result)->GetChars();
|
| - WriteToFlat(first, first_shape, dest, 0, first_length);
|
| + WriteToFlat(first, dest, 0, first_length);
|
| String* second = cs->second();
|
| WriteToFlat(second,
|
| - StringShape(second),
|
| dest + first_length,
|
| 0,
|
| len - first_length);
|
| @@ -654,12 +651,10 @@
|
| result = String::cast(object);
|
| uc16* dest = SeqTwoByteString::cast(result)->GetChars();
|
| String* first = cs->first();
|
| - StringShape first_shape(first);
|
| - int first_length = first->length(first_shape);
|
| - WriteToFlat(first, first_shape, dest, 0, first_length);
|
| + int first_length = first->length();
|
| + WriteToFlat(first, dest, 0, first_length);
|
| String* second = cs->second();
|
| WriteToFlat(second,
|
| - StringShape(second),
|
| dest + first_length,
|
| 0,
|
| len - first_length);
|
| @@ -761,8 +756,7 @@
|
|
|
|
|
| void String::StringShortPrint(StringStream* accumulator) {
|
| - StringShape shape(this);
|
| - int len = length(shape);
|
| + int len = length();
|
| if (len > kMaxMediumStringSize) {
|
| accumulator->Add("<Very long string[%u]>", len);
|
| return;
|
| @@ -790,7 +784,7 @@
|
| }
|
| buf.Reset(this);
|
| if (ascii) {
|
| - accumulator->Add("<String[%u]: ", length(shape));
|
| + accumulator->Add("<String[%u]: ", length());
|
| for (int i = 0; i < len; i++) {
|
| accumulator->Put(buf.GetNext());
|
| }
|
| @@ -798,7 +792,7 @@
|
| } else {
|
| // Backslash indicates that the string contains control
|
| // characters and that backslashes are therefore escaped.
|
| - accumulator->Add("<String[%u]\\: ", length(shape));
|
| + accumulator->Add("<String[%u]\\: ", length());
|
| for (int i = 0; i < len; i++) {
|
| int c = buf.GetNext();
|
| if (c == '\n') {
|
| @@ -979,12 +973,12 @@
|
|
|
| if (instance_type < FIRST_NONSTRING_TYPE
|
| && (StringShape(instance_type).IsSequential())) {
|
| - StringShape shape(instance_type);
|
| - if (shape.IsAsciiRepresentation()) {
|
| - return reinterpret_cast<SeqAsciiString*>(this)->SeqAsciiStringSize(shape);
|
| + if (StringShape(instance_type).IsAsciiRepresentation()) {
|
| + SeqAsciiString* seq_ascii_this = reinterpret_cast<SeqAsciiString*>(this);
|
| + return seq_ascii_this->SeqAsciiStringSize(instance_type);
|
| } else {
|
| SeqTwoByteString* self = reinterpret_cast<SeqTwoByteString*>(this);
|
| - return self->SeqTwoByteStringSize(shape);
|
| + return self->SeqTwoByteStringSize(instance_type);
|
| }
|
| }
|
|
|
| @@ -2559,7 +2553,7 @@
|
| }
|
|
|
| // Try to flatten before operating on the string.
|
| - name->TryFlattenIfNotFlat(StringShape(name));
|
| + name->TryFlattenIfNotFlat();
|
|
|
| // Check if there is an API defined callback object which prohibits
|
| // callback overwriting in this object or it's prototype chain.
|
| @@ -3274,13 +3268,12 @@
|
|
|
|
|
| int String::Utf8Length() {
|
| - StringShape shape(this);
|
| - if (shape.IsAsciiRepresentation()) return length(shape);
|
| + if (StringShape(this).IsAsciiRepresentation()) return length();
|
| // Attempt to flatten before accessing the string. It probably
|
| // doesn't make Utf8Length faster, but it is very likely that
|
| // the string will be accessed later (for example by WriteUtf8)
|
| // so it's still a good idea.
|
| - TryFlattenIfNotFlat(shape); // shape is now no longer valid.
|
| + TryFlattenIfNotFlat();
|
| Access<StringInputBuffer> buffer(&string_input_buffer);
|
| buffer->Reset(0, this);
|
| int result = 0;
|
| @@ -3291,26 +3284,23 @@
|
|
|
|
|
| Vector<const char> String::ToAsciiVector() {
|
| - StringShape shape(this);
|
| - ASSERT(shape.IsAsciiRepresentation());
|
| - ASSERT(IsFlat(shape));
|
| + ASSERT(StringShape(this).IsAsciiRepresentation());
|
| + ASSERT(IsFlat());
|
|
|
| int offset = 0;
|
| - int length = this->length(shape);
|
| - StringRepresentationTag string_tag = shape.representation_tag();
|
| + int length = this->length();
|
| + StringRepresentationTag string_tag = StringShape(this).representation_tag();
|
| String* string = this;
|
| if (string_tag == kSlicedStringTag) {
|
| SlicedString* sliced = SlicedString::cast(string);
|
| offset += sliced->start();
|
| string = sliced->buffer();
|
| - shape = StringShape(string);
|
| - string_tag = shape.representation_tag();
|
| + string_tag = StringShape(string).representation_tag();
|
| } else if (string_tag == kConsStringTag) {
|
| ConsString* cons = ConsString::cast(string);
|
| - ASSERT(cons->second()->length(StringShape(cons->second())) == 0);
|
| + ASSERT(cons->second()->length() == 0);
|
| string = cons->first();
|
| - shape = StringShape(string);
|
| - string_tag = shape.representation_tag();
|
| + string_tag = StringShape(string).representation_tag();
|
| }
|
| if (string_tag == kSeqStringTag) {
|
| SeqAsciiString* seq = SeqAsciiString::cast(string);
|
| @@ -3325,26 +3315,23 @@
|
|
|
|
|
| Vector<const uc16> String::ToUC16Vector() {
|
| - StringShape shape(this);
|
| - ASSERT(shape.IsTwoByteRepresentation());
|
| - ASSERT(IsFlat(shape));
|
| + ASSERT(StringShape(this).IsTwoByteRepresentation());
|
| + ASSERT(IsFlat());
|
|
|
| int offset = 0;
|
| - int length = this->length(shape);
|
| - StringRepresentationTag string_tag = shape.representation_tag();
|
| + int length = this->length();
|
| + StringRepresentationTag string_tag = StringShape(this).representation_tag();
|
| String* string = this;
|
| if (string_tag == kSlicedStringTag) {
|
| SlicedString* sliced = SlicedString::cast(string);
|
| offset += sliced->start();
|
| string = String::cast(sliced->buffer());
|
| - shape = StringShape(string);
|
| - string_tag = shape.representation_tag();
|
| + string_tag = StringShape(string).representation_tag();
|
| } else if (string_tag == kConsStringTag) {
|
| ConsString* cons = ConsString::cast(string);
|
| - ASSERT(cons->second()->length(StringShape(cons->second())) == 0);
|
| + ASSERT(cons->second()->length() == 0);
|
| string = cons->first();
|
| - shape = StringShape(string);
|
| - string_tag = shape.representation_tag();
|
| + string_tag = StringShape(string).representation_tag();
|
| }
|
| if (string_tag == kSeqStringTag) {
|
| SeqTwoByteString* seq = SeqTwoByteString::cast(string);
|
| @@ -3424,9 +3411,8 @@
|
|
|
|
|
| const uc16* String::GetTwoByteData(unsigned start) {
|
| - StringShape shape(this);
|
| - ASSERT(!shape.IsAsciiRepresentation());
|
| - switch (shape.representation_tag()) {
|
| + ASSERT(!StringShape(this).IsAsciiRepresentation());
|
| + switch (StringShape(this).representation_tag()) {
|
| case kSeqStringTag:
|
| return SeqTwoByteString::cast(this)->SeqTwoByteStringGetData(start);
|
| case kExternalStringTag:
|
| @@ -3438,7 +3424,7 @@
|
| if (StringShape(buffer).IsCons()) {
|
| ConsString* cs = ConsString::cast(buffer);
|
| // Flattened string.
|
| - ASSERT(cs->second()->length(StringShape(cs->second())) == 0);
|
| + ASSERT(cs->second()->length() == 0);
|
| buffer = cs->first();
|
| }
|
| return buffer->GetTwoByteData(start + sliced_string->start());
|
| @@ -3541,8 +3527,7 @@
|
|
|
| while (true) {
|
| String* left = current->first();
|
| - StringShape left_shape(left);
|
| - unsigned left_length = (unsigned)left->length(left_shape);
|
| + unsigned left_length = (unsigned)left->length();
|
| if (left_length > offset &&
|
| (max_chars <= left_length - offset ||
|
| (rbb->capacity <= left_length - offset &&
|
| @@ -3554,7 +3539,7 @@
|
| // the point where we switch to the -IntoBuffer routines (below) in order
|
| // to maximize the chances of delegating a big chunk of work to the
|
| // efficient *AsciiStringReadBlock routines.
|
| - if (left_shape.IsCons()) {
|
| + if (StringShape(left).IsCons()) {
|
| current = ConsString::cast(left);
|
| continue;
|
| } else {
|
| @@ -3719,10 +3704,9 @@
|
| rbb->remaining = 0;
|
| return NULL;
|
| }
|
| - StringShape shape(input);
|
| - switch (shape.representation_tag()) {
|
| + switch (StringShape(input).representation_tag()) {
|
| case kSeqStringTag:
|
| - if (shape.IsAsciiRepresentation()) {
|
| + if (StringShape(input).IsAsciiRepresentation()) {
|
| SeqAsciiString* str = SeqAsciiString::cast(input);
|
| return str->SeqAsciiStringReadBlock(&rbb->remaining,
|
| offset_ptr,
|
| @@ -3743,7 +3727,7 @@
|
| offset_ptr,
|
| max_chars);
|
| case kExternalStringTag:
|
| - if (shape.IsAsciiRepresentation()) {
|
| + if (StringShape(input).IsAsciiRepresentation()) {
|
| return ExternalAsciiString::cast(input)->ExternalAsciiStringReadBlock(
|
| &rbb->remaining,
|
| offset_ptr,
|
| @@ -3795,9 +3779,8 @@
|
| void FlatStringReader::RefreshState() {
|
| if (str_ == NULL) return;
|
| Handle<String> str(str_);
|
| - StringShape shape(*str);
|
| - ASSERT(str->IsFlat(shape));
|
| - is_ascii_ = shape.IsAsciiRepresentation();
|
| + ASSERT(str->IsFlat());
|
| + is_ascii_ = StringShape(*str).IsAsciiRepresentation();
|
| if (is_ascii_) {
|
| start_ = str->ToAsciiVector().start();
|
| } else {
|
| @@ -3833,13 +3816,12 @@
|
| ReadBlockBuffer* rbb,
|
| unsigned* offset_ptr,
|
| unsigned max_chars) {
|
| - StringShape shape(input);
|
| - ASSERT(*offset_ptr <= (unsigned)input->length(shape));
|
| + ASSERT(*offset_ptr <= (unsigned)input->length());
|
| if (max_chars == 0) return;
|
|
|
| - switch (shape.representation_tag()) {
|
| + switch (StringShape(input).representation_tag()) {
|
| case kSeqStringTag:
|
| - if (shape.IsAsciiRepresentation()) {
|
| + if (StringShape(input).IsAsciiRepresentation()) {
|
| SeqAsciiString::cast(input)->SeqAsciiStringReadBlockIntoBuffer(rbb,
|
| offset_ptr,
|
| max_chars);
|
| @@ -3861,7 +3843,7 @@
|
| max_chars);
|
| return;
|
| case kExternalStringTag:
|
| - if (shape.IsAsciiRepresentation()) {
|
| + if (StringShape(input).IsAsciiRepresentation()) {
|
| ExternalAsciiString::cast(input)->
|
| ExternalAsciiStringReadBlockIntoBuffer(rbb, offset_ptr, max_chars);
|
| } else {
|
| @@ -3885,12 +3867,11 @@
|
| unsigned capacity,
|
| unsigned* remaining,
|
| unsigned* offset_ptr) {
|
| - StringShape shape(input);
|
| - ASSERT(*offset_ptr <= (unsigned)input->length(shape));
|
| - unsigned chars = input->length(shape) - *offset_ptr;
|
| + ASSERT(*offset_ptr <= (unsigned)input->length());
|
| + unsigned chars = input->length() - *offset_ptr;
|
| ReadBlockBuffer rbb(util_buffer, 0, capacity, 0);
|
| const unibrow::byte* answer = ReadBlock(input, &rbb, offset_ptr, chars);
|
| - ASSERT(rbb.remaining <= static_cast<unsigned>(input->length(shape)));
|
| + ASSERT(rbb.remaining <= static_cast<unsigned>(input->length()));
|
| *remaining = rbb.remaining;
|
| return answer;
|
| }
|
| @@ -3901,14 +3882,13 @@
|
| unsigned capacity,
|
| unsigned* remaining,
|
| unsigned* offset_ptr) {
|
| - StringShape shape(*raw_input);
|
| Handle<String> input(raw_input);
|
| - ASSERT(*offset_ptr <= (unsigned)input->length(shape));
|
| - unsigned chars = input->length(shape) - *offset_ptr;
|
| + ASSERT(*offset_ptr <= (unsigned)input->length());
|
| + unsigned chars = input->length() - *offset_ptr;
|
| if (chars > capacity) chars = capacity;
|
| ReadBlockBuffer rbb(util_buffer, 0, capacity, 0);
|
| ReadBlockIntoBuffer(*input, &rbb, offset_ptr, chars);
|
| - ASSERT(rbb.remaining <= static_cast<unsigned>(input->length(shape)));
|
| + ASSERT(rbb.remaining <= static_cast<unsigned>(input->length()));
|
| *remaining = rbb.remaining;
|
| return rbb.util_buffer;
|
| }
|
| @@ -3928,13 +3908,12 @@
|
|
|
| while (true) {
|
| String* left = current->first();
|
| - StringShape left_shape(left);
|
| - unsigned left_length = (unsigned)left->length(left_shape);
|
| + unsigned left_length = (unsigned)left->length();
|
| if (left_length > offset &&
|
| max_chars <= left_length - offset) {
|
| // Left hand side only - iterate unless we have reached the bottom of
|
| // the cons tree.
|
| - if (left_shape.IsCons()) {
|
| + if (StringShape(left).IsCons()) {
|
| current = ConsString::cast(left);
|
| continue;
|
| } else {
|
| @@ -4002,27 +3981,23 @@
|
| // Check for a flattened cons string
|
| if (second()->length() == 0) {
|
| String* left = first();
|
| - return left->Get(StringShape(left), index);
|
| + return left->Get(index);
|
| }
|
|
|
| String* string = String::cast(this);
|
| - StringShape shape(string);
|
|
|
| while (true) {
|
| - if (shape.IsCons()) {
|
| + if (StringShape(string).IsCons()) {
|
| ConsString* cons_string = ConsString::cast(string);
|
| String* left = cons_string->first();
|
| - StringShape left_shape(left);
|
| - if (left->length(left_shape) > index) {
|
| + if (left->length() > index) {
|
| string = left;
|
| - shape = left_shape;
|
| } else {
|
| - index -= left->length(left_shape);
|
| + index -= left->length();
|
| string = cons_string->second();
|
| - shape = StringShape(string);
|
| }
|
| } else {
|
| - return string->Get(shape, index);
|
| + return string->Get(index);
|
| }
|
| }
|
|
|
| @@ -4033,17 +4008,15 @@
|
|
|
| template <typename sinkchar>
|
| void String::WriteToFlat(String* src,
|
| - StringShape src_shape,
|
| sinkchar* sink,
|
| int f,
|
| int t) {
|
| String* source = src;
|
| - StringShape shape = src_shape;
|
| int from = f;
|
| int to = t;
|
| while (true) {
|
| - ASSERT(0 <= from && from <= to && to <= source->length(shape));
|
| - switch (shape.full_representation_tag()) {
|
| + ASSERT(0 <= from && from <= to && to <= source->length());
|
| + switch (StringShape(source).full_representation_tag()) {
|
| case kAsciiStringTag | kExternalStringTag: {
|
| CopyChars(sink,
|
| ExternalAsciiString::cast(source)->resource()->data() + from,
|
| @@ -4077,19 +4050,17 @@
|
| from += start;
|
| to += start;
|
| source = String::cast(sliced_string->buffer());
|
| - shape = StringShape(source);
|
| break;
|
| }
|
| case kAsciiStringTag | kConsStringTag:
|
| case kTwoByteStringTag | kConsStringTag: {
|
| ConsString* cons_string = ConsString::cast(source);
|
| String* first = cons_string->first();
|
| - StringShape first_shape(first);
|
| - int boundary = first->length(first_shape);
|
| + int boundary = first->length();
|
| if (to - boundary >= boundary - from) {
|
| // Right hand side is longer. Recurse over left.
|
| if (from < boundary) {
|
| - WriteToFlat(first, first_shape, sink, from, boundary);
|
| + WriteToFlat(first, sink, from, boundary);
|
| sink += boundary - from;
|
| from = 0;
|
| } else {
|
| @@ -4097,20 +4068,17 @@
|
| }
|
| to -= boundary;
|
| source = cons_string->second();
|
| - shape = StringShape(source);
|
| } else {
|
| // Left hand side is longer. Recurse over right.
|
| if (to > boundary) {
|
| String* second = cons_string->second();
|
| WriteToFlat(second,
|
| - StringShape(second),
|
| sink + boundary - from,
|
| 0,
|
| to - boundary);
|
| to = boundary;
|
| }
|
| source = first;
|
| - shape = first_shape;
|
| }
|
| break;
|
| }
|
| @@ -4128,7 +4096,7 @@
|
| ASSERT(index >= 0 && index < this->length());
|
| // Delegate to the buffer string.
|
| String* underlying = buffer();
|
| - return underlying->Get(StringShape(underlying), start() + index);
|
| + return underlying->Get(start() + index);
|
| }
|
|
|
|
|
| @@ -4192,9 +4160,8 @@
|
|
|
| template <typename IteratorA>
|
| static inline bool CompareStringContentsPartial(IteratorA* ia, String* b) {
|
| - StringShape b_shape(b);
|
| - if (b->IsFlat(b_shape)) {
|
| - if (b_shape.IsAsciiRepresentation()) {
|
| + if (b->IsFlat()) {
|
| + if (StringShape(b).IsAsciiRepresentation()) {
|
| VectorIterator<char> ib(b->ToAsciiVector());
|
| return CompareStringContents(ia, &ib);
|
| } else {
|
| @@ -4211,12 +4178,10 @@
|
| static StringInputBuffer string_compare_buffer_a;
|
|
|
|
|
| -bool String::SlowEquals(StringShape this_shape,
|
| - String* other,
|
| - StringShape other_shape) {
|
| +bool String::SlowEquals(String* other) {
|
| // Fast check: negative check with lengths.
|
| - int len = length(this_shape);
|
| - if (len != other->length(other_shape)) return false;
|
| + int len = length();
|
| + if (len != other->length()) return false;
|
| if (len == 0) return true;
|
|
|
| // Fast check: if hash code is computed for both strings
|
| @@ -4225,18 +4190,18 @@
|
| if (Hash() != other->Hash()) return false;
|
| }
|
|
|
| - if (this_shape.IsSequentialAscii() && other_shape.IsSequentialAscii()) {
|
| + if (StringShape(this).IsSequentialAscii() && StringShape(other).IsSequentialAscii()) {
|
| const char* str1 = SeqAsciiString::cast(this)->GetChars();
|
| const char* str2 = SeqAsciiString::cast(other)->GetChars();
|
| return CompareRawStringContents(Vector<const char>(str1, len),
|
| Vector<const char>(str2, len));
|
| }
|
|
|
| - if (this->IsFlat(this_shape)) {
|
| - if (this_shape.IsAsciiRepresentation()) {
|
| + if (this->IsFlat()) {
|
| + if (StringShape(this).IsAsciiRepresentation()) {
|
| Vector<const char> vec1 = this->ToAsciiVector();
|
| - if (other->IsFlat(other_shape)) {
|
| - if (other_shape.IsAsciiRepresentation()) {
|
| + if (other->IsFlat()) {
|
| + if (StringShape(other).IsAsciiRepresentation()) {
|
| Vector<const char> vec2 = other->ToAsciiVector();
|
| return CompareRawStringContents(vec1, vec2);
|
| } else {
|
| @@ -4251,8 +4216,8 @@
|
| }
|
| } else {
|
| Vector<const uc16> vec1 = this->ToUC16Vector();
|
| - if (other->IsFlat(other_shape)) {
|
| - if (other_shape.IsAsciiRepresentation()) {
|
| + if (other->IsFlat()) {
|
| + if (StringShape(other).IsAsciiRepresentation()) {
|
| VectorIterator<uc16> buf1(vec1);
|
| VectorIterator<char> ib(other->ToAsciiVector());
|
| return CompareStringContents(&buf1, &ib);
|
| @@ -4302,14 +4267,13 @@
|
|
|
|
|
| bool String::IsEqualTo(Vector<const char> str) {
|
| - StringShape this_shape(this);
|
| - int slen = length(this_shape);
|
| + int slen = length();
|
| Access<Scanner::Utf8Decoder> decoder(Scanner::utf8_decoder());
|
| decoder->Reset(str.start(), str.length());
|
| int i;
|
| for (i = 0; i < slen && decoder->has_more(); i++) {
|
| uc32 r = decoder->GetNext();
|
| - if (Get(this_shape, i) != r) return false;
|
| + if (Get(i) != r) return false;
|
| }
|
| return i == slen && !decoder->has_more();
|
| }
|
| @@ -4363,8 +4327,7 @@
|
|
|
|
|
| bool String::SlowAsArrayIndex(uint32_t* index) {
|
| - StringShape shape(this);
|
| - if (length(shape) <= kMaxCachedArrayIndexLength) {
|
| + if (length() <= kMaxCachedArrayIndexLength) {
|
| Hash(); // force computation of hash code
|
| uint32_t field = length_field();
|
| if ((field & kIsArrayIndexMask) == 0) return false;
|
| @@ -4372,7 +4335,7 @@
|
| return true;
|
| } else {
|
| StringInputBuffer buffer(this);
|
| - return ComputeArrayIndex(&buffer, index, length(shape));
|
| + return ComputeArrayIndex(&buffer, index, length());
|
| }
|
| }
|
|
|
| @@ -4433,9 +4396,8 @@
|
|
|
|
|
| Object* String::Slice(int start, int end) {
|
| - StringShape shape(this);
|
| - if (start == 0 && end == length(shape)) return this;
|
| - if (shape.representation_tag() == kSlicedStringTag) {
|
| + if (start == 0 && end == length()) return this;
|
| + if (StringShape(this).representation_tag() == kSlicedStringTag) {
|
| // Translate slices of a SlicedString into slices of the
|
| // underlying string buffer.
|
| SlicedString* str = SlicedString::cast(this);
|
| @@ -4459,14 +4421,13 @@
|
| // if Heap::AllocateSlicedString actually returned a SlicedString. It will
|
| // return flat strings for small slices for efficiency reasons.
|
| String* answer = String::cast(result);
|
| - StringShape answer_shape(answer);
|
| - if (answer_shape.IsSliced() &&
|
| - shape.representation_tag() == kConsStringTag) {
|
| - TryFlatten(shape);
|
| + if (StringShape(answer).IsSliced() &&
|
| + StringShape(this).representation_tag() == kConsStringTag) {
|
| + TryFlatten();
|
| // If the flatten succeeded we might as well make the sliced string point
|
| // to the flat string rather than the cons string.
|
| String* second = ConsString::cast(this)->second();
|
| - if (second->length(StringShape(second)) == 0) {
|
| + if (second->length() == 0) {
|
| SlicedString::cast(answer)->set_buffer(ConsString::cast(this)->first());
|
| }
|
| }
|
| @@ -4475,10 +4436,9 @@
|
|
|
|
|
| void String::PrintOn(FILE* file) {
|
| - StringShape shape(this);
|
| - int length = this->length(shape);
|
| + int length = this->length();
|
| for (int i = 0; i < length; i++) {
|
| - fprintf(file, "%c", Get(shape, i));
|
| + fprintf(file, "%c", Get(i));
|
| }
|
| }
|
|
|
| @@ -6034,13 +5994,12 @@
|
| Object* val = JSValue::cast(this)->value();
|
| if (val->IsString()) {
|
| String* str = String::cast(val);
|
| - StringShape shape(str);
|
| if (storage) {
|
| - for (int i = 0; i < str->length(shape); i++) {
|
| + for (int i = 0; i < str->length(); i++) {
|
| storage->set(counter + i, Smi::FromInt(i), SKIP_WRITE_BARRIER);
|
| }
|
| }
|
| - counter += str->length(shape);
|
| + counter += str->length();
|
| }
|
| }
|
| ASSERT(!storage || storage->length() == counter);
|
| @@ -6288,10 +6247,9 @@
|
| Object* GetObject() {
|
| // If the string is a cons string, attempt to flatten it so that
|
| // symbols will most often be flat strings.
|
| - StringShape shape(string_);
|
| - if (shape.IsCons()) {
|
| + if (StringShape(string_).IsCons()) {
|
| ConsString* cons_string = ConsString::cast(string_);
|
| - cons_string->TryFlatten(shape);
|
| + cons_string->TryFlatten();
|
| if (cons_string->second() == Heap::empty_string()) {
|
| string_ = cons_string->first();
|
| }
|
|
|