code optimizations based on static analysis checks

This commit is contained in:
proddy
2020-11-23 18:15:47 +01:00
parent d47a6f36af
commit ac1f8c0c58
11 changed files with 31 additions and 24 deletions

View File

@@ -82,7 +82,7 @@ char * Helpers::itoa(char * result, int32_t value, const uint8_t base) {
return result;
}
char * ptr = result, *ptr1 = result, tmp_char;
char * ptr = result, *ptr1 = result;
int16_t tmp_value;
do {
@@ -97,6 +97,7 @@ char * Helpers::itoa(char * result, int32_t value, const uint8_t base) {
}
*ptr-- = '\0';
char tmp_char;
while (ptr1 < ptr) {
tmp_char = *ptr;
*ptr-- = *ptr1;
@@ -136,7 +137,7 @@ char * Helpers::render_boolean(char * result, bool value) {
}
// depending on format render a number or a string
char * Helpers::render_enum(char * result, const std::vector<const __FlashStringHelper *> value, const uint8_t no) {
char * Helpers::render_enum(char * result, const std::vector<const __FlashStringHelper *> &value, const uint8_t no) {
if (no >= value.size()) {
return nullptr; // out of bounds
}
@@ -459,7 +460,7 @@ bool Helpers::value2bool(const char * v, bool & value) {
}
// checks to see if a string is member of a vector and return the index, also allow true/false for on/off
bool Helpers::value2enum(const char * v, uint8_t & value, const std::vector<const __FlashStringHelper *> strs) {
bool Helpers::value2enum(const char * v, uint8_t & value, const std::vector<const __FlashStringHelper *> &strs) {
if ((v == nullptr) || (strlen(v) == 0)) {
return false;
}