mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-05 09:20:29 +00:00
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:
parent
f9dd5683a4
commit
15ffab0683
2 changed files with 2 additions and 4 deletions
|
@ -87,10 +87,7 @@ class string
|
||||||
|
|
||||||
void swap(string& s) noexcept
|
void swap(string& s) noexcept
|
||||||
{
|
{
|
||||||
char tmp[__::string_size];
|
std::swap(blob, s.blob);
|
||||||
__builtin_memcpy(tmp, blob, __::string_size);
|
|
||||||
__builtin_memcpy(blob, s.blob, __::string_size);
|
|
||||||
__builtin_memcpy(s.blob, tmp, __::string_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string(string&& s) noexcept
|
string(string&& s) noexcept
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// vi: set et ft=cpp ts=4 sts=4 sw=4 fenc=utf-8 :vi
|
// vi: set et ft=cpp ts=4 sts=4 sw=4 fenc=utf-8 :vi
|
||||||
#ifndef COSMOPOLITAN_CTL_STRINGVIEW_H_
|
#ifndef COSMOPOLITAN_CTL_STRINGVIEW_H_
|
||||||
#define COSMOPOLITAN_CTL_STRINGVIEW_H_
|
#define COSMOPOLITAN_CTL_STRINGVIEW_H_
|
||||||
|
#include <__utility/swap.h>
|
||||||
|
|
||||||
namespace ctl {
|
namespace ctl {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue