Re:Why Discord is switching from Go to Rust
by earthboundkid on Tuesday February 04, 2020 @09:25PM
(#22243437)
Ugh, linked lists fuck everything up. It’s never the right data structure. Use a vector!
[ Parent
| on HN ]
Re:Why Discord is switching from Go to Rust
by giornogiovanna on Wednesday February 05, 2020 @07:57AM
(#22246326)
The two main cases when linked lists are better are (a) when you want to guarantee a low cost per insert, since vector insertion is only O(1) amortized, and (b) when you want to insert in the middle, but somehow found that middle without scanning the list.
Anyway, in this case, I guess they're using a free list because (1) it's simpler since you don't need an external collection keeping a list of unused stuff, and (2) reason (a) above.
Re:Why Discord is switching from Go to Rust
by anarazel on Tuesday February 04, 2020 @11:03PM
(#22243906)
That's only true if you actually need to access more than a few elements at once. And if you never need to insert/delete to/from anywhere but the end.
Re:Why Discord is switching from Go to Rust
by earthboundkid on Wednesday February 05, 2020 @07:17AM
(#22246089)
Even if you need middle inserts but not a B-tree (weird), it’s still better to use a vector in most cases. Time to find the insertion point will dominate.