Skip to content

Commit f316186

Browse files
committed
perf: drop BarrelExport::export_name
1 parent 2def69b commit f316186

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

src/exports.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use crate::{Context, SymbolKind};
1313

1414
#[derive(Debug, Clone)]
1515
pub struct BarrelExport {
16-
pub export_name: String,
1716
pub source_path: String,
1817
pub kind: SymbolKind,
1918
pub source_file_path: Option<PathBuf>,
@@ -72,7 +71,6 @@ fn collect_into(
7271
exports.insert(
7372
"default".to_string(),
7473
BarrelExport {
75-
export_name: "default".to_string(),
7674
source_path: barrel_export_path(file, barrel_dir, alias),
7775
kind: SymbolKind::Default,
7876
source_file_path: Some(file.to_path_buf()),
@@ -99,11 +97,9 @@ fn handle_export_all(
9997

10098
match &decl.exported {
10199
Some(name_node) => {
102-
let name = name_node.name().to_string();
103100
exports.insert(
104-
name.clone(),
101+
name_node.name().to_string(),
105102
BarrelExport {
106-
export_name: name,
107103
source_path: resolve_export_path(from_module, alias),
108104
kind: SymbolKind::Named,
109105
source_file_path: resolved,
@@ -132,17 +128,14 @@ fn handle_export_named(
132128
let source_path = resolve_export_path(from_module, alias);
133129

134130
for spec in &decl.specifiers {
135-
let exported = spec.exported.name().to_string();
136-
let original = spec.local.name();
137-
let kind = if original == "default" {
131+
let kind = if spec.local.name() == "default" {
138132
SymbolKind::Default
139133
} else {
140134
SymbolKind::Named
141135
};
142136
exports.insert(
143-
exported.clone(),
137+
spec.exported.name().to_string(),
144138
BarrelExport {
145-
export_name: exported,
146139
source_path: source_path.clone(),
147140
kind,
148141
source_file_path: resolved.clone(),
@@ -153,9 +146,8 @@ fn handle_export_named(
153146
let source_path = barrel_export_path(file, barrel_dir, alias);
154147
for name in declaration_names(declaration) {
155148
exports.insert(
156-
name.clone(),
149+
name,
157150
BarrelExport {
158-
export_name: name,
159151
source_path: source_path.clone(),
160152
kind: SymbolKind::Named,
161153
source_file_path: Some(file.to_path_buf()),

src/reaper.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ fn format_import(
6767
}
6868
SymbolKind::Named => {
6969
let binding = match &imp.local_name {
70-
Some(local) => format!("{} as {local}", export.export_name),
71-
None => export.export_name.clone(),
70+
Some(local) => format!("{} as {local}", imp.import_name),
71+
None => imp.import_name.clone(),
7272
};
7373
format!("import {type_prefix}{{ {binding} }} from '{source_path}';")
7474
}

0 commit comments

Comments
 (0)