From f98ca2d0ab2dc67aa9891ab443d1649dc0da1b60 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Mon, 3 Apr 2017 13:08:26 +0200 Subject: [PATCH] rgw: deduplicate variants of rgw_make_bucket_entry_name(). Signed-off-by: Radoslaw Zarzynski --- src/rgw/rgw_bucket.cc | 15 +++------------ src/rgw/rgw_bucket.h | 13 ++++++++----- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 8b2bc5f46df..37d20e88deb 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -49,18 +49,9 @@ void rgw_get_buckets_obj(const rgw_user& user_id, string& buckets_obj_id) * acceptable in bucket names and thus qualified buckets cannot conflict * with the legacy or S3 buckets. */ -void rgw_make_bucket_entry_name(const string& tenant_name, const string& bucket_name, string& bucket_entry) { - if (bucket_name.empty()) { - bucket_entry.clear(); - } else if (tenant_name.empty()) { - bucket_entry = bucket_name; - } else { - bucket_entry = tenant_name + "/" + bucket_name; - } -} - -string rgw_make_bucket_entry_name(const string& tenant_name, const string& bucket_name) { - string bucket_entry; +std::string rgw_make_bucket_entry_name(const std::string& tenant_name, + const std::string& bucket_name) { + std::string bucket_entry; if (bucket_name.empty()) { bucket_entry.clear(); diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index ebc419beb14..d5f469b2a0b 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -49,11 +49,14 @@ extern int rgw_bucket_delete_bucket_obj(RGWRados *store, extern int rgw_bucket_sync_user_stats(RGWRados *store, const rgw_user& user_id, const RGWBucketInfo& bucket_info); extern int rgw_bucket_sync_user_stats(RGWRados *store, const string& tenant_name, const string& bucket_name); -extern void rgw_make_bucket_entry_name(const string& tenant_name, - const string& bucket_name, - string& bucket_entry); -extern string rgw_make_bucket_entry_name(const string& tenant_name, - const string& bucket_name); +extern std::string rgw_make_bucket_entry_name(const std::string& tenant_name, + const std::string& bucket_name); +static inline void rgw_make_bucket_entry_name(const string& tenant_name, + const string& bucket_name, + std::string& bucket_entry) { + bucket_entry = rgw_make_bucket_entry_name(tenant_name, bucket_name); +} + extern void rgw_parse_url_bucket(const string& bucket, const string& auth_tenant, string &tenant_name, string &bucket_name);