AVG_PART_LENGTH in rustdoc::html::url_parts_builder - Rust
Description: This is just a guess at the average length of a URL part, used for `String::with_capacity` calls in the `FromIterator` and `Extend` impls.

Skip to main content

## AVG_PART_LENGTH

# Constant AVG_PART_LENGTH

Source

    const AVG_PART_LENGTH: usize = 8;

Expand description

This is just a guess at the average length of a URL part, used for `String::with_capacity` calls in the `FromIterator` and `Extend` impls.

The value `8` was chosen for two main reasons:

- It seems like a good guess for the average part length.
- jemalloc’s size classes are all multiples of eight, which means that the amount of memory it allocates will often match the amount requested, avoiding wasted bytes.