From e448c4eb7fcd0700143aff4c69a34692e8b0072e Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Sat, 19 Dec 2015 23:35:47 -0500 Subject: [PATCH] librgw: use string_ref remove_prefix Save a few cycles over re-assigning a string_ref suffix substring to itself. Signed-off-by: Matt Benjamin --- src/rgw/rgw_file.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 2c902306273..c25231abe8f 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -889,7 +889,7 @@ public: size_t last_del = sref.find_last_of('/'); if (last_del != string::npos) - sref = sref.substr(last_del+1); + sref.remove_prefix(last_del+1); /* if we find a trailing slash in a -listing- the parent is an @@ -916,6 +916,9 @@ public: << " iter second: " << iter.second << std::endl; + /* it's safest to modify the element in place--a suffix-modifying + * string_ref operation is problematic since ULP rgw_file callers + * will ultimately need a c-string */ if (iter.first.back() == '/') const_cast(iter.first).pop_back(); @@ -923,7 +926,7 @@ public: size_t last_del = sref.find_last_of('/'); if (last_del != string::npos) - sref = sref.substr(last_del+1); + sref.remove_prefix(last_del+1); lsubdout(cct, rgw, 15) << "RGWReaddirRequest " << __func__ << " " -- 2.39.5