Skip to content

Commit

Permalink
Optimise FlashString iteration and indexing (#2761)
Browse files Browse the repository at this point in the history
This PR improves performance of `FlashString` library object iteration and indexing.
  • Loading branch information
mikee47 authored Apr 12, 2024
1 parent 20cc413 commit 040d6bd
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 41 deletions.
20 changes: 10 additions & 10 deletions Sming/Arch/Esp32/Components/libc/src/include/sys/pgmspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ extern "C" {
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
#define pgm_read_float_far(addr) pgm_read_float(addr)

#define memcpy_P(dest, src, num) memcpy(dest, src, num)
#define memcmp_P(a1, b1, len) memcmp(a1, b1, len)
#define strlen_P(a) strlen(a)
#define strcpy_P(dest, src) strcpy(dest, src)
#define strncpy_P(dest, src, size) strncpy(dest, src, size)
#define strcmp_P(a, b) strcmp(a, b)
#define memcpy_P(dest, src_P, num) memcpy(dest, src_P, num)
#define memcmp_P(buf1, buf2_P, len) memcmp(buf1, buf2_P, len)
#define strlen_P(str_P) strlen(str_P)
#define strcpy_P(dest, src_P) strcpy(dest, src_P)
#define strncpy_P(dest, src_P, size) strncpy(dest, src_P, size)
#define strcmp_P(str1, str2_P) strcmp(str1, str2_P)
#define strncmp_P(str1, str2_P, size) strncmp(str1, str2_P, size)
#define strcasecmp_P(a, b) strcasecmp(a, b)
#define strcat_P(dest, src) strcat(dest, src)
#define strstr_P(a, b) strstr(a, b)
#define sprintf_P(s, f, ...) m_snprintf(s, 1024, f, ##__VA_ARGS__)
#define strcasecmp_P(str1, str2_P) strcasecmp(str1, str2_P)
#define strcat_P(dest, src_P) strcat(dest, src_P)
#define strstr_P(haystack, needle_P) strstr(haystack, needle_P)
#define sprintf_P(str, format_P, ...) m_snprintf(str, 1024, format_P, ##__VA_ARGS__)

#ifdef __cplusplus
}
Expand Down
20 changes: 10 additions & 10 deletions Sming/Arch/Esp8266/Components/libc/include/sys/pgmspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,16 @@ static inline uint16_t pgm_read_word_inlined(const void* addr)
* @{
*/

void* memcpy_P(void* dest, const void* src_P, size_t length);
int memcmp_P(const void* a1, const void* b1, size_t len);
size_t strlen_P(const char* src_P);
char* strcpy_P(char* dest, const char* src_P);
char* strncpy_P(char* dest, const char* src_P, size_t size);
int strcmp_P(const char* str1, const char* str2_P);
int strncmp_P(const char* str1, const char* str2_P, const size_t size);
int strcasecmp_P(const char* str1, const char* str2_P);
char* strcat_P(char* dest, const char* src_P);
char* strstr_P(char* haystack, const char* needle_P);
void* memcpy_P(void* dest, PGM_VOID_P src_P, size_t length);
int memcmp_P(const void* buf1, PGM_VOID_P buf2_P, size_t len);
size_t strlen_P(PGM_VOID_P src_P);
char* strcpy_P(char* dest, PGM_P src_P);
char* strncpy_P(char* dest, PGM_P src_P, size_t size);
int strcmp_P(const char* str1, PGM_P str2_P);
int strncmp_P(const char* str1, PGM_P str2_P, const size_t size);
int strcasecmp_P(const char* str1, PGM_P str2_P);
char* strcat_P(char* dest, PGM_P src_P);
char* strstr_P(char* haystack, PGM_P needle_P);

#define sprintf_P(s, f_P, ...) \
(__extension__({ \
Expand Down
20 changes: 10 additions & 10 deletions Sming/Arch/Host/Components/libc/include/sys/pgmspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ bool isFlashPtr(const void* ptr);
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
#define pgm_read_float_far(addr) pgm_read_float(addr)

#define memcpy_P(dest, src, num) memcpy(dest, src, num)
#define memcmp_P(a1, b1, len) memcmp(a1, b1, len)
#define strlen_P(a) strlen(a)
#define strcpy_P(dest, src) strcpy(dest, src)
#define strncpy_P(dest, src, size) strncpy(dest, src, size)
#define strcmp_P(a, b) strcmp(a, b)
#define memcpy_P(dest, src_P, num) memcpy(dest, src_P, num)
#define memcmp_P(buf1, buf2_P, len) memcmp(buf1, buf2_P, len)
#define strlen_P(str_P) strlen(str_P)
#define strcpy_P(dest, src_P) strcpy(dest, src_P)
#define strncpy_P(dest, src_P, size) strncpy(dest, src_P, size)
#define strcmp_P(str1, str2_P) strcmp(str1, str2_P)
#define strncmp_P(str1, str2_P, size) strncmp(str1, str2_P, size)
#define strcasecmp_P(a, b) strcasecmp(a, b)
#define strcat_P(dest, src) strcat(dest, src)
#define strstr_P(a, b) strstr(a, b)
#define sprintf_P(s, f, ...) m_snprintf(s, 1024, f, ##__VA_ARGS__)
#define strcasecmp_P(str1, str2_P) strcasecmp(str1, str2_P)
#define strcat_P(dest, src_P) strcat(dest, src_P)
#define strstr_P(haystack, needle_P) strstr(haystack, needle_P)
#define sprintf_P(str, format_P, ...) m_snprintf(str, 1024, format_P, ##__VA_ARGS__)

#ifdef __cplusplus
}
Expand Down
20 changes: 10 additions & 10 deletions Sming/Arch/Rp2040/Components/libc/src/include/sys/pgmspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ extern "C" {
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
#define pgm_read_float_far(addr) pgm_read_float(addr)

#define memcpy_P(dest, src, num) memcpy(dest, src, num)
#define memcmp_P(a1, b1, len) memcmp(a1, b1, len)
#define strlen_P(a) strlen(a)
#define strcpy_P(dest, src) strcpy(dest, src)
#define strncpy_P(dest, src, size) strncpy(dest, src, size)
#define strcmp_P(a, b) strcmp(a, b)
#define memcpy_P(dest, src_P, num) memcpy(dest, src_P, num)
#define memcmp_P(buf1, buf2_P, len) memcmp(buf1, buf2_P, len)
#define strlen_P(str_P) strlen(str_P)
#define strcpy_P(dest, src_P) strcpy(dest, src_P)
#define strncpy_P(dest, src_P, size) strncpy(dest, src_P, size)
#define strcmp_P(str1, str2_P) strcmp(str1, str2_P)
#define strncmp_P(str1, str2_P, size) strncmp(str1, str2_P, size)
#define strcasecmp_P(a, b) strcasecmp(a, b)
#define strcat_P(dest, src) strcat(dest, src)
#define strstr_P(a, b) strstr(a, b)
#define sprintf_P(s, f, ...) m_snprintf(s, 1024, f, ##__VA_ARGS__)
#define strcasecmp_P(str1, str2_P) strcasecmp(str1, str2_P)
#define strcat_P(dest, src_P) strcat(dest, src_P)
#define strstr_P(haystack, needle_P) strstr(haystack, needle_P)
#define sprintf_P(str, format_P, ...) m_snprintf(str, 1024, format_P, ##__VA_ARGS__)

#ifdef __cplusplus
}
Expand Down

0 comments on commit 040d6bd

Please sign in to comment.