Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: src/objects-inl.h

Issue 11638037: Remove most uses of StringInputBuffer (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: last patch set had upload error Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2827 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 // Verify output. 2838 // Verify output.
2839 ASSERT(string == NULL || offset_out == 0); 2839 ASSERT(string == NULL || offset_out == 0);
2840 ASSERT(string == NULL || 2840 ASSERT(string == NULL ||
2841 *length_out == static_cast<unsigned>(string->length())); 2841 *length_out == static_cast<unsigned>(string->length()));
2842 ASSERT(string == NULL || *type_out == string->map()->instance_type()); 2842 ASSERT(string == NULL || *type_out == string->map()->instance_type());
2843 return string; 2843 return string;
2844 } 2844 }
2845 2845
2846 2846
2847 uint16_t StringCharacterStream::GetNext() { 2847 uint16_t StringCharacterStream::GetNext() {
2848 ASSERT((buffer8_ == NULL && end_ == NULL) || buffer8_ < end_); 2848 ASSERT(buffer8_ != NULL && end_ != NULL);
2849 // Advance cursor if needed.
2850 // TODO(dcarney): Ensure uses of the api call HasMore first and avoid this.
2851 if (buffer8_ == end_) HasMore();
2852 ASSERT(buffer8_ < end_);
2849 return is_one_byte_ ? *buffer8_++ : *buffer16_++; 2853 return is_one_byte_ ? *buffer8_++ : *buffer16_++;
2850 } 2854 }
2851 2855
2852 2856
2853 StringCharacterStream::StringCharacterStream( 2857 StringCharacterStream::StringCharacterStream(String* string,
2854 String* string, unsigned offset, ConsStringIteratorOp* op) 2858 ConsStringIteratorOp* op)
2855 : is_one_byte_(false), 2859 : op_(op) {
Yang 2012/12/21 09:21:48 Please initialize is_one_byte_, some compilers whi
2856 buffer8_(NULL), 2860 Reset(string);
2857 end_(NULL),
2858 op_(op) {
2859 op->Reset();
2860 int32_t type = string->map()->instance_type();
2861 unsigned length = string->length();
2862 String::Visit(string, offset, *this, *op, type, length);
2863 } 2861 }
2864 2862
2865 2863
2864 StringCharacterStream::StringCharacterStream(String* string,
2865 unsigned offset,
2866 ConsStringIteratorOp* op)
Yang 2012/12/21 09:21:48 Wouldn't it be cleaner to put offset as last and o
2867 : op_(op) {
2868 Reset(string, offset);
2869 }
2870
2871
2872 void StringCharacterStream::Reset(String* string, unsigned offset) {
2873 op_->Reset();
2874 buffer8_ = NULL;
2875 end_ = NULL;
2876 int32_t type = string->map()->instance_type();
2877 unsigned length = string->length();
2878 String::Visit(string, offset, *this, *op_, type, length);
2879 }
2880
2881
2866 bool StringCharacterStream::HasMore() { 2882 bool StringCharacterStream::HasMore() {
2867 if (buffer8_ != end_) return true; 2883 if (buffer8_ != end_) return true;
2868 if (!op_->HasMore()) return false; 2884 if (!op_->HasMore()) return false;
2869 unsigned length; 2885 unsigned length;
2870 int32_t type; 2886 int32_t type;
2871 String* string = op_->ContinueOperation(&type, &length); 2887 String* string = op_->ContinueOperation(&type, &length);
2872 if (string == NULL) return false; 2888 if (string == NULL) return false;
2873 ASSERT(!string->IsConsString()); 2889 ASSERT(!string->IsConsString());
2874 ASSERT(string->length() != 0); 2890 ASSERT(string->length() != 0);
2875 ConsStringNullOp null_op; 2891 ConsStringNullOp null_op;
(...skipping 2895 matching lines...) Expand 10 before | Expand all | Expand 10 after
5771 #undef WRITE_UINT32_FIELD 5787 #undef WRITE_UINT32_FIELD
5772 #undef READ_SHORT_FIELD 5788 #undef READ_SHORT_FIELD
5773 #undef WRITE_SHORT_FIELD 5789 #undef WRITE_SHORT_FIELD
5774 #undef READ_BYTE_FIELD 5790 #undef READ_BYTE_FIELD
5775 #undef WRITE_BYTE_FIELD 5791 #undef WRITE_BYTE_FIELD
5776 5792
5777 5793
5778 } } // namespace v8::internal 5794 } } // namespace v8::internal
5779 5795
5780 #endif // V8_OBJECTS_INL_H_ 5796 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698