зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1287784 - micro-optimize GPUParent::RecvInit; r=milan
We can make GPUParent::RecvInit more efficient in two ways: 1. Using `auto&' for the type of the for-loop variable means that we're not copying each GfxPrefSetting value that we're iterating over, which is a win. 2. Pulling the `gfxPrefs::all()' call out of the loop means that we don't have to call it on each iteration. You may think the compiler could do this for you, but the compiler can't be sure that sGfxPrefList isn't being modified by SetCachedValue.
This commit is contained in:
Родитель
f55fa7da7a
Коммит
2f28c4b3a4
|
@ -48,8 +48,9 @@ GPUParent::Init(base::ProcessId aParentPid,
|
|||
bool
|
||||
GPUParent::RecvInit(nsTArray<GfxPrefSetting>&& prefs)
|
||||
{
|
||||
for (auto setting : prefs) {
|
||||
gfxPrefs::Pref* pref = gfxPrefs::all()[setting.index()];
|
||||
const nsTArray<gfxPrefs::Pref*>& globalPrefs = gfxPrefs::all();
|
||||
for (auto& setting : prefs) {
|
||||
gfxPrefs::Pref* pref = globalPrefs[setting.index()];
|
||||
pref->SetCachedValue(setting.value());
|
||||
}
|
||||
return true;
|
||||
|
|
Загрузка…
Ссылка в новой задаче