refactor(services): use Set instead of Arrays for faster lookups

This commit is contained in:
Panagiotis Papadopoulos
2025-01-02 14:59:26 +01:00
parent 6fe4027a75
commit baea3bdcdd
4 changed files with 11 additions and 11 deletions

View File

@@ -9,7 +9,7 @@ import BUILTIN_ATTRIBUTES from "./builtin_attributes.js";
import BNote from "../becca/entities/bnote.js";
import { AttributeRow } from '../becca/entities/rows.js';
const ATTRIBUTE_TYPES = ['label', 'relation'];
const ATTRIBUTE_TYPES = new Set(['label', 'relation']);
function getNotesWithLabel(name: string, value?: string): BNote[] {
const query = attributeFormatter.formatAttrForSearch({type: 'label', name, value}, value !== undefined);
@@ -99,7 +99,7 @@ function getAttributeNames(type: string, nameLike: string) {
}
function isAttributeType(type: string): boolean {
return ATTRIBUTE_TYPES.includes(type);
return ATTRIBUTE_TYPES.has(type);
}
function isAttributeDangerous(type: string, name: string): boolean {