Skip to content

Commit

Permalink
refactor(core): optmize sourcemap type
Browse files Browse the repository at this point in the history
  • Loading branch information
h-a-n-a committed Dec 26, 2021
1 parent 7741656 commit 135902a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions core/src/source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@ pub struct SourceMap {
impl SourceMap {
pub fn new(
mappings: &str,
file: Option<String>,
names: Vec<String>,
sources_content: Vec<Option<String>>,
source_root: Option<String>,
sources: Vec<Option<String>>,
file: Option<&str>,
names: Vec<&str>,
sources_content: Vec<Option<&str>>,
source_root: Option<&str>,
sources: Vec<Option<&str>>,
) -> Self {
Self {
version: VERSION,
mappings: String::from(mappings),
file,
names,
sources_content,
source_root,
sources,
file: file.map(|f| f.to_owned()),
names: names.iter().map(|&n| n.to_owned()).collect::<Vec<String>>(),
sources_content: sources_content
.iter()
.map(|s| s.map(|s| s.to_owned()))
.collect(),
source_root: source_root.map(|s| s.to_owned()),
sources: sources.iter().map(|s| s.map(|s| s.to_owned())).collect(),
}
}

Expand Down

0 comments on commit 135902a

Please sign in to comment.