make bufferlist::c_str() skip rebuild when it isn't necessary
The ceph_msg_header2 on the other hand, the bufferlist comes from the segment data, which is also contiguous, but splicing out the segment crc causes the bufferlist to be composed of two buffers, the other one being an empty carriage.
So ceph_msg_header2 always have to be rebuilt, while the preamble and the epilogue do not.
I wonder if either `splice()` or `rebuild()` should be made smarter. From a `bufferlist` user POV, a splice from the end of the contiguous buffer leading to `c_str()` ending up in `rebuild()` and actually reallocating is counter-intuitive.
I definitely think that `c_str()` can be made a little smarter to detect more cases that do not require rebuild.
Given that, perhaps it's a better approach to always prefer `reinterpret_cast`, and use `ceph::decode` only as a fallback.
In that case, this commit [https://github.com/ceph/ceph/pull/42280] will be reverted.
#1 Updated by Radoslaw Zarzynski 5 months ago
- Status changed from New to In Progress