Skip to content

Commit 853f453

Browse files
committed
Avoid some token cloning in filter_tokens_from_list.
Now the cloning only happens on some paths, instead of all paths.
1 parent 55a7324 commit 853f453

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/librustdoc/clean/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2347,19 +2347,19 @@ fn get_all_import_attributes<'hir>(
23472347
}
23482348

23492349
fn filter_tokens_from_list(
2350-
args_tokens: TokenStream,
2350+
args_tokens: &TokenStream,
23512351
should_retain: impl Fn(&TokenTree) -> bool,
23522352
) -> Vec<TokenTree> {
23532353
let mut tokens = Vec::with_capacity(args_tokens.len());
23542354
let mut skip_next_comma = false;
2355-
for token in args_tokens.into_trees() {
2355+
for token in args_tokens.trees() {
23562356
match token {
23572357
TokenTree::Token(Token { kind: TokenKind::Comma, .. }, _) if skip_next_comma => {
23582358
skip_next_comma = false;
23592359
}
2360-
token if should_retain(&token) => {
2360+
token if should_retain(token) => {
23612361
skip_next_comma = false;
2362-
tokens.push(token);
2362+
tokens.push(token.clone());
23632363
}
23642364
_ => {
23652365
skip_next_comma = true;
@@ -2417,7 +2417,7 @@ fn add_without_unwanted_attributes<'hir>(
24172417
match normal.item.args {
24182418
ast::AttrArgs::Delimited(ref mut args) => {
24192419
let tokens =
2420-
filter_tokens_from_list(args.tokens.clone(), |token| {
2420+
filter_tokens_from_list(&args.tokens, |token| {
24212421
!matches!(
24222422
token,
24232423
TokenTree::Token(

0 commit comments

Comments
 (0)