Optimize getEffectivelyEnabledItems to reduce memory allocation and improve performance (#34)
This commit is contained in:
commit
dc00c3633d
@ -287,23 +287,20 @@ function computeEffectiveItemStates(config) {
|
|||||||
function getEffectivelyEnabledItems(config) {
|
function getEffectivelyEnabledItems(config) {
|
||||||
const effectiveStates = computeEffectiveItemStates(config);
|
const effectiveStates = computeEffectiveItemStates(config);
|
||||||
|
|
||||||
return {
|
const result = {
|
||||||
prompts: new Set(
|
prompts: new Set(),
|
||||||
Object.entries(effectiveStates.prompts)
|
instructions: new Set(),
|
||||||
.filter(([, state]) => state.enabled)
|
chatmodes: new Set()
|
||||||
.map(([itemName]) => itemName)
|
|
||||||
),
|
|
||||||
instructions: new Set(
|
|
||||||
Object.entries(effectiveStates.instructions)
|
|
||||||
.filter(([, state]) => state.enabled)
|
|
||||||
.map(([itemName]) => itemName)
|
|
||||||
),
|
|
||||||
chatmodes: new Set(
|
|
||||||
Object.entries(effectiveStates.chatmodes)
|
|
||||||
.filter(([, state]) => state.enabled)
|
|
||||||
.map(([itemName]) => itemName)
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
for (const section of ["prompts", "instructions", "chatmodes"]) {
|
||||||
|
for (const itemName in effectiveStates[section]) {
|
||||||
|
if (effectiveStates[section][itemName].enabled) {
|
||||||
|
result[section].add(itemName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user