Renamed UTFDecoder.buffer_ to decodedBuffer_ .

This commit is contained in:
Ferdinand Majerech 2014-07-22 02:18:26 +02:00
parent c296a6e790
commit 7d4df103a7

View file

@ -415,10 +415,10 @@ struct UTFBlockDecoder(size_t bufferSize_) if (bufferSize_ % 2 == 0)
// Used space (in items) in rawBuffer8_/rawBuffer16_. // Used space (in items) in rawBuffer8_/rawBuffer16_.
size_t rawUsed_; size_t rawUsed_;
// Space used by buffer_. // Space used by decodedBuffer_.
dchar[bufferSize_] bufferSpace_; dchar[bufferSize_] decodedBufferSpace_;
// Buffer of decoded, UTF-32 characters. This is a slice into bufferSpace_. // Buffer of decoded, UTF-32 characters. This is a slice into decodedBufferSpace_.
dchar[] buffer_; dchar[] decodedBuffer_;
public: public:
/// Construct a UTFBlockDecoder decoding data from a buffer. /// Construct a UTFBlockDecoder decoding data from a buffer.
@ -447,17 +447,17 @@ struct UTFBlockDecoder(size_t bufferSize_) if (bufferSize_ % 2 == 0)
/// Are we done decoding? /// Are we done decoding?
bool done() const pure @safe nothrow @nogc bool done() const pure @safe nothrow @nogc
{ {
return rawUsed_ == 0 && buffer_.length == 0 && available_ == 0; return rawUsed_ == 0 && decodedBuffer_.length == 0 && available_ == 0;
} }
/// Get next character. /// Get next character.
dchar getDChar() dchar getDChar()
@safe @safe
{ {
if(buffer_.length) if(decodedBuffer_.length)
{ {
const result = buffer_[0]; const result = decodedBuffer_[0];
buffer_ = buffer_[1 .. $]; decodedBuffer_ = decodedBuffer_[1 .. $];
return result; return result;
} }
@ -470,11 +470,11 @@ struct UTFBlockDecoder(size_t bufferSize_) if (bufferSize_ % 2 == 0)
const(dchar[]) getDChars(size_t maxChars = size_t.max) const(dchar[]) getDChars(size_t maxChars = size_t.max)
@safe @safe
{ {
if(buffer_.length) if(decodedBuffer_.length)
{ {
const slice = min(buffer_.length, maxChars); const slice = min(decodedBuffer_.length, maxChars);
const result = buffer_[0 .. slice]; const result = decodedBuffer_[0 .. slice];
buffer_ = buffer_[slice .. $]; decodedBuffer_ = decodedBuffer_[slice .. $];
return result; return result;
} }
@ -487,7 +487,7 @@ struct UTFBlockDecoder(size_t bufferSize_) if (bufferSize_ % 2 == 0)
// Read and decode characters from file and store them in the buffer. // Read and decode characters from file and store them in the buffer.
void updateBuffer() @trusted void updateBuffer() @trusted
{ {
assert(buffer_.length == 0, assert(decodedBuffer_.length == 0,
"updateBuffer can only be called when the buffer is empty"); "updateBuffer can only be called when the buffer is empty");
final switch(encoding_) final switch(encoding_)
{ {
@ -514,10 +514,10 @@ struct UTFBlockDecoder(size_t bufferSize_) if (bufferSize_ % 2 == 0)
const chars = min(bufferSize_ / 4, available_ / 4); const chars = min(bufferSize_ / 4, available_ / 4);
foreach(c; 0 .. chars) foreach(c; 0 .. chars)
{ {
stream_.read(bufferSpace_[c]); stream_.read(decodedBufferSpace_[c]);
available_ -= 4; available_ -= 4;
} }
buffer_ = bufferSpace_[0 .. chars]; decodedBuffer_ = decodedBufferSpace_[0 .. chars];
break; break;
} }
} }
@ -584,15 +584,15 @@ struct UTFBlockDecoder(size_t bufferSize_) if (bufferSize_ % 2 == 0)
const c = source[srcpos]; const c = source[srcpos];
if(c < 0x80) if(c < 0x80)
{ {
bufferSpace_[bufpos++] = c; decodedBufferSpace_[bufpos++] = c;
++srcpos; ++srcpos;
} }
else else
{ {
bufferSpace_[bufpos++] = decode(source, srcpos); decodedBufferSpace_[bufpos++] = decode(source, srcpos);
} }
} }
buffer_ = bufferSpace_[0 .. bufpos]; decodedBuffer_ = decodedBufferSpace_[0 .. bufpos];
} }
} }