Skip to content

Commit a07daf9

Browse files
author
Luc
committed
Code refactoring
Thanks a lot @treepleks
1 parent 60326f3 commit a07daf9

File tree

3 files changed

+469
-877
lines changed

3 files changed

+469
-877
lines changed

esp8266/storestrings.cpp

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,12 @@ bool STORESTRINGS_CLASS::setsize(int size)
3939
_maxsize=size;
4040
return true;
4141
}
42-
bool STORESTRINGS_CLASS::setlenght(int lenght)
42+
bool STORESTRINGS_CLASS::setlength(int len)
4343
{
44-
if (lenght<4)return false;
45-
_maxstringlength=lenght;
44+
if (len < 4) return false;
45+
_maxstringlength = len;
4646
return true;
4747
}
48-
int STORESTRINGS_CLASS::getsize()
49-
{
50-
return _maxsize;
51-
}
52-
int STORESTRINGS_CLASS::getlenght()
53-
{
54-
return _maxstringlength;
55-
}
5648

5749
//Clear list and content
5850
void STORESTRINGS_CLASS::clear(){
@@ -65,11 +57,6 @@ void STORESTRINGS_CLASS::clear(){
6557
}
6658
}
6759

68-
bool STORESTRINGS_CLASS::add (String & string)
69-
{
70-
return add(string.c_str());
71-
}
72-
7360
bool STORESTRINGS_CLASS::add (const __FlashStringHelper *str)
7461
{
7562
String stmp;
@@ -138,10 +125,4 @@ int STORESTRINGS_CLASS::get_index(const char * string)
138125
//if not found return -1
139126
return -1;
140127
}
141-
//Number of elements in list
142-
int STORESTRINGS_CLASS::size()
143-
{
144-
return _charlist.size();
145-
}
146-
147128

esp8266/storestrings.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ class STORESTRINGS_CLASS
2828
STORESTRINGS_CLASS (int maxsize = -1, int maxstringlength=-1);
2929
~STORESTRINGS_CLASS ();
3030
bool add (const char * string);
31-
bool add (String & string);
31+
inline bool add (String & string) {return add(string.c_str());};
3232
bool add (const __FlashStringHelper *str);
3333
bool remove(int pos);
3434
const char * get(int pos);
3535
int get_index(const char * string);
3636
void clear();
37-
int size();
37+
inline int size() {return _charlist.size();};
3838
bool setsize(int size);
39-
bool setlenght(int lenght);
40-
int getsize();
41-
int getlenght();
39+
bool setlength(int len);
40+
inline int getsize() {return _maxsize;};
41+
inline int getlength() {return _maxstringlength;};
42+
4243
private:
4344
int _maxsize;
4445
int _maxstringlength;

0 commit comments

Comments
 (0)