Skip to content
public-library›Rules›Performance›Optimize measured hot paths by removing repeated work

Optimize measured hot paths by removing repeated work

When measurement shows that code is slow, or code runs very often over large inputs, remove repeated work: index repeated lookups, stop when the answer is known, avoid unnecessary passes, and compute invariant values once. Leave code that is not measurably hot in its clearest form.

In the full rule