Commit e1f712f1 authored by ssid's avatar ssid Committed by Commit Bot

Do not create unnecessary strings for each posted task

Reduces one of the hot spots in early startup.

Change-Id: I0fbf412a14cf1e31bbfe601d523fb8169fb73a99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2523241
Commit-Queue: ssid <ssid@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825055}
parent 8b5342b7
......@@ -8,6 +8,7 @@
#include <utility>
#include "base/callback.h"
#include "base/location.h"
#include "base/strings/string_piece.h"
#include "build/build_config.h"
......@@ -66,6 +67,12 @@ inline OnceClosure MakeCriticalClosure(StringPiece task_name,
&internal::CriticalClosure::Run,
Owned(new internal::CriticalClosure(task_name, std::move(closure))));
}
inline OnceClosure MakeCriticalClosure(const Location& posted_from,
OnceClosure closure) {
return MakeCriticalClosure(posted_from.ToString(), std::move(closure));
}
#else // defined(OS_IOS)
inline OnceClosure MakeCriticalClosure(StringPiece task_name,
OnceClosure closure) {
......@@ -73,6 +80,12 @@ inline OnceClosure MakeCriticalClosure(StringPiece task_name,
// background time for closures to finish when it goes into the background.
return closure;
}
inline OnceClosure MakeCriticalClosure(const Location& posted_from,
OnceClosure closure) {
return closure;
}
#endif // defined(OS_IOS)
} // namespace base
......
......@@ -45,8 +45,7 @@ void Sequence::Transaction::PushTask(Task task) {
task.task = sequence()->traits_.shutdown_behavior() ==
TaskShutdownBehavior::BLOCK_SHUTDOWN
? MakeCriticalClosure(task.posted_from.ToString(),
std::move(task.task))
? MakeCriticalClosure(task.posted_from, std::move(task.task))
: std::move(task.task);
if (sequence()->queue_.empty())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment