Skip to content

Commit 112d15b

Browse files
committed
fix(canvas) Tweaks from PR feedback.
- Speed improvement to `projectContentsSameForRefreshRequire`. - Remove unused code.
1 parent 9dad5dd commit 112d15b

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

editor/src/components/canvas/canvas-utils.ts

+4
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,10 @@ export function projectContentsSameForRefreshRequire(
22002200
} else {
22012201
for (const [filename, oldProjectTree] of Object.entries(oldProjectContents)) {
22022202
const newProjectTree = newProjectContents[filename]
2203+
// No need to check these further if they have the same reference.
2204+
if (oldProjectTree === newProjectTree) {
2205+
continue
2206+
}
22032207
// If the file can't be found in the other tree, the imports are not the same.
22042208
if (newProjectTree == null) {
22052209
return false

editor/src/components/editor/import-utils.ts

+1-11
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import type {
3131
NodeModules,
3232
} from '../../core/shared/project-file-types'
3333
import { importAlias, importDetails, importsResolution } from '../../core/shared/project-file-types'
34-
import { walkContentsTreeForParseSuccess, type ProjectContentTreeRoot } from '../assets'
34+
import type { ProjectContentTreeRoot } from '../assets'
3535
import type { BuiltInDependencies } from '../../core/es-modules/package-manager/built-in-dependencies-list'
3636
import { withUnderlyingTarget } from './store/editor-state'
3737
import * as EP from '../../core/shared/element-path'
@@ -366,13 +366,3 @@ function removeImportDetails(
366366
importedFromWithin: importedFromWithin,
367367
}
368368
}
369-
370-
export function getProjectImports(projectContents: ProjectContentTreeRoot): {
371-
[filename: string]: Imports
372-
} {
373-
let result: { [filename: string]: Imports } = {}
374-
walkContentsTreeForParseSuccess(projectContents, (filePath, parseSuccess) => {
375-
result[filePath] = parseSuccess.imports
376-
})
377-
return result
378-
}

0 commit comments

Comments
 (0)