Some encoding functions (in particular, encoders for strings) right now
use two encode() calls, one for data length and one for actual data. This
change makes encoding functions aware of the data length and don't call
second encode if there's no actual data to encode - conditional branch is
faster than function call.
Signed-off-by: Piotr Dałek <piotr.dalek@ts.fujitsu.com>
{
__u32 len = s.length();
encode(len, bl);
- bl.append(s.data(), len);
+ if (len)
+ bl.append(s.data(), len);
}
inline void decode(std::string& s, bufferlist::iterator& p)
{
{
__u32 len = strlen(s);
encode(len, bl);
- bl.append(s, len);
+ if (len)
+ bl.append(s, len);
}