Skip to content

Commit

Permalink
Remove leading underscore from class variables (SmingHub#1466)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 authored and slaff committed Oct 8, 2018
1 parent 8ed9585 commit 72a0006
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Sming/Services/Profiling/ElapseTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ class ElapseTimer

void start()
{
_start = NOW();
startTicks = NOW();
}

uint32_t elapsed()
{
return timerTicksToUs(NOW() - _start);
return timerTicksToUs(NOW() - startTicks);
}

private:
uint32_t _start;
uint32_t startTicks;
};

#endif // __ELAPSETIMER_H
4 changes: 2 additions & 2 deletions Sming/SmingCore/Data/CStringArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ bool CStringArray::add(const char* str, unsigned length)
buffer[len++] = '\0'; // Separator between strings
memcpy(buffer + len, str, length + 1); // Copy final nul terminator
len += length;
++count_;
++stringCount;
return true;
}

Expand All @@ -42,7 +42,7 @@ int CStringArray::indexOf(const char* str) const

const char* CStringArray::getValue(unsigned index) const
{
if(index < count_) {
if(index < stringCount) {
for(unsigned offset = 0; offset < length(); --index) {
const char* s = buffer + offset;
if(index == 0)
Expand Down
6 changes: 3 additions & 3 deletions Sming/SmingCore/Data/CStringArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ class CStringArray : protected String
void clear()
{
invalidate();
count_ = 0;
stringCount = 0;
}

unsigned count() const
{
return count_;
return stringCount;
}

private:
unsigned count_ = 0;
unsigned stringCount = 0;
};

#endif // _SMING_CORE_DATA_STRING_ARRAY_H_
22 changes: 11 additions & 11 deletions Sming/Wiring/FlashString.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
*/
#define FSTR_TABLE(_name) const FlashString* const _name[] PROGMEM


/*
* Load a FlashString object into a named local (stack) buffer
*
Expand Down Expand Up @@ -151,22 +150,23 @@
* content into RAM. Data is stored word-aligned so it can be read as efficiently as possible.
*/
struct FlashString {
uint32_t _length; // Only needs to be uint16_t but ensures data is aligned
char _data[];
// Do NOT access these directly - use member functions
uint32_t flashLength; ///< Only needs to be uint16_t but ensures data is aligned
char flashData[];

uint32_t length() const
{
return _length;
return flashLength;
}

uint32_t size() const
{
return ALIGNUP(_length + 1);
return ALIGNUP(flashLength + 1);
}

flash_string_t data() const
{
return FPSTR(_data);
return FPSTR(flashData);
}

/** @brief Check for equality with a C-string
Expand All @@ -178,10 +178,10 @@ struct FlashString {
{
// Unlikely we'd want an empty flash string, but check anyway
if(cstr == nullptr)
return _length == 0;
return flashLength == 0;
// Don't use strcmp as our data may contain nuls
size_t cstrlen = strlen(cstr);
if(cstrlen != _length)
if(cstrlen != flashLength)
return false;
LOAD_FSTR(buf, *this);
return memcmp(buf, cstr, cstrlen) == 0;
Expand All @@ -193,11 +193,11 @@ struct FlashString {
*/
bool isEqual(const FlashString& str) const
{
if(_length != str._length)
if(flashLength != str.flashLength)
return false;
if(_data == str._data)
if(flashData == str.flashData)
return true;
return memcmp_aligned(_data, str._data, ALIGNUP(_length)) == 0;
return memcmp_aligned(flashData, str.flashData, ALIGNUP(flashLength)) == 0;
}

bool isEqual(const String& str) const
Expand Down

0 comments on commit 72a0006

Please sign in to comment.