RS.CLIPPY.LINKEDLIST
Usage of LinkedList, usually a vector is faster, or a more specialized data structure like a `VecDeque`
What it does
Checks for usage of any LinkedList, suggesting to use a
Vec or a VecDeque (formerly called RingBuf).
Why is this bad?
Gankra says:
The TL;DR of
LinkedListis that it's built on a massive amount of pointers and indirection. It wastes memory, it has terrible cache locality, and is all-around slow.RingBuf, while "only" amortized for push/pop, should be faster in the general case for almost every possible workload, and isn't even amortized at all if you can predict the capacity you need.
LinkedLists are only really good if you're doing a lot of merging or splitting of lists. This is because they can just mangle some pointers instead of actually copying the data. Even if you're doing a lot of insertion in the middle of the list,RingBufcan still be better because of how expensive it is to seek to the middle of aLinkedList.
Known problems
False positives – the instances where using a
LinkedList makes sense are few and far between, but they can still happen.
Example
let x: LinkedList<usize> = LinkedList::new();
Configuration
-
avoid-breaking-exported-api: Suppress lints whenever the suggested change would cause breakage for other crates.(default:
true)