Skip to content

Commit 5a4c4c3

Browse files
committed
Use memcpy instead of loop
1 parent 2adda59 commit 5a4c4c3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

libraries/EEPROM/EEPROM.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <stddef.h>
2626
#include <stdint.h>
27+
#include <string.h>
2728

2829
class EEPROMClass
2930
{
@@ -41,7 +42,7 @@ class EEPROMClass
4142
return t;
4243

4344
uint8_t *ptr = (uint8_t*) &t;
44-
for(int count = 0; count < sizeof(T); ++count) *ptr++ = _data[address + count];
45+
memcpy(ptr, _data + address, sizeof(T));
4546
return t;
4647
}
4748

@@ -51,7 +52,7 @@ class EEPROMClass
5152
return t;
5253

5354
const uint8_t *ptr = (const uint8_t*) &t;
54-
for(int count = 0; count < sizeof(T); ++count) _data[address + count] = *ptr++;
55+
memcpy(_data + address, ptr, sizeof(T));
5556
_dirty = true;
5657
return t;
5758
}

0 commit comments

Comments
 (0)