Skip to content

Commit e443b0c

Browse files
committed
Merge pull request esp8266#1437 from timw1971/patch-2
Optimised _dirty flag.
2 parents a39b482 + b3a503a commit e443b0c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

libraries/EEPROM/EEPROM.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,13 @@ void EEPROMClass::write(int address, uint8_t value) {
8686
if(!_data)
8787
return;
8888

89-
_data[address] = value;
90-
_dirty = true;
89+
// Optimise _dirty. Only flagged if data written is different.
90+
uint8_t* pData = &_data[address];
91+
if (*pData != value)
92+
{
93+
*pData = value;
94+
_dirty = true;
95+
}
9196
}
9297

9398
bool EEPROMClass::commit() {

0 commit comments

Comments
 (0)