mirror of
https://github.com/ceph/ceph
synced 2025-02-23 02:57:21 +00:00
common/buffers: check _num directly in list::c_str()
no need to create temporary iterator for comparing it with cend(). Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
5bb4d37410
commit
d6334e5c43
@ -1519,16 +1519,18 @@ static ceph::spinlock debug_lock;
|
||||
*/
|
||||
char *buffer::list::c_str()
|
||||
{
|
||||
if (_buffers.empty())
|
||||
return 0; // no buffers
|
||||
|
||||
auto iter = std::cbegin(_buffers);
|
||||
++iter;
|
||||
|
||||
if (iter != std::cend(_buffers)) {
|
||||
switch (get_num_buffers()) {
|
||||
case 0:
|
||||
// no buffers
|
||||
return nullptr;
|
||||
case 1:
|
||||
// good, we're already contiguous.
|
||||
break;
|
||||
default:
|
||||
rebuild();
|
||||
break;
|
||||
}
|
||||
return _buffers.front().c_str(); // good, we're already contiguous.
|
||||
return _buffers.front().c_str();
|
||||
}
|
||||
|
||||
string buffer::list::to_str() const {
|
||||
|
Loading…
Reference in New Issue
Block a user