Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
perf(studio): remove quadratic region scan in LaTeX preprocessing (#7538)
Michael Han2989b178e1bf
diff --git a/studio/frontend/src/lib/latex.ts b/studio/frontend/src/lib/latex.tsindex edf98756020..ccccccbbe43 100644--- a/studio/frontend/src/lib/latex.ts+++ b/studio/frontend/src/lib/latex.ts@@ -33,19 +33,20 @@ function findCodeBlockRegions(content: string): Array<[number, number]> {regions.push([match.index, match.index + match[0].length]);}- // Inline code: `...` (skip spans inside fenced blocks, filtered below)+ // Inline code: `...`, skipped when inside a fenced block. Both loops yield+ // ascending matches, so walk the fenced list with a cursor rather than+ // rescanning it per match (was quadratic on code-heavy text).+ const fencedCount = regions.length;const inlineRe = /`[^`\n]+`/g;+ let fencedIndex = 0;while ((match = inlineRe.exec(content)) !== null) {const start = match.index;const end = start + match[0].length;- let inside = false;- for (const [rs, re] of regions) {- if (start >= rs && end <= re) {- inside = true;- break;- }+ while (fencedIndex < fencedCount && regions[fencedIndex][1] <= start) {+ fencedIndex += 1;}- if (!inside) {+ const fenced = fencedIndex < fencedCount ? regions[fencedIndex] : null;+ if (!(fenced && start >= fenced[0] && end <= fenced[1])) {regions.push([start, end]);}}