本文共 1036 字,大约阅读时间需要 3 分钟。
今天查看自己为《专业嵌入式软件开发》一书所写的代码时发现,个别函数由于没有引入中间变量,使代码行既长又不易读。重构前后的代码如下所示。 -
if (TIMER_STARTED == _handle->state_) {
-
-
if (g_timer_next == _handle) {
-
g_timer_next = (timer_handle_t) dll_next (&g_bucket_firing->dll_,
-
-
-
next = (timer_handle_t)dll_next
-
(&
g_buckets [_handle->bucket_index_].dll_, &_handle->node_);
-
-
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_ ++;
-
-
-
if (TIMER_STARTED == _handle->state_) {
-
-
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_,
-
-
-
next = (timer_handle_t)dll_next (&
p_bucket->dll_, &_handle->node_);
-
-
next->round_ += _handle->round_;
-
-
dll_remove (&
p_bucket->dll_, &_handle->node_);
-
if (
p_bucket->reentrance_ > 0) {
-
g_bucket_firing->level_ ++;
-
-
转载地址:http://rbjna.baihongyu.com/