Skip to content

Commit 7ad76f9

Browse files
Michael Poggyfacebook-github-bot
authored andcommitted
Avoid copying FB303's get(Regex|Selected)Counters result map in BaseService.h
Summary: ## Context I was glancing at the [Container Copies](https://www.internalfb.com/intern/unidash/dashboard/bad_patterns/container_copies/?dimensional_context_300674582190283=%7B%22macros%22%3A[]%2C%22operators%22%3A[]%2C%22movingAggregation%22%3A%22DEFAULT%22%2C%22granularity%22%3A%22DEFAULT%22%2C%22limit%22%3A5%7D) Bad Patterns dashboard and this one stood out to me. This is a locally defined `std::map` that we don't seem to use beyond the `result` call where I've added `std::move`. Similar optimizations were performed in D55817430, where the underlying callback was made to take arguments by value. This must have been missed. Seems like a small ([~14kW](https://fburl.com/scuba/strobelight_services/whv43t10)), but easy win. Reviewed By: yfeldblum Differential Revision: D68642453 fbshipit-source-id: 3d7687ae0d2c9a57304ea86c7b03538ee380f957
1 parent 3a66ed4 commit 7ad76f9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fb303/BaseService.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class BaseService : virtual public cpp2::BaseServiceSvIf {
233233
}
234234
addCountersAvailableToResponse(reqCtx, numAvailable);
235235
}
236-
callback_->result(res);
236+
callback_->result(std::move(res));
237237
} catch (...) {
238238
callback_->exception(std::current_exception());
239239
}
@@ -273,7 +273,7 @@ class BaseService : virtual public cpp2::BaseServiceSvIf {
273273
}
274274
addCountersAvailableToResponse(reqCtx, numAvailable);
275275
}
276-
callback_->result(res);
276+
callback_->result(std::move(res));
277277
} catch (...) {
278278
callback_->exception(std::current_exception());
279279
}
@@ -313,7 +313,7 @@ class BaseService : virtual public cpp2::BaseServiceSvIf {
313313
}
314314
addCountersAvailableToResponse(reqCtx, numAvailable);
315315
}
316-
callback_->result(res);
316+
callback_->result(std::move(res));
317317
} catch (...) {
318318
callback_->exception(std::current_exception());
319319
}

0 commit comments

Comments
 (0)