File tree Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -49,13 +49,11 @@ impl Token {
49
49
pub fn append_comments ( & self , comments : & mut Vec < String > ) {
50
50
Python :: with_gil ( |py| {
51
51
let pylist = self . comments . bind ( py) ;
52
- for comment in comments. iter ( ) {
52
+ for comment in comments. drain ( .. ) {
53
53
if let Err ( _) = pylist. append ( comment) {
54
54
panic ! ( "Failed to append comments to the Python list" ) ;
55
55
}
56
56
}
57
57
} ) ;
58
- // Simulate `Vec::append`.
59
- let _ = std:: mem:: replace ( comments, Vec :: new ( ) ) ;
60
58
}
61
59
}
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ impl<'a> TokenizerState<'a> {
111
111
112
112
fn tokenize ( & mut self ) -> Result < Vec < Token > , TokenizerError > {
113
113
self . scan ( None ) ?;
114
- Ok ( std:: mem:: replace ( & mut self . tokens , Vec :: new ( ) ) )
114
+ Ok ( std:: mem:: take ( & mut self . tokens ) )
115
115
}
116
116
117
117
fn scan ( & mut self , until_peek_char : Option < char > ) -> Result < ( ) , TokenizerError > {
@@ -234,7 +234,7 @@ impl<'a> TokenizerState<'a> {
234
234
self . column ,
235
235
self . start ,
236
236
self . current - 1 ,
237
- std:: mem:: replace ( & mut self . comments , Vec :: new ( ) ) ,
237
+ std:: mem:: take ( & mut self . comments ) ,
238
238
) ) ;
239
239
240
240
// If we have either a semicolon or a begin token before the command's token, we'll parse
You can’t perform that action at this time.
0 commit comments