librgw: pre-assign req->op (as self), avoid dynamic_cast

It would be nice to have some compile-type assistance w/the
dual RGWOp & RGWLibRequest boilerplate.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
This commit is contained in:
Matt Benjamin 2015-09-30 10:00:14 -04:00
parent f4994c84b1
commit 7e8ecc58ac
2 changed files with 5 additions and 3 deletions

View 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;

View 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) {