Bug 1739500 - Modernize lambda that adds a screenshot marker - r=canaltinova

While working on this screenshot marker, I noticed that the lambda initialization could directly copy or move its needed captures, instead of going through separate copies on the stack, which was probably done before C++14 lambda were available to us.

Differential Revision: https://phabricator.services.mozilla.com/D130436
This commit is contained in:
Gerald Squelart 2021-11-07 22:43:12 +00:00
parent 9784494cbd
commit 27166e1256

View File

@ -82,18 +82,13 @@ void ProfilerScreenshots::SubmitScreenshot(
return;
}
ProfilerThreadId sourceThread = profiler_current_thread_id();
uint32_t windowIdentifier = mWindowIdentifier;
IntSize originalSize = aOriginalSize;
IntSize scaledSize = aScaledSize;
TimeStamp timeStamp = aTimeStamp;
RefPtr<ProfilerScreenshots> self = this;
NS_DispatchBackgroundTask(NS_NewRunnableFunction(
"ProfilerScreenshots::SubmitScreenshot",
[self{std::move(self)}, backingSurface, sourceThread, windowIdentifier,
originalSize, scaledSize, timeStamp]() {
[self = RefPtr<ProfilerScreenshots>{this},
backingSurface = std::move(backingSurface),
sourceThread = profiler_current_thread_id(),
windowIdentifier = mWindowIdentifier, originalSize = aOriginalSize,
scaledSize = aScaledSize, timeStamp = aTimeStamp]() {
// Create a new surface that wraps backingSurface's data but has the
// correct size.
if (profiler_thread_is_being_profiled(sourceThread)) {