From c6337b41385d7d0431e664a5db5c3ca64963ce5c Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 28 Apr 2017 14:13:53 +0800 Subject: [PATCH] common/hobject: use string::append() to avoid temp object Signed-off-by: Kefu Chai --- src/common/hobject.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/hobject.cc b/src/common/hobject.cc index a965c87d622..dffd471b7f9 100644 --- a/src/common/hobject.cc +++ b/src/common/hobject.cc @@ -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);