# std.mem: use indexOfScalarPos when indexOf is called where needle.len == 1 · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/75b48ef503204d3ba005647ecce8fda4657a8588)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 75b48ef503204d3ba005647ecce8fda4657a8588

Requested commit: 75b48ef503204d3ba005647ecce8fda4657a8588

Commit: 75b48ef503204d3ba005647ecce8fda4657a8588

Tree: e84b4d576938585c06f94b498785e6539bd60938

Author: Karl Seguin

Committer: GitHub

## Message

```
std.mem: use indexOfScalarPos when indexOf is called where needle.len == 1

When `std.mem.indexOf` is called with a single-item needle, use `indexOfScalarPos` which is significantly faster than the more general `indexOfPosLinear`.  This can be done without introducing overhead to normal cases (where `needle.len > 1`).
```

## Parents

- [57874ce619c098a4affd6804a71e0604ff3874c8](https://git.cafe/gitcafe/zig/commit/57874ce619c098a4affd6804a71e0604ff3874c8?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/75b48ef503204d3ba005647ecce8fda4657a8588?format=markdown)
