mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-24 05:37:13 +00:00
Fix MultiArray::at(); use operator[] on hot paths
Fix MultiArray::at() which was marked noexcept despite delegating to std::array::at() that throws on out-of-range. Per review feedback, at() now keeps standard bounds-checking semantics (only noexcept removed), and operator[] gains an assert for debug-mode safety. All eight correction history lookups in search.cpp (correction_value and update_correction_history) are switched from .at(us) to [us]. Passed STC: https://tests.stockfishchess.org/tests/view/69de7a735c67bee7d241ff92 LLR: 2.96 (-2.94,2.94) <-1.75,0.25> Total: 77536 W: 20031 L: 19860 D: 37645 Ptnml(0-2): 221, 8411, 21338, 8572, 226 closes https://github.com/official-stockfish/Stockfish/pull/6734 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
cc4637b52b
commit
40ac93b8f8
+10
-4
@@ -266,11 +266,17 @@ class MultiArray {
|
||||
using reverse_iterator = typename ArrayType::reverse_iterator;
|
||||
using const_reverse_iterator = typename ArrayType::const_reverse_iterator;
|
||||
|
||||
constexpr auto& at(size_type index) noexcept { return data_.at(index); }
|
||||
constexpr const auto& at(size_type index) const noexcept { return data_.at(index); }
|
||||
constexpr auto& at(size_type index) { return data_.at(index); }
|
||||
constexpr const auto& at(size_type index) const { return data_.at(index); }
|
||||
|
||||
constexpr auto& operator[](size_type index) noexcept { return data_[index]; }
|
||||
constexpr const auto& operator[](size_type index) const noexcept { return data_[index]; }
|
||||
constexpr auto& operator[](size_type index) noexcept {
|
||||
assert(index < Size);
|
||||
return data_[index];
|
||||
}
|
||||
constexpr const auto& operator[](size_type index) const noexcept {
|
||||
assert(index < Size);
|
||||
return data_[index];
|
||||
}
|
||||
|
||||
constexpr auto& front() noexcept { return data_.front(); }
|
||||
constexpr const auto& front() const noexcept { return data_.front(); }
|
||||
|
||||
Reference in New Issue
Block a user