# manual-fill

Prefer fill over an index loop assigning one repeated value

An index loop from zero to an array or slice length that assigns one repeated value spells the fill operation manually.
Instead, you SHOULD call `fill` with that value.

- Category: performance
- Level: warning
- Fix: suggestion
- Scope: module

## Reported

```ds title="main.ds"
function clear(values: int32[]): void {
    for (let index: isize = 0; index < values.length; index++) {
        values[index] = 0;
    }
}
```

## Accepted

```ds title="main.ds"
function clear(values: int32[]): void {
    values.fill(0);
}
```

## Prior art

- [Clippy · manual_slice_fill](https://rust-lang.github.io/rust-clippy/master/index.html#manual_slice_fill)

[language/linter/src/rules/performance/manual_fill.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/performance/manual_fill.rs#L8)
