Skip to content

Commit e3034bd

Browse files
committed
unwrap comments Rc
1 parent c095871 commit e3034bd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/swc/parse_swc_ast.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::collections::{HashMap};
22
use std::path::PathBuf;
3+
use std::rc::Rc;
34
use swc_common::{
45
errors::{Handler, Emitter, DiagnosticBuilder},
56
FileName, comments::{Comment, SingleThreadedComments, SingleThreadedCommentsMap}, SourceFile, BytePos
@@ -100,8 +101,8 @@ fn parse_inner<'a>(file_path: &PathBuf, file_text: &'a str) -> Result<ParsedSour
100101
// It is much more performant to look into HashMaps instead of CHashMaps
101102
// because then locking on each comment lookup is not necessary. We don't
102103
// need to support multi-threading so convert to HashMap.
103-
let cmts = &*comments.borrow();
104-
cmts.into_iter().map(|(k, v)| (k.to_owned(), v.to_owned())).collect()
104+
let comments = Rc::try_unwrap(comments).expect("Failed to unwrap comments Rc").into_inner();
105+
comments.into_iter().collect()
105106
}
106107
}
107108

0 commit comments

Comments
 (0)