@@ -27,30 +27,23 @@ Pieces::collect (std::string &&to_parse, bool append_newline)
27
27
{
28
28
auto piece_slice = collect_pieces (to_parse.c_str (), append_newline);
29
29
30
- rust_debug (" [ARTHUR] %p, %lu" , (const void *) piece_slice.base_ptr ,
31
- piece_slice.len );
32
-
33
30
// this performs multiple copies, can we avoid them maybe?
34
- // auto pieces = std::vector<Piece> (piece_slice.base_ptr,
35
- // piece_slice.base_ptr + piece_slice.len);
36
-
37
- return Pieces (piece_slice, std::move (to_parse));
31
+ // TODO: Instead of just creating a vec of, basically, `ffi::Piece`s, we
32
+ // should transform them into the proper C++ type which we can work with. so
33
+ // transform all the strings into C++ strings? all the Option<T> into
34
+ // tl::optional<T>?
35
+ auto pieces = std::vector<Piece> (piece_slice.base_ptr ,
36
+ piece_slice.base_ptr + piece_slice.len );
37
+
38
+ return Pieces (std::move (pieces), piece_slice, std::move (to_parse));
38
39
}
39
40
40
- Pieces::~Pieces ()
41
- {
42
- std::cerr << " Arthur: destoying pieces. this: " << (void *) this
43
- << " slice: " << slice.base_ptr << std::endl;
44
- destroy_pieces (slice);
45
- }
41
+ Pieces::~Pieces () { destroy_pieces (slice); }
46
42
47
- Pieces::Pieces (const Pieces &other) : to_parse (other.to_parse)
43
+ Pieces::Pieces (const Pieces &other)
44
+ : pieces_vector (other.pieces_vector), to_parse (other.to_parse)
48
45
{
49
46
slice = clone_pieces (other.slice .base_ptr , other.slice .len , other.slice .cap );
50
- std::cerr << " Arthur: copying pieces: other.to_parse: "
51
- << (void *) other.to_parse .c_str ()
52
- << " ours to_parse: " << (void *) to_parse.c_str () << std::endl;
53
- // auto pieces = std::vector (slice.base_ptr, slice.base_ptr + slice.len);
54
47
}
55
48
56
49
Pieces &
@@ -63,13 +56,11 @@ Pieces::operator= (const Pieces &other)
63
56
}
64
57
65
58
Pieces::Pieces (Pieces &&other)
66
- : slice (
67
- clone_pieces (other.slice.base_ptr, other.slice.len, other.slice.cap)),
59
+ : pieces_vector (std::move (other.pieces_vector)),
60
+ slice (
61
+ clone_pieces (other.slice.base_ptr, other.slice.len, other.slice.cap)),
68
62
to_parse (std::move (other.to_parse))
69
- {
70
- std::cerr << " Arthur: moving pieces. to_parse: " << (void *) to_parse.c_str ()
71
- << " base_ptr/slice: " << (void *) slice.base_ptr << std::endl;
72
- }
63
+ {}
73
64
74
65
} // namespace Fmt
75
66
} // namespace Rust
0 commit comments