Today, I checked the code I wrote for professional embedded software development and found that some functions do not introduce intermediate variables, so the code lines are long and easy to read. The code before and after reconstruction is as follows.
Before reconstruction:
If (TIMER_STARTED ==_handle-> state _){
Timer_handle_t next;
If (g_timer_next = _ handle ){
G_timer_next = (timer_handle_t) dll_next (& g_bucket_firing-> dll _,
& _ Handle-> node _);
}
Next = (timer_handle_t) dll_next
(& G_buckets [_ handle-> bucket_index _]. dll _, & _ handle-> node _);
If (0! = Next ){
Next-> round _ + = _ handle-> round _;
}
Dll_remove (& g_buckets [_ handle-> bucket_index _]. dll _, & _ handle-> node _);
If (g_buckets [_ handle-> bucket_index _]. reentrance _> 0 ){
G_bucket_firing-> level _ ++;
}
}
After reconstruction:
If (TIMER_STARTED ==_handle-> state _){
Timer_handle_t next;
Bucket_t * p_bucket = & g_buckets [_ handle-> bucket_index _];
If (g_timer_next = _ handle ){
G_timer_next = (timer_handle_t) dll_next (& g_bucket_firing-> dll _,
& _ Handle-> node _);
}
Next = (timer_handle_t) dll_next (& p_bucket-> dll _, & _ handle-> node _);
If (0! = Next ){
Next-> round _ + = _ handle-> round _;
}
Dll_remove (& p_bucket-> dll _, & _ handle-> node _);
If (p_bucket-> reentrance _> 0 ){
G_bucket_firing-> level _ ++;
}
}
Author Li Yun