mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 15:14:56 -04:00
fix(frontend): improve performance by reducing array constructions
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
28f04f461c
commit
ced4cd953c
6 changed files with 26 additions and 24 deletions
|
@ -12,7 +12,7 @@
|
|||
*/
|
||||
export const calculateLineStartIndexes = (markdownContentLines: string[]): number[] => {
|
||||
return markdownContentLines.reduce((state, line, lineIndex, lines) => {
|
||||
const lastIndex = lineIndex === 0 ? 0 : state[lineIndex - 1] + lines[lineIndex - 1].length + 1
|
||||
return [...state, lastIndex]
|
||||
}, [] as number[])
|
||||
state[lineIndex] = lineIndex === 0 ? 0 : state[lineIndex - 1] + lines[lineIndex - 1].length + 1
|
||||
return state
|
||||
}, new Array<number>(markdownContentLines.length))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue