Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

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,574 Aufrufe • vor 1 Jahr •via X (Twitter)

10 Kommentare

Profilbild von tetsuo.ai
tetsuo.aivor 1 Jahr

Source:

Profilbild von 🇵🇹Ninja Dynamics☀️🌴🍹
🇵🇹Ninja Dynamics☀️🌴🍹vor 1 Jahr

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

Profilbild von dinn
dinnvor 1 Jahr

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

Profilbild von Kevin Dai
Kevin Daivor 1 Jahr

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)

Profilbild von Ghasem Ramezani
Ghasem Ramezanivor 1 Jahr

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

Profilbild von Araf
Arafvor 1 Jahr

had to do some soul searching

Profilbild von wundram
wundramvor 1 Jahr

That while loop tastes pretty sour.

Profilbild von Teobastus
Teobastusvor 1 Jahr

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.

Profilbild von Method
Methodvor 1 Jahr

“code taste”

Profilbild von Noga Navon🏳️‍⚧️ الزهرة الحكيمة נוגה נבון
Noga Navon🏳️‍⚧️ الزهرة الحكيمة נוגה נבוןvor 1 Jahr

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

Ähnliche Videos