diff options
author | Neil <nyamatongwe@gmail.com> | 2021-05-28 14:46:21 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2021-05-28 14:46:21 +1000 |
commit | c9b2423aaed459c68dd8f43b1de0edee4eb287c8 (patch) | |
tree | f9bfdfa908e5a0a242fb2a00f1ed988682f568c5 /src/SplitVector.h | |
parent | a20684909b6edadae8e0c8c9ebc0d15d7fc128ba (diff) | |
download | scintilla-mirror-c9b2423aaed459c68dd8f43b1de0edee4eb287c8.tar.gz |
Better exception handling for noexcept methods. More accurate noexcept marking.
Diffstat (limited to 'src/SplitVector.h')
-rw-r--r-- | src/SplitVector.h | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/SplitVector.h b/src/SplitVector.h index dc63b4ab6..2b4aed4be 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -26,20 +26,25 @@ protected: /// hence be fast. void GapTo(ptrdiff_t position) noexcept { if (position != part1Length) { - if (position < part1Length) { - // Moving the gap towards start so moving elements towards end - std::move_backward( - body.data() + position, - body.data() + part1Length, - body.data() + gapLength + part1Length); - } else { // position > part1Length - // Moving the gap towards end so moving elements towards start - std::move( - body.data() + part1Length + gapLength, - body.data() + gapLength + position, - body.data() + part1Length); + try { + // This can never fail but std::move and std::move_backward are not noexcept. + if (position < part1Length) { + // Moving the gap towards start so moving elements towards end + std::move_backward( + body.data() + position, + body.data() + part1Length, + body.data() + gapLength + part1Length); + } else { // position > part1Length + // Moving the gap towards end so moving elements towards start + std::move( + body.data() + part1Length + gapLength, + body.data() + gapLength + position, + body.data() + part1Length); + } + part1Length = position; + } catch (...) { + // Ignore any exception } - part1Length = position; } } @@ -280,7 +285,7 @@ public: } /// Retrieve a range of elements into an array - void GetRange(T *buffer, ptrdiff_t position, ptrdiff_t retrieveLength) const noexcept { + void GetRange(T *buffer, ptrdiff_t position, ptrdiff_t retrieveLength) const { // Split into up to 2 ranges, before and after the split then use memcpy on each. ptrdiff_t range1Length = 0; if (position < part1Length) { |