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

Unified Diff: src/unicode-inl.h

Issue 11727004: Remove InputBuffer (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/unicode.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/unicode-inl.h
diff --git a/src/unicode-inl.h b/src/unicode-inl.h
index 8ceefe8f4fc34e51447516b78992e1f3d7ddcc62..c3a00ed710eb1da94ea8e2fe5e56cadd4db9f3be 100644
--- a/src/unicode-inl.h
+++ b/src/unicode-inl.h
@@ -137,109 +137,6 @@ unsigned Utf8::Length(uchar c, int previous) {
}
}
-uchar CharacterStream::GetNext() {
- uchar result = DecodeCharacter(buffer_, &cursor_);
- if (remaining_ == 1) {
- cursor_ = 0;
- FillBuffer();
- } else {
- remaining_--;
- }
- ASSERT(BoundsCheck(cursor_));
- return result;
-}
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define IF_LITTLE(expr) expr
-#define IF_BIG(expr) ((void) 0)
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#define IF_LITTLE(expr) ((void) 0)
-#define IF_BIG(expr) expr
-#else
-#warning Unknown byte ordering
-#endif
-
-bool CharacterStream::EncodeAsciiCharacter(uchar c, byte* buffer,
- unsigned capacity, unsigned& offset) {
- if (offset >= capacity) return false;
- buffer[offset] = c;
- offset += 1;
- return true;
-}
-
-bool CharacterStream::EncodeNonAsciiCharacter(uchar c, byte* buffer,
- unsigned capacity, unsigned& offset) {
- unsigned aligned = (offset + 0x3) & ~0x3;
- if ((aligned + sizeof(uchar)) > capacity)
- return false;
- if (offset == aligned) {
- IF_LITTLE(*reinterpret_cast<uchar*>(buffer + aligned) = (c << 8) | 0x80);
- IF_BIG(*reinterpret_cast<uchar*>(buffer + aligned) = c | (1 << 31));
- } else {
- buffer[offset] = 0x80;
- IF_LITTLE(*reinterpret_cast<uchar*>(buffer + aligned) = c << 8);
- IF_BIG(*reinterpret_cast<uchar*>(buffer + aligned) = c);
- }
- offset = aligned + sizeof(uchar);
- return true;
-}
-
-bool CharacterStream::EncodeCharacter(uchar c, byte* buffer, unsigned capacity,
- unsigned& offset) {
- if (c <= Utf8::kMaxOneByteChar) {
- return EncodeAsciiCharacter(c, buffer, capacity, offset);
- } else {
- return EncodeNonAsciiCharacter(c, buffer, capacity, offset);
- }
-}
-
-uchar CharacterStream::DecodeCharacter(const byte* buffer, unsigned* offset) {
- byte b = buffer[*offset];
- if (b <= Utf8::kMaxOneByteChar) {
- (*offset)++;
- return b;
- } else {
- unsigned aligned = (*offset + 0x3) & ~0x3;
- *offset = aligned + sizeof(uchar);
- IF_LITTLE(return *reinterpret_cast<const uchar*>(buffer + aligned) >> 8);
- IF_BIG(return *reinterpret_cast<const uchar*>(buffer + aligned) &
- ~(1 << 31));
- }
-}
-
-#undef IF_LITTLE
-#undef IF_BIG
-
-template <class R, class I, unsigned s>
-void InputBuffer<R, I, s>::FillBuffer() {
- buffer_ = R::ReadBlock(input_, util_buffer_, s, &remaining_, &offset_);
-}
-
-template <class R, class I, unsigned s>
-void InputBuffer<R, I, s>::Rewind() {
- Reset(input_);
-}
-
-template <class R, class I, unsigned s>
-void InputBuffer<R, I, s>::Reset(unsigned position, I input) {
- input_ = input;
- remaining_ = 0;
- cursor_ = 0;
- offset_ = position;
- buffer_ = R::ReadBlock(input_, util_buffer_, s, &remaining_, &offset_);
-}
-
-template <class R, class I, unsigned s>
-void InputBuffer<R, I, s>::Reset(I input) {
- Reset(0, input);
-}
-
-template <class R, class I, unsigned s>
-void InputBuffer<R, I, s>::Seek(unsigned position) {
- offset_ = position;
- buffer_ = R::ReadBlock(input_, util_buffer_, s, &remaining_, &offset_);
-}
-
Utf8DecoderBase::Utf8DecoderBase()
: unbuffered_start_(NULL),
utf16_length_(0),
« no previous file with comments | « src/unicode.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698