mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-13 11:39:41 +03:00
perf(core): sort integrations once per rebuild (#59402)
This commit is contained in:
committed by
GitHub
Unverified
parent
cc4faf46bf
commit
a0dca06854
@@ -385,6 +385,16 @@ const layer = Layer.effect(
|
||||
),
|
||||
})
|
||||
|
||||
const sorted = new WeakMap<Map<ID, Entry>, Entry[]>()
|
||||
const sortedEntries = () => {
|
||||
const integrations = state.get().integrations
|
||||
const cached = sorted.get(integrations)
|
||||
if (cached) return cached
|
||||
const entries = Array.from(integrations.values()).toSorted((a, b) => a.ref.name.localeCompare(b.ref.name))
|
||||
sorted.set(integrations, entries)
|
||||
return entries
|
||||
}
|
||||
|
||||
const createCredential = Effect.fnUntraced(function* (input: Parameters<Credential.Interface["create"]>[0]) {
|
||||
if (input.label !== undefined) return yield* credentials.create(input)
|
||||
const name = state.get().integrations.get(input.integrationID)?.ref.name ?? input.integrationID
|
||||
@@ -715,9 +725,7 @@ const layer = Layer.effect(
|
||||
}),
|
||||
list: Effect.fn("Integration.list")(function* () {
|
||||
const saved = Map.groupBy(yield* credentials.all(), (credential) => credential.integrationID)
|
||||
return Array.from(state.get().integrations.values(), (entry) =>
|
||||
project(entry, resolveConnections(entry, saved.get(entry.ref.id) ?? [])),
|
||||
).toSorted((a, b) => a.name.localeCompare(b.name))
|
||||
return sortedEntries().map((entry) => project(entry, resolveConnections(entry, saved.get(entry.ref.id) ?? [])))
|
||||
}),
|
||||
connection: {
|
||||
active: Effect.fn("Integration.connection.active")(function* (id) {
|
||||
|
||||
Reference in New Issue
Block a user