From 469c5c0d3f0b267ff6d8fc6267341e7affa65fce Mon Sep 17 00:00:00 2001 From: likui <2218301630@qq.com> Date: Mon, 1 Jun 2020 23:00:23 +0800 Subject: [PATCH] refactor: change `dependencies` type with `Set` --- src/node/utils/cssUtils.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/node/utils/cssUtils.ts b/src/node/utils/cssUtils.ts index 48d468363bec58..cff607d8d1b4a5 100644 --- a/src/node/utils/cssUtils.ts +++ b/src/node/utils/cssUtils.ts @@ -171,13 +171,15 @@ export function getCssImportBoundaries( return boundaries } -export function recordCssImportChain(dependencies: string[], filePath: string) { +export function recordCssImportChain( + dependencies: Set, + filePath: string +) { const preImportees = cssImporteeMap.get(filePath) - const currentImportees = new Set(dependencies) // if import code change, should removed unused previous importee if (preImportees) { for (const preImportee of preImportees) { - if (!currentImportees.has(preImportee)) { + if (!dependencies.has(preImportee)) { const importers = cssImporterMap.get(preImportee) if (importers) { importers.delete(filePath) @@ -186,7 +188,7 @@ export function recordCssImportChain(dependencies: string[], filePath: string) { } } - currentImportees.forEach((dependency) => { + dependencies.forEach((dependency) => { if (cssImporterMap.has(dependency)) { cssImporterMap.get(dependency)!.add(filePath) } else { @@ -194,5 +196,5 @@ export function recordCssImportChain(dependencies: string[], filePath: string) { } }) - cssImporteeMap.set(filePath, currentImportees) + cssImporteeMap.set(filePath, dependencies) }