@@ -18,43 +18,34 @@ struct SwiftMangledName {
1818
1919 std::string str () const ;
2020
21- // streaming labels or ints into a SwiftMangledName just appends them
22- template <typename Tag>
23- SwiftMangledName& operator <<(TrapLabel<Tag> label) {
24- assert (label && " using undefined label in mangled name" );
25- parts.emplace_back (label);
26- return *this ;
27- }
21+ // let's avoid copying as long as we don't need it
22+ SwiftMangledName () = default ;
23+ SwiftMangledName (const SwiftMangledName&) = delete ;
24+ SwiftMangledName& operator =(const SwiftMangledName&) = delete ;
25+ SwiftMangledName (SwiftMangledName&&) = default ;
26+ SwiftMangledName& operator =(SwiftMangledName&&) = default ;
2827
29- SwiftMangledName& operator <<(unsigned i) {
30- parts.emplace_back (i);
31- return *this ;
32- }
28+ // streaming labels or ints into a SwiftMangledName just appends them
29+ SwiftMangledName& operator <<(UntypedTrapLabel label) &;
30+ SwiftMangledName& operator <<(unsigned i) &;
3331
3432 // streaming string-like stuff will add a new part it only if strictly required, otherwise it will
3533 // append to the last part if it is a string
3634 template <typename T>
37- SwiftMangledName& operator <<(T&& arg) {
35+ SwiftMangledName& operator <<(T&& arg) & {
3836 if (parts.empty () || !std::holds_alternative<std::string>(parts.back ())) {
3937 parts.emplace_back (" " );
4038 }
4139 std::get<std::string>(parts.back ()) += std::forward<T>(arg);
4240 return *this ;
4341 }
4442
45- SwiftMangledName& operator <<(SwiftMangledName&& other) {
46- parts.reserve (parts.size () + other.parts .size ());
47- for (auto & p : other.parts ) {
48- parts.emplace_back (std::move (p));
49- }
50- other.parts .clear ();
51- return *this ;
52- }
43+ SwiftMangledName& operator <<(SwiftMangledName&& other) &;
44+ SwiftMangledName& operator <<(const SwiftMangledName& other) &;
5345
54- SwiftMangledName& operator <<(const SwiftMangledName& other) {
55- parts.reserve (parts.size () + other.parts .size ());
56- parts.insert (parts.end (), other.parts .begin (), other.parts .end ());
57- return *this ;
46+ template <typename T>
47+ SwiftMangledName&& operator <<(T&& arg) && {
48+ return std::move (operator <<(std::forward<T>(arg)));
5849 }
5950};
6051
0 commit comments