Well you've already made partialFlush static, so it's a obvious
contender for a a member variable. The other two could be parameters.
bool
SendBuffer::ending (uint32_t all, uint32_t numWritten)
{
buf_.erase(buf_.begin(), buf_.begin() + numWritten);
if (numWritten == all) return true;
partialFlush_ = true;
return false;
}
bool
SendBuffer::Flush ()
{
uint32_t const all = buf_.size();
uint32_t numWritten = 0;
if (partialFlush_) {
::neolib::segmented_array<unsigned char, chunk_size>::segment&
segment =
segmented_iterator<unsigned char,
chunk_size>(buf_.begin()).segment();
numWritten = Write(sock_, &buf_[0], segment.size());
if (numWritten < segment.size()) return ending(all, numWritten);
partialFlush_ = false;
}
int32_t const chunks = (all - numWritten) / chunk_size;
for (int32_t ii = 0; ii < chunks; ++ii) {
uint32_t bytes = Write(sock_, &buf_[numWritten], chunk_size);
numWritten += bytes;
if (bytes < chunk_size) return ending(all, numWritten);
}
if (numWritten < all) {
numWritten += Write(sock_, &buf_[numWritten], all - numWritten);
}
return ending(all, numWritten);
}
The .o file is 48 bytes bigger in this form when using
g++ 4.5.1 and -O3. I'm not sure this is a step in the
right direction.