
来自:网络
阅读本文大概需要 3 分钟。
Linus Torvalds是睿智的,做好自己能控制的。
开源不仅仅代表源代码的开放,开源更是一种工作方式,一种教育方式。因为有了开源,我们多了一种更好的合作共赢的工作方式;因为有了开源,让更多从业者和学生能够学习到更好的技术。
采访中Linus Torvalds对比了以下2个函数:


1. 不怎么漂亮的代码
remove_list_entry(entry){prev = NULL;walk = head;// Walk the listwhile (walk != entry){prev = walk;walk = walk->next;}// Remove the entry by updating the// head or the previous entryif(!prev){head = entry->next;}else{prev->next = entry->next;}}
remove_list_entry(entry){// The "indirect" pointer points to the// *address* of the thing we'll updateindirect = &head;// Walk the list, looking for the thing that// points to the entry we want to removewhile ((*indirect) != entry)){indirect = &(*indirect)->next;}// .. and just remove it*indirect = entry->next;}

*indirect = entry->next;长按订阅更多精彩▼

如有收获,点个在看,诚挚感谢