Skip to content

Commit cc3d50f

Browse files
Copilotgarrytrinder
andcommitted
Optimize: pre-lowercase filter values to avoid redundant conversions
Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com>
1 parent 9152695 commit cc3d50f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/components/SampleGallery.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ function getMetadataMap(sample: CollectionEntry<'samples'>): Record<string, stri
153153
function applyFilters() {
154154
const query = searchInput.value.toLowerCase().trim();
155155

156-
// Collect active metadata filters
156+
// Collect active metadata filters (pre-lowercase values for comparison)
157157
const activeFilters: Record<string, string> = {};
158158
filterSelects.forEach((select) => {
159159
const key = select.dataset.filterKey!;
160160
const value = select.value;
161161
if (value) {
162-
activeFilters[key] = value;
162+
activeFilters[key] = value.toLowerCase();
163163
}
164164
});
165165

@@ -177,7 +177,7 @@ function getMetadataMap(sample: CollectionEntry<'samples'>): Record<string, stri
177177
// Metadata filter match (all active filters must match)
178178
let metadataMatch = true;
179179
for (const [key, value] of Object.entries(activeFilters)) {
180-
if ((metadata[key] || '').toLowerCase() !== value.toLowerCase()) {
180+
if ((metadata[key] || '').toLowerCase() !== value) {
181181
metadataMatch = false;
182182
break;
183183
}

0 commit comments

Comments
 (0)