Use std::swap in string

The STL spec says that swap is located in the string_view header anyawy.
Performance-wise this is a noop, but it’s slightly cleaner.
This commit is contained in:
Steven Dee (Jōshin) 2024-06-15 22:07:34 -07:00
parent f9dd5683a4
commit 15ffab0683
No known key found for this signature in database
2 changed files with 2 additions and 4 deletions

View file

@ -87,10 +87,7 @@ class string
void swap(string& s) noexcept
{
char tmp[__::string_size];
__builtin_memcpy(tmp, blob, __::string_size);
__builtin_memcpy(blob, s.blob, __::string_size);
__builtin_memcpy(s.blob, tmp, __::string_size);
std::swap(blob, s.blob);
}
string(string&& s) noexcept

View file

@ -2,6 +2,7 @@
// vi: set et ft=cpp ts=4 sts=4 sw=4 fenc=utf-8 :vi
#ifndef COSMOPOLITAN_CTL_STRINGVIEW_H_
#define COSMOPOLITAN_CTL_STRINGVIEW_H_
#include <__utility/swap.h>
namespace ctl {