diff options
author | Jan Kokemüller <jan.kokemueller@gmail.com> | 2024-04-03 01:09:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-02 16:09:26 -0700 |
commit | 84ae8cb4af9abafe9f45e69744607aadb38d649a (patch) | |
tree | 6870e8d28b595de1f699f98ad1ce16f589bdc334 /llvm/lib/Object/COFFObjectFile.cpp | |
parent | 12c7371296e59c22debdd906f632c5e6574e3a44 (diff) | |
download | llvm-84ae8cb4af9abafe9f45e69744607aadb38d649a.zip llvm-84ae8cb4af9abafe9f45e69744607aadb38d649a.tar.gz llvm-84ae8cb4af9abafe9f45e69744607aadb38d649a.tar.bz2 |
[libc++] `std::ranges::advance`: avoid unneeded bounds checks when advancing iterator (#84126)
Currently, the bounds check in `std::ranges::advance(it, n, s)` is done
_before_ `n` is checked. This results in one extra, unneeded bounds
check.
Thus, `std::ranges::advance(it, 1, s)` currently is _not_ simply
equivalent to:
```c++
if (it != s) {
++it;
}
```
This difference in behavior matters when the check involves some
"expensive" logic. For example, the `==` operator of
`std::istreambuf_iterator` may actually have to read the underlying
`streambuf`.
Swapping around the checks in the `while` results in the expected
behavior.
Diffstat (limited to 'llvm/lib/Object/COFFObjectFile.cpp')
0 files changed, 0 insertions, 0 deletions