Commit d0875482 authored by Ian Barber's avatar Ian Barber

Merge pull request #338 from hurtonm/code_cleanup

Simplify encoder's loop
parents 80e8baaf 64194394
......@@ -69,11 +69,11 @@ namespace zmq
unsigned char *buffer = !*data_ ? buf : *data_;
size_t buffersize = !*data_ ? bufsize : *size_;
size_t pos = 0;
if (offset_)
*offset_ = -1;
while (true) {
size_t pos = 0;
while (pos < buffersize) {
// If there are no more data to return, run the state machine.
// If there are still no data, return what we already have
......@@ -85,11 +85,8 @@ namespace zmq
if (offset_ && *offset_ == -1)
*offset_ = static_cast <int> (pos);
if (!(static_cast <T*> (this)->*next) ()) {
*data_ = buffer;
*size_ = pos;
return;
}
if (!(static_cast <T*> (this)->*next) ())
break;
}
// If there are no data in the buffer yet and we are able to
......@@ -116,12 +113,10 @@ namespace zmq
pos += to_copy;
write_pos += to_copy;
to_write -= to_copy;
if (pos == buffersize) {
}
*data_ = buffer;
*size_ = pos;
return;
}
}
}
protected:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment