MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / move

Method move

include/stringzilla/stringzilla.hpp:2704–2718  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2702 }
2703
2704 void move(basic_string &other) noexcept {
2705 // We can't just assign the other string state, as its start address may be somewhere else on the stack.
2706 sz_ptr_t string_start;
2707 sz_size_t string_length;
2708 sz_size_t string_space;
2709 sz_bool_t string_is_external;
2710 sz_string_unpack(&other.string_, &string_start, &string_length, &string_space, &string_is_external);
2711
2712 // Acquire the old string's value bitwise
2713 *(&string_) = *(&other.string_);
2714 // Reposition the string start pointer to the stack if it fits.
2715 // Ternary condition may be optimized to a branchless version.
2716 string_.internal.start = string_is_external ? string_.internal.start : &string_.internal.chars[0];
2717 sz_string_init(&other.string_); // Discard the other string.
2718 }
2719
2720 public:
2721 // STL compatibility

Callers 1

sz_moveFunction · 0.80

Calls 2

sz_string_unpackFunction · 0.85
sz_string_initFunction · 0.85

Tested by

no test coverage detected