# Premature Pessimization
+## Avoid Allocations
+
Avoid writing code which is slower than it needs to be.
Don't allocate a `Vec` where an iterator would do, don't allocate strings needlessly.
}
```
+## Push Allocations to the Call Site
+
If allocation is inevitable, let the caller allocate the resource:
```rust
}
```
+This is better because it reveals the costs.
+It is also more efficient when the caller already owns the allocation.
+
## Collection types
Prefer `rustc_hash::FxHashMap` and `rustc_hash::FxHashSet` instead of the ones in `std::collections`.