Skip to content

Commit

Permalink
Avoid copying FB303's get(Regex|Selected)Counters result map in BaseS…
Browse files Browse the repository at this point in the history
…ervice.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
  • Loading branch information
Michael Poggy authored and facebook-github-bot committed Jan 28, 2025
1 parent 3a66ed4 commit 7ad76f9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fb303/BaseService.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class BaseService : virtual public cpp2::BaseServiceSvIf {
}
addCountersAvailableToResponse(reqCtx, numAvailable);
}
callback_->result(res);
callback_->result(std::move(res));
} catch (...) {
callback_->exception(std::current_exception());
}
Expand Down Expand Up @@ -273,7 +273,7 @@ class BaseService : virtual public cpp2::BaseServiceSvIf {
}
addCountersAvailableToResponse(reqCtx, numAvailable);
}
callback_->result(res);
callback_->result(std::move(res));
} catch (...) {
callback_->exception(std::current_exception());
}
Expand Down Expand Up @@ -313,7 +313,7 @@ class BaseService : virtual public cpp2::BaseServiceSvIf {
}
addCountersAvailableToResponse(reqCtx, numAvailable);
}
callback_->result(res);
callback_->result(std::move(res));
} catch (...) {
callback_->exception(std::current_exception());
}
Expand Down

0 comments on commit 7ad76f9

Please sign in to comment.