]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: some code cleanup
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 4 Sep 2014 21:40:49 +0000 (14:40 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 16 Jan 2015 22:33:42 +0000 (14:33 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rados.cc

index d2ae727eed1b3da2d3d13231cc0e1741464d3653..9fc416b0ba2eaeefdcf96ec71837592e3dd77494 100644 (file)
@@ -5259,6 +5259,18 @@ int RGWRados::olh_init_modification(rgw_obj& obj, string *tag)
   return 0;
 }
 
+static void filter_attrset(map<string, bufferlist>& unfiltered_attrset, const string& check_prefix,
+                           map<string, bufferlist> *attrset)
+{
+  map<string, bufferlist>::iterator iter;
+  for (iter = unfiltered_attrset.lower_bound(check_prefix);
+       iter != unfiltered_attrset.end(); ++iter) {
+    if (!str_startswith(iter->first, check_prefix))
+      break;
+    (*attrset)[iter->first] = iter->second;
+  }
+}
+
 int RGWRados::get_olh(rgw_obj& obj, RGWOLHInfo *olh)
 {
   map<string, bufferlist> unfiltered_attrset;
@@ -5273,16 +5285,10 @@ int RGWRados::get_olh(rgw_obj& obj, RGWOLHInfo *olh)
     return r;
   }
   map<string, bufferlist> attrset;
-  map<string, bufferlist>::iterator iter;
-  string check_prefix = RGW_ATTR_OLH_PREFIX;
-  for (iter = unfiltered_attrset.lower_bound(check_prefix);
-       iter != unfiltered_attrset.end(); ++iter) {
-    if (!str_startswith(iter->first, check_prefix))
-      break;
-    attrset[iter->first] = iter->second;
-  }
 
-  iter = attrset.find(RGW_ATTR_OLH_INFO);
+  filter_attrset(unfiltered_attrset, RGW_ATTR_OLH_PREFIX, &attrset);
+
+  map<string, bufferlist>::iterator iter = attrset.find(RGW_ATTR_OLH_INFO);
   if (iter == attrset.end()) { /* not an olh */
     return -EINVAL;
   }
@@ -5337,16 +5343,9 @@ int RGWRados::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime,
     return r;
 
   map<string, bufferlist> attrset;
-  map<string, bufferlist>::iterator iter;
-  string check_prefix = RGW_ATTR_PREFIX;
-  for (iter = unfiltered_attrset.lower_bound(check_prefix);
-       iter != unfiltered_attrset.end(); ++iter) {
-    if (!str_startswith(iter->first, check_prefix))
-      break;
-    attrset[iter->first] = iter->second;
-  }
+  filter_attrset(unfiltered_attrset, RGW_ATTR_PREFIX, &attrset);
 
-  iter = attrset.find(RGW_ATTR_OLH_INFO);
+  map<string, bufferlist>::iterator iter = attrset.find(RGW_ATTR_OLH_INFO);
   if (iter != attrset.end()) {
 #warning implment me
   }