Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,38 @@ export abstract class PrimitiveComponent<
return this.parent?.getGroup?.() ?? null
}

doInitialOptimizeSelectorCache() {
if (!this.isSubcircuit) return
const ports = this.selectAll("port")

for (const port of ports) {
const parentAliases = port.parent?.getNameAndAliases()
const portAliases = port.getNameAndAliases()
if (!parentAliases) continue
for (const parentAlias of parentAliases) {
for (const portAlias of portAliases) {
const selectors = [
`.${parentAlias} > .${portAlias}`,
`.${parentAlias} .${portAlias}`,
]
for (const selector of selectors) {
const ar = this._cachedSelectAllQueries.get(selector)
if (ar) {
ar.push(port)
} else {
this._cachedSelectAllQueries.set(selector, [port])
}
}
}
}
}
for (const [selector, ports] of this._cachedSelectAllQueries.entries()) {
if (ports.length === 1) {
this._cachedSelectOneQueries.set(selector, ports[0])
}
}
}

_cachedSelectAllQueries: Map<string, PrimitiveComponent[]> = new Map()
selectAll(selectorRaw: string): PrimitiveComponent[] {
if (this._cachedSelectAllQueries.has(selectorRaw)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export const preprocessSelector = (selector: string) => {
return selector
.replace(/ pin/g, " port")
.replace(/ subcircuit\./g, " group[isSubcircuit=true]")
.replace(/([^ ])\>([^ ])/g, "$1 > $2")
.trim()
}
1 change: 1 addition & 0 deletions lib/components/base-components/Renderable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const orderedRenderPhases = [
"SourceRender",
"SourceParentAttachment",
"PortMatching",
"OptimizeSelectorCache",
"SourceTraceRender",
"SourceAddConnectivityMapKey",
"SchematicComponentRender",
Expand Down