From: Robin H. Johnson Date: Wed, 15 Apr 2015 01:30:16 +0000 (-0700) Subject: rgw: Speed up the building of valid de-duplicated hostnames for regions. X-Git-Tag: v9.0.1~130^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=044060fd4010fdc799612849882da14b33c1cf2f;p=ceph.git rgw: Speed up the building of valid de-duplicated hostnames for regions. Signed-off-by: Robin H. Johnson --- diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index 4dc160a6cec..169b5baf557 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -161,7 +161,8 @@ string camelcase_dash_http_attr(const string& orig) return string(buf); } -static list hostnames_list; +/* avoid duplicate hostnames in hostnames list */ +static set hostnames_set; void rgw_rest_init(CephContext *cct, RGWRegion& region) { @@ -193,18 +194,10 @@ void rgw_rest_init(CephContext *cct, RGWRegion& region) http_status_names[h->code] = h->name; } - /* avoid duplicate hostnames in hostnames list */ - map hostnames_map; if (!cct->_conf->rgw_dns_name.empty()) { - hostnames_map[cct->_conf->rgw_dns_name] = true; - } - for (list::iterator iter = region.hostnames.begin(); iter != region.hostnames.end(); ++iter) { - hostnames_map[*iter] = true; - } - - for (map::iterator iter = hostnames_map.begin(); iter != hostnames_map.end(); ++iter) { - hostnames_list.push_back(iter->first); + hostnames_set.insert(cct->_conf->rgw_dns_name); } + hostnames_set.insert(region.hostnames.begin(), region.hostnames.end()); } static bool str_ends_with(const string& s, const string& suffix, size_t *pos) @@ -224,8 +217,8 @@ static bool str_ends_with(const string& s, const string& suffix, size_t *pos) static bool rgw_find_host_in_domains(const string& host, string *domain, string *subdomain) { - list::iterator iter; - for (iter = hostnames_list.begin(); iter != hostnames_list.end(); ++iter) { + set::iterator iter; + for (iter = hostnames_set.begin(); iter != hostnames_set.end(); ++iter) { size_t pos; if (!str_ends_with(host, *iter, &pos)) continue;