From a9faf21f0e35c552d21cadda0e96f515ee9537ee Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Wed, 23 Mar 2016 15:43:33 +0100 Subject: [PATCH] rgw: improve const-correctness of RGWHTTPArgs. Signed-off-by: Radoslaw Zarzynski --- src/rgw/rgw_common.cc | 7 +++---- src/rgw/rgw_common.h | 16 +++++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 4bc3b015929db..b14b26c6de48d 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -783,11 +783,10 @@ void RGWHTTPArgs::append(const string& name, const string& val) } } -string& RGWHTTPArgs::get(const string& name, bool *exists) +const string& RGWHTTPArgs::get(const string& name, bool *exists) const { - map::iterator iter; - iter = val_map.find(name); - bool e = (iter != val_map.end()); + auto iter = val_map.find(name); + bool e = (iter != std::end(val_map)); if (exists) *exists = e; if (e) diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 11948c5b3c7f7..d95eea4fad98a 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -304,7 +304,7 @@ class RGWHTTPArgs int parse(); void append(const string& name, const string& val); /** Get the value for a specific argument parameter */ - string& get(const string& name, bool *exists = NULL); + const string& get(const string& name, bool *exists = NULL) const; int get_bool(const string& name, bool *val, bool *exists); int get_bool(const char *name, bool *val, bool *exists); void get_bool(const char *name, bool *val, bool def_val); @@ -313,22 +313,20 @@ class RGWHTTPArgs string sys_get(const string& name, bool *exists = nullptr); /** see if a parameter is contained in this RGWHTTPArgs */ - bool exists(const char *name) { - map::iterator iter = val_map.find(name); - return (iter != val_map.end()); + bool exists(const char *name) const { + return (val_map.find(name) != std::end(val_map)); } - bool sub_resource_exists(const char *name) { - map::iterator iter = sub_resources.find(name); - return (iter != sub_resources.end()); + bool sub_resource_exists(const char *name) const { + return (sub_resources.find(name) != std::end(sub_resources)); } map& get_params() { return val_map; } map& get_sub_resources() { return sub_resources; } - unsigned get_num_params() { + unsigned get_num_params() const { return val_map.size(); } - bool has_response_modifier() { + bool has_response_modifier() const { return has_resp_modifier; } void set_system() { /* make all system params visible */ -- 2.39.5