️ Tiny string optimization

This commit is contained in:
Scott Lahteine 2023-11-22 21:06:47 -06:00
parent 2d9262cc5a
commit bf61e52390
2 changed files with 16 additions and 8 deletions

View file

@ -276,13 +276,13 @@ public:
SString& set() { super::set(); return *this; } SString& set() { super::set(); return *this; }
template<typename... Args> template<typename... Args>
SString& setf_P(PGM_P const fmt, Args... more) { snprintf_P(str, SIZE, fmt, more...); debug(F("setf_P")); return *this; } SString& setf_P(PGM_P const fmt, Args... more) { super::setf_P(fmt, more...); return *this; }
template<typename... Args> template<typename... Args>
SString& setf(const char *fmt, Args... more) { snprintf(str, SIZE, fmt, more...); debug(F("setf")); return *this; } SString& setf(const char *fmt, Args... more) { super::setf(fmt, more...); return *this; }
template<typename... Args> template<typename... Args>
SString& setf(FSTR_P const fmt, Args... more) { return setf_P(FTOP(fmt), more...); } SString& setf(FSTR_P const fmt, Args... more) { super::setf(fmt, more...); return *this; }
template <typename T> template <typename T>
SString& set(const T &v) { super::set(v); return *this; } SString& set(const T &v) { super::set(v); return *this; }

View file

@ -376,11 +376,19 @@ void _lcd_ubl_storage_mesh() {
* UBL LCD "radar" map point editing * UBL LCD "radar" map point editing
*/ */
void _lcd_ubl_map_edit_cmd() { void _lcd_ubl_map_edit_cmd() {
char ubl_lcd_gcode[50], str[10], str2[10]; #if ENABLED(POWER_LOSS_RECOVERY)
dtostrf(bedlevel.get_mesh_x(x_plot), 0, 2, str); // Costs 198 bytes on AVR with PLR disabled, but saves 60 bytes with PLR enabled
dtostrf(bedlevel.get_mesh_y(y_plot), 0, 2, str2); queue.inject(TS(F("G29P4X"), x_plot, 'Y', y_plot, 'R', n_edit_pts));
snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29P4X%sY%sR%i"), str, str2, int(n_edit_pts)); #else
queue.inject(ubl_lcd_gcode); char ubl_lcd_gcode[50], str1[10], str2[10];
snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode),
PSTR("G29P4X%sY%sR%i"),
dtostrf(bedlevel.get_mesh_x(x_plot), 0, 2, str1),
dtostrf(bedlevel.get_mesh_y(y_plot), 0, 2, str2),
int(n_edit_pts)
);
queue.inject(ubl_lcd_gcode);
#endif
} }
/** /**