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_++;
}
}
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_++;
}
}
p_bucket 語意明確,取代冗長陣列索引_handle->bucket_index_ 及陣列索引const 防止意外修改現代工具可自動偵測並建議提取:
// 啟用檢查
clang-tidy -checks='readability-*', 'performance-*' ...