Skip to content

Commit

Permalink
Merge pull request #1437 from timw1971/patch-2
Browse files Browse the repository at this point in the history
Optimised _dirty flag.
  • Loading branch information
igrr committed Jan 18, 2016
2 parents a39b482 + b3a503a commit e443b0c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions libraries/EEPROM/EEPROM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,13 @@ void EEPROMClass::write(int address, uint8_t value) {
if(!_data)
return;

_data[address] = value;
_dirty = true;
// Optimise _dirty. Only flagged if data written is different.
uint8_t* pData = &_data[address];
if (*pData != value)
{
*pData = value;
_dirty = true;
}
}

bool EEPROMClass::commit() {
Expand Down

0 comments on commit e443b0c

Please sign in to comment.