Introduce intermediate variables to make the program easier to read

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.