common/hobject: use string::append() to avoid temp object

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2017-04-28 14:13:53 +08:00
parent 8f2537ff30
commit c6337b4138

View File

@ -75,7 +75,7 @@ string hobject_t::to_str() const
char snap_with_hash[1000];
char *t = snap_with_hash;
char *end = t + sizeof(snap_with_hash);
const char *end = t + sizeof(snap_with_hash);
uint64_t poolid(pool);
t += snprintf(t, end - t, "%.*llX", 16, (long long unsigned)poolid);
@ -90,7 +90,7 @@ string hobject_t::to_str() const
else
t += snprintf(t, end - t, ".%llx", (long long unsigned)snap);
out += string(snap_with_hash);
out.append(snap_with_hash, t);
out.push_back('.');
append_escaped(oid.name, &out);