mirror of
https://github.com/marqs85/ossc.git
synced 2024-09-28 11:55:16 +00:00
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:
parent
b68b586ec8
commit
89bc3f35e7
File diff suppressed because it is too large
Load Diff
@ -353,12 +353,12 @@ int export_userdata()
|
|||||||
alt_u8 prompt_state = 0;
|
alt_u8 prompt_state = 0;
|
||||||
useconds_t prompt_delay;
|
useconds_t prompt_delay;
|
||||||
const alt_u8 prompt_transitions[] = { 1, 2, 0, 0, };
|
const alt_u8 prompt_transitions[] = { 1, 2, 0, 0, };
|
||||||
const char *prompt_msgs[] = {
|
const alt_u8 prompt_ofs[] = { 0, 16, 31, 48, };
|
||||||
"SD CARD WILL BE",
|
const char *prompt_msgs =
|
||||||
"OVERWRITTEN!!!",
|
"SD CARD WILL BE" "\0" // [ 0..15]
|
||||||
"Export? 1=Y, 2=N",
|
"OVERWRITTEN!!!" "\0" // [16..30]
|
||||||
"Press 1 or 2",
|
"Export? 1=Y, 2=N""\0" // [31..47]
|
||||||
};
|
"Press 1 or 2"; // [48..60]
|
||||||
alt_u32 btn_vec;
|
alt_u32 btn_vec;
|
||||||
|
|
||||||
retval = check_sdcard(databuf);
|
retval = check_sdcard(databuf);
|
||||||
@ -370,7 +370,7 @@ int export_userdata()
|
|||||||
|
|
||||||
usleep(100000U);
|
usleep(100000U);
|
||||||
while (1) {
|
while (1) {
|
||||||
msg = prompt_msgs[prompt_state];
|
msg = &prompt_msgs[prompt_ofs[prompt_state]];
|
||||||
prompt_delay = (prompt_state == 2) ? 2000000U
|
prompt_delay = (prompt_state == 2) ? 2000000U
|
||||||
: ((prompt_state == 3) ? 300000U : 1000000U);
|
: ((prompt_state == 3) ? 300000U : 1000000U);
|
||||||
prompt_state = prompt_transitions[prompt_state];
|
prompt_state = prompt_transitions[prompt_state];
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user