]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: pre-assign req->op (as self), avoid dynamic_cast
authorMatt Benjamin <mbenjamin@redhat.com>
Wed, 30 Sep 2015 14:00:14 +0000 (10:00 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 16:58:06 +0000 (11:58 -0500)
It would be nice to have some compile-type assistance w/the
dual RGWOp & RGWLibRequest boilerplate.

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

index 12bfff14b0314c0247366ee25d89e9c94cdd4b65..604f141493e024e3ba85936ec514a596681250cc 100644 (file)
@@ -393,8 +393,9 @@ int process_request(RGWRados* store, RGWREST* rest, RGWRequest* base_req,
 
   req->log_format(s, "initializing for trans_id = %s", s->trans_id.c_str());
 
-  RGWOp *op = dynamic_cast<RGWOp*>(req);
-  req->op = op; // XXX but we can do this in the ctor!
+  /* XXX the following works, but we shouldn't need to pay for a
+   * dynamic cast */
+  RGWOp *op = reinterpret_cast<RGWOp*>(req); // req->op is already correct
 
   bool should_log = true;
 
index 8f96ce716eafd58c2c50a9c758fdf0aac06f1427..83cfe234b887477f25e8dc9beaa2fc74d8a80a82 100644 (file)
@@ -299,7 +299,8 @@ public:
   RGWListBucketsRequest(uint64_t _req_id,
                        rgw_readdir_cb _rcb, void* _cb_arg, uint64_t _offset)
     : RGWLibRequest(_req_id), offset(_offset), cb_arg(_cb_arg), rcb(_rcb) {
-    // nothing
+    // req->op = op
+    op = this;
   }
 
   int operator()(const std::string& name, const std::string& marker) {