mirror of
https://github.com/jellyfin/jellyfin-vue.git
synced 2024-11-27 00:00:23 +00:00
perf: reduce iterations and allocations (#2481)
Some checks failed
Push & Release 🌍 / Automation 🎛️ (push) Has been cancelled
Push & Release 🌍 / ${{ github.event_name == 'push' && 'Unstable 🚀⚠️' || 'Stable 🏷️✅' }} (push) Has been cancelled
Push & Release 🌍 / GitHub CodeQL 🔬 (push) Has been cancelled
Push & Release 🌍 / Deploy 🚀 (push) Has been cancelled
Some checks failed
Push & Release 🌍 / Automation 🎛️ (push) Has been cancelled
Push & Release 🌍 / ${{ github.event_name == 'push' && 'Unstable 🚀⚠️' || 'Stable 🏷️✅' }} (push) Has been cancelled
Push & Release 🌍 / GitHub CodeQL 🔬 (push) Has been cancelled
Push & Release 🌍 / Deploy 🚀 (push) Has been cancelled
* Object.keys and Object.values were used in some for loops, which increased allocations and memory pressure unnecessarily.
This commit is contained in:
parent
c992cbc667
commit
410358c939
@ -32,7 +32,7 @@
|
||||
<tbody>
|
||||
<template v-for="(tracksOnDisc, discNumber) in tracksPerDisc">
|
||||
<tr
|
||||
v-if="Object.keys(tracksPerDisc).length > 1"
|
||||
v-if="hasMultipleDiscs"
|
||||
:key="discNumber"
|
||||
class="disc-header">
|
||||
<td
|
||||
@ -137,6 +137,19 @@ const { data: tracks } = await useBaseItem(getItemsApi, 'getItems')(() => ({
|
||||
}));
|
||||
|
||||
const tracksPerDisc = computed(() => Object.groupBy(tracks.value, ({ ParentIndexNumber }) => ParentIndexNumber!));
|
||||
const hasMultipleDiscs = computed(() => {
|
||||
let loops = 0;
|
||||
|
||||
for (const _ in tracksPerDisc.value) {
|
||||
loops++;
|
||||
|
||||
if (loops > 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Check if a given BaseItemDto is playing
|
||||
|
@ -35,12 +35,12 @@ function replaceTags(input: string, tagMap: TagMap) {
|
||||
let formattedText = input;
|
||||
|
||||
// Iterate through tag mappings
|
||||
for (const [htmlTag, markdownTag] of Object.entries(tagMap)) {
|
||||
for (const htmlTag in tagMap) {
|
||||
const escapedHtmlTag = htmlTag.replaceAll('\\', '\\\\');
|
||||
const regex = new RegExp(escapedHtmlTag, 'gi');
|
||||
|
||||
formattedText = formattedText.replace(regex, (_, p1: string) => {
|
||||
return markdownTag.replace('$1', p1.trim());
|
||||
return tagMap[htmlTag].replace('$1', p1.trim());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1133,12 +1133,12 @@ class PlaybackManagerStore extends CommonStore<PlaybackManagerState> {
|
||||
}
|
||||
};
|
||||
|
||||
for (const [action, handler] of Object.entries(actionHandlers)) {
|
||||
for (const action in actionHandlers) {
|
||||
try {
|
||||
window.navigator.mediaSession.setActionHandler(
|
||||
action as MediaSessionAction,
|
||||
/* eslint-disable-next-line unicorn/no-null */
|
||||
add ? handler : null
|
||||
add ? actionHandlers[action as keyof typeof actionHandlers] ?? null : null
|
||||
);
|
||||
} catch {
|
||||
console.error(
|
||||
|
@ -7,7 +7,6 @@ import eslintImportX from 'eslint-plugin-import-x';
|
||||
// @ts-expect-error - No types available
|
||||
import vueScopedCSS from 'eslint-plugin-vue-scoped-css';
|
||||
import css from 'eslint-plugin-css';
|
||||
// @ts-expect-error - No types available
|
||||
import vue from 'eslint-plugin-vue';
|
||||
// @ts-expect-error - No types available
|
||||
import promise from 'eslint-plugin-promise';
|
||||
@ -94,6 +93,18 @@ const common = [
|
||||
}],
|
||||
'@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: true }],
|
||||
'@typescript-eslint/no-empty-object-type': ['error', { allowInterfaces: 'with-single-extends' }],
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
{
|
||||
args: 'all',
|
||||
argsIgnorePattern: '^_',
|
||||
caughtErrors: 'all',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
destructuredArrayIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_',
|
||||
ignoreRestSiblings: true
|
||||
}
|
||||
],
|
||||
'vue/return-in-computed-property': 'off'
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user