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

Unified Diff: src/v8conversions.cc

Issue 11727003: Reland r13275 and 13276 (Remove most uses of StringInputBuffer). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 12 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/string-stream.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8conversions.cc
diff --git a/src/v8conversions.cc b/src/v8conversions.cc
index c6755d593cec63db62003140a5af69a752cbe56b..26a4868a8d2d7b7fa2ce544e239cfdb79e46be46 100644
--- a/src/v8conversions.cc
+++ b/src/v8conversions.cc
@@ -41,40 +41,40 @@ namespace internal {
namespace {
-// C++-style iterator adaptor for StringInputBuffer
+// C++-style iterator adaptor for StringCharacterStream
// (unlike C++ iterators the end-marker has different type).
-class StringInputBufferIterator {
+class StringCharacterStreamIterator {
public:
class EndMarker {};
- explicit StringInputBufferIterator(StringInputBuffer* buffer);
+ explicit StringCharacterStreamIterator(StringCharacterStream* stream);
- int operator*() const;
+ uint16_t operator*() const;
void operator++();
bool operator==(EndMarker const&) const { return end_; }
bool operator!=(EndMarker const& m) const { return !end_; }
private:
- StringInputBuffer* const buffer_;
- int current_;
+ StringCharacterStream* const stream_;
+ uint16_t current_;
bool end_;
};
-StringInputBufferIterator::StringInputBufferIterator(
- StringInputBuffer* buffer) : buffer_(buffer) {
+StringCharacterStreamIterator::StringCharacterStreamIterator(
+ StringCharacterStream* stream) : stream_(stream) {
++(*this);
}
-int StringInputBufferIterator::operator*() const {
+uint16_t StringCharacterStreamIterator::operator*() const {
return current_;
}
-void StringInputBufferIterator::operator++() {
- end_ = !buffer_->has_more();
+void StringCharacterStreamIterator::operator++() {
+ end_ = !stream_->HasMore();
if (!end_) {
- current_ = buffer_->GetNext();
+ current_ = stream_->GetNext();
}
}
} // End anonymous namespace.
@@ -83,6 +83,7 @@ void StringInputBufferIterator::operator++() {
double StringToDouble(UnicodeCache* unicode_cache,
String* str, int flags, double empty_string_val) {
StringShape shape(str);
+ // TODO(dcarney): Use a Visitor here.
if (shape.IsSequentialAscii()) {
const char* begin = SeqOneByteString::cast(str)->GetChars();
const char* end = begin + str->length();
@@ -94,10 +95,11 @@ double StringToDouble(UnicodeCache* unicode_cache,
return InternalStringToDouble(unicode_cache, begin, end, flags,
empty_string_val);
} else {
- StringInputBuffer buffer(str);
+ ConsStringIteratorOp op;
+ StringCharacterStream stream(str, &op);
return InternalStringToDouble(unicode_cache,
- StringInputBufferIterator(&buffer),
- StringInputBufferIterator::EndMarker(),
+ StringCharacterStreamIterator(&stream),
+ StringCharacterStreamIterator::EndMarker(),
flags,
empty_string_val);
}
@@ -108,6 +110,7 @@ double StringToInt(UnicodeCache* unicode_cache,
String* str,
int radix) {
StringShape shape(str);
+ // TODO(dcarney): Use a Visitor here.
if (shape.IsSequentialAscii()) {
const char* begin = SeqOneByteString::cast(str)->GetChars();
const char* end = begin + str->length();
@@ -117,10 +120,11 @@ double StringToInt(UnicodeCache* unicode_cache,
const uc16* end = begin + str->length();
return InternalStringToInt(unicode_cache, begin, end, radix);
} else {
- StringInputBuffer buffer(str);
+ ConsStringIteratorOp op;
+ StringCharacterStream stream(str, &op);
return InternalStringToInt(unicode_cache,
- StringInputBufferIterator(&buffer),
- StringInputBufferIterator::EndMarker(),
+ StringCharacterStreamIterator(&stream),
+ StringCharacterStreamIterator::EndMarker(),
radix);
}
}
« no previous file with comments | « src/string-stream.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698