Загрузка видео...

Не удалось загрузить видео

На главную

Linus Torvalds explains "taste" in code by showing how to remove an entry from a singly linked list in C without adding extra complexity. Source: TED

8,910,912 просмотров • 2 лет назад •via X (Twitter)

Комментарии: 10

Фото профиля tetsuo.ai
tetsuo.ai2 лет назад

Source:

Фото профиля 🇵🇹Ninja Dynamics☀️🌴🍹
🇵🇹Ninja Dynamics☀️🌴🍹2 лет назад

Oh man, seeing how elegantly a simple linked list can be optimized really blew my mind! Beautiful! Linus really is the goat!

Фото профиля dinn
dinn2 лет назад

"Better taste" would not work if entry is a value, not a list element that needs to be deleted. Last string needs indirect->next

Фото профиля Kevin Dai
Kevin Dai2 лет назад

I'd argue the first one is better *because* it's more intuitive and understandable (biased as a compiler developer). In reality, the compiler has no trouble optimizing this trivial logic: and actually yields better code in the "untasteful" one (1/3)

Фото профиля Ghasem Ramezani
Ghasem Ramezani2 лет назад

Looking at the problem from a different perspective is extremely hard when you are in the problem. 😫

Фото профиля Araf
Araf2 лет назад

had to do some soul searching

Фото профиля wundram
wundram2 лет назад

That while loop tastes pretty sour.

Фото профиля Teobastus
Teobastus2 лет назад

But it doesn't really handle the case where you reach the end of the list without finding the element you're looking for. If you reach the end it will crash and probably segfault.

Фото профиля Method
Method2 лет назад

“code taste”

Фото профиля Noga Navon🏳️‍⚧️ الزهرة الحكيمة נוגה נבון
Noga Navon🏳️‍⚧️ الزهرة الحكيمة נוגה נבון2 лет назад

This is the kind of thing that make having pointers in your language worth it.

Похожие видео