{
create_buffers();
- if(!batches.empty() && batches.back().can_append(b.get_type()))
+ if(batches.empty())
+ {
+ batches.push_back(b);
+ batches.back().use_buffer(ibuf);
+ }
+ else if(batches.back().can_append(b.get_type()))
batches.back().append(b);
else
{
bool reallocate = (batches.size()==batches.capacity());
- if(reallocate && ibuf)
+ if(reallocate)
{
for(vector<Batch>::iterator i=batches.end(); i!=batches.begin(); )
(--i)->use_buffer(0);
}
- Batch *prev = (batches.empty() ? 0 : &batches.back());
+ Batch *prev = &batches.back();
batches.push_back(b);
- if(ibuf)
+ if(reallocate)
{
- if(reallocate)
+ prev = 0;
+ for(vector<Batch>::iterator i=batches.begin(); i!=batches.end(); ++i)
{
- prev = 0;
- for(vector<Batch>::iterator i=batches.begin(); i!=batches.end(); ++i)
- {
- i->use_buffer(ibuf, prev);
- prev = &*i;
- }
+ i->use_buffer(ibuf, prev);
+ prev = &*i;
}
- else
- batches.back().use_buffer(ibuf, prev);
}
+ else
+ batches.back().use_buffer(ibuf, prev);
}
}