Userdata export: Reduce image size by 20 bytes.

Replace an array of const char* literals with a single const char*
literal containing all the messages in the rotating prompt and an
array of alt_u8 containing the offsets of each message within the
literal.

This ends up yielding a larger size reduction than expected, a
healthy 20 bytes, despite a meager 8-byte difference in the size
of local variables and slightly more complex pointer math in
calculating the address of the current message within the string
literal.
This commit is contained in:
Ari Sundholm 2020-11-09 19:12:41 +02:00
parent b68b586ec8
commit 89bc3f35e7
3 changed files with 5494 additions and 5444 deletions

File diff suppressed because it is too large Load Diff

View File

@ -353,12 +353,12 @@ int export_userdata()
alt_u8 prompt_state = 0;
useconds_t prompt_delay;
const alt_u8 prompt_transitions[] = { 1, 2, 0, 0, };
const char *prompt_msgs[] = {
"SD CARD WILL BE",
"OVERWRITTEN!!!",
"Export? 1=Y, 2=N",
"Press 1 or 2",
};
const alt_u8 prompt_ofs[] = { 0, 16, 31, 48, };
const char *prompt_msgs =
"SD CARD WILL BE" "\0" // [ 0..15]
"OVERWRITTEN!!!" "\0" // [16..30]
"Export? 1=Y, 2=N""\0" // [31..47]
"Press 1 or 2"; // [48..60]
alt_u32 btn_vec;
retval = check_sdcard(databuf);
@ -370,7 +370,7 @@ int export_userdata()
usleep(100000U);
while (1) {
msg = prompt_msgs[prompt_state];
msg = &prompt_msgs[prompt_ofs[prompt_state]];
prompt_delay = (prompt_state == 2) ? 2000000U
: ((prompt_state == 3) ? 300000U : 1000000U);
prompt_state = prompt_transitions[prompt_state];