aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/fstream
diff options
context:
space:
mode:
authormikhnenko <mikhnenko@yandex-team.com>2023-10-14 13:00:57 +0300
committermikhnenko <mikhnenko@yandex-team.com>2023-10-14 13:22:30 +0300
commit4371a757495f375ca7c5b1730f4e9f741a71ec40 (patch)
treebe8f3405e7b0534d29bfb8eec493c0dbe108adc5 /contrib/libs/cxxsupp/libcxx/include/fstream
parentecb10029a72bb21f92858ff3c0d76c8f255cf4ba (diff)
downloadydb-4371a757495f375ca7c5b1730f4e9f741a71ec40.tar.gz
Update libc++ to 1 May 2022 639b9618f46d75f4dabd2082b3f6ba8433c287bf
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/fstream')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/fstream27
1 files changed, 20 insertions, 7 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/fstream b/contrib/libs/cxxsupp/libcxx/include/fstream
index 907c59e888..7608daa3f9 100644
--- a/contrib/libs/cxxsupp/libcxx/include/fstream
+++ b/contrib/libs/cxxsupp/libcxx/include/fstream
@@ -419,25 +419,38 @@ basic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs)
basic_streambuf<char_type, traits_type>::swap(__rhs);
if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
{
- _VSTD::swap(__extbuf_, __rhs.__extbuf_);
- _VSTD::swap(__extbufnext_, __rhs.__extbufnext_);
- _VSTD::swap(__extbufend_, __rhs.__extbufend_);
+ // Neither *this nor __rhs uses the small buffer, so we can simply swap the pointers.
+ std::swap(__extbuf_, __rhs.__extbuf_);
+ std::swap(__extbufnext_, __rhs.__extbufnext_);
+ std::swap(__extbufend_, __rhs.__extbufend_);
}
else
{
- ptrdiff_t __ln = __extbufnext_ - __extbuf_;
- ptrdiff_t __le = __extbufend_ - __extbuf_;
- ptrdiff_t __rn = __rhs.__extbufnext_ - __rhs.__extbuf_;
- ptrdiff_t __re = __rhs.__extbufend_ - __rhs.__extbuf_;
+ ptrdiff_t __ln = __extbufnext_ ? __extbufnext_ - __extbuf_ : 0;
+ ptrdiff_t __le = __extbufend_ ? __extbufend_ - __extbuf_ : 0;
+ ptrdiff_t __rn = __rhs.__extbufnext_ ? __rhs.__extbufnext_ - __rhs.__extbuf_ : 0;
+ ptrdiff_t __re = __rhs.__extbufend_ ? __rhs.__extbufend_ - __rhs.__extbuf_ : 0;
if (__extbuf_ == __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
{
+ // *this uses the small buffer, but __rhs doesn't.
__extbuf_ = __rhs.__extbuf_;
__rhs.__extbuf_ = __rhs.__extbuf_min_;
+ std::memmove(__rhs.__extbuf_min_, __extbuf_min_, sizeof(__extbuf_min_));
}
else if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ == __rhs.__extbuf_min_)
{
+ // *this doesn't use the small buffer, but __rhs does.
__rhs.__extbuf_ = __extbuf_;
__extbuf_ = __extbuf_min_;
+ std::memmove(__extbuf_min_, __rhs.__extbuf_min_, sizeof(__extbuf_min_));
+ }
+ else
+ {
+ // Both *this and __rhs use the small buffer.
+ char __tmp[sizeof(__extbuf_min_)];
+ std::memmove(__tmp, __extbuf_min_, sizeof(__extbuf_min_));
+ std::memmove(__extbuf_min_, __rhs.__extbuf_min_, sizeof(__extbuf_min_));
+ std::memmove(__rhs.__extbuf_min_, __tmp, sizeof(__extbuf_min_));
}
__extbufnext_ = __extbuf_ + __rn;
__extbufend_ = __extbuf_ + __re;