Skip to content

Commit 83f1286

Browse files
committed
Changed from pass-by-copy to pass-by-const-ref. A minor change but could have significant impact for large structures. I believe it makes no difference for built-in types.
1 parent a18f645 commit 83f1286

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

EEPROMVar.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@
2424
template<typename T> class EEPROMVar
2525
{
2626
public:
27-
EEPROMVar(T init) {
28-
address = EEPROM.getAddress(sizeof(T));
29-
var = init;
3027
}
28+
EEPROMVar(const T& init):
29+
var(init),
30+
address(EEPROM.getAddress(sizeof(T)))
31+
{
32+
}
33+
3134
operator T () {
3235
return var;
3336
}
34-
EEPROMVar &operator=(T val) {
37+
EEPROMVar &operator=(const T& val) {
3538
var = val;
3639
return *this;
3740
}

0 commit comments

Comments
 (0)