mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1580112 - Stop updating the database when the value has not changed. r=alwu
In most of the cases, the value to be stored is the same as the existing value, which does not require an update to the database. Setting something in the database requires disk access. By using this we avoid accessing the disk in the majority of the cases. Differential Revision: https://phabricator.services.mozilla.com/D45504 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e613c24777
commit
966ab066dc
@ -81,7 +81,11 @@ IPCResult BenchmarkStorageParent::RecvPut(const nsCString& aDbName,
|
||||
}
|
||||
MovingAverage(average, window, aValue);
|
||||
int32_t newValue = PrepareStoredValue(average, window);
|
||||
// Avoid storing if the values are the same. This is an optimization
|
||||
// to minimize the disk usage.
|
||||
if (aResult != newValue) {
|
||||
storage->Put(aDbName, aKey, newValue);
|
||||
}
|
||||
},
|
||||
[](nsresult rv) { /*do nothing*/ });
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user