From 33f735c15d8bbf0448d941ed48d1091edfd0063d Mon Sep 17 00:00:00 2001 From: "Bundit J." Date: Sat, 18 Apr 2015 22:48:04 +0700 Subject: [PATCH] Use memcpy instead of loop --- hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.h b/hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.h index 961ff8b08..52de83909 100644 --- a/hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.h +++ b/hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.h @@ -24,6 +24,7 @@ #include #include +#include class EEPROMClass { @@ -41,7 +42,7 @@ class EEPROMClass return t; uint8_t *ptr = (uint8_t*) &t; - for(int count = 0; count < sizeof(T); ++count) *ptr++ = _data[address + count]; + memcpy(ptr, _data + address, sizeof(T)); return t; } @@ -51,7 +52,7 @@ class EEPROMClass return t; const uint8_t *ptr = (const uint8_t*) &t; - for(int count = 0; count < sizeof(T); ++count) _data[address + count] = *ptr++; + memcpy(_data + address, ptr, sizeof(T)); _dirty = true; return t; }