]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: use string_ref remove_prefix
authorMatt Benjamin <mbenjamin@redhat.com>
Sun, 20 Dec 2015 04:35:47 +0000 (23:35 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:07:07 +0000 (12:07 -0500)
Save a few cycles over re-assigning a string_ref suffix substring
to itself.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.h

index 2c902306273d9def7ef418fc62d38b6af154c10a..c25231abe8f6acf089a3aa6280abfbd09de13a78 100644 (file)
@@ -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<std::string&>(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__ << " "