View Single Post
Old 15 December 2013, 19:42   #3
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 2,481
clear_id() basically does this:
- free all memory entries in the custom[][] array
- zero out the entire uae_input_device structure, except for configname and name fields.

In set_kbr_default() there is this though:
Code:
for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
	clear_id (kbr);
	kbr->extra[i] = -1;
}
So for each of the 256 loop iterations (MAX_INPUT_DEVICE_EVENTS is 256) you call clear_id() then set the extra[i] field to -1. But on the next loop iteration, because clear_id() zeros out the structure, the previous extra[i] field is also zeroed. And all the custom[][] memory regions will have been freed on the first loop iteration.

So, would it make sense to move clear_id(kbr) out of the loop, doing this instead:
Code:
clear_id (kbr);
for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
	kbr->extra[i] = -1;
}
Update: I built WinUAE with that change, and now with instrumented profiling the settings window opens in about 6-7 seconds (on my 6-year-old laptop).

Last edited by mark_k; 15 December 2013 at 21:31.
mark_k is offline  
 
Page generated in 0.04797 seconds with 9 queries