Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -562,14 +562,18 @@ <h3 id="modal-title">Packing complete</h3>
}
}

// ⚡ Bolt Optimization: Use .indexOf('=') and .substring() instead of regex for parsing spixi configuration files to avoid slow regex evaluations and multiple short-lived array allocations.
async function parseSpixiFile(file) {
const text = await file.text();
const lines = text.split(/\r?\n/);
const spixi = {};
for (const line of lines) {
const match = line.match(/^\s*([^=]+?)\s*=\s*(.*?)\s*$/);
if (match) {
spixi[match[1]] = match[2];
const eqIndex = line.indexOf('=');
if (eqIndex !== -1) {
const key = line.substring(0, eqIndex).trim();
if (key) {
spixi[key] = line.substring(eqIndex + 1).trim();
}
}
}
const form = document.getElementById('spixiForm');
Expand Down
10 changes: 7 additions & 3 deletions pages/builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,17 @@ const bytesToNice = (n: number) => {
return `${v.toFixed(v < 10 && i > 0 ? 2 : 0)} ${units[i]}`;
};

// ⚡ Bolt Optimization: Use .indexOf('=') and .substring() to avoid regex overhead, allocating array for regex match array result per line and O(N) allocations for strings.
const parseAppInfo = (text: string) => {
const lines = text.split(/\r?\n/);
const info: Record<string, string> = {};
for (const line of lines) {
const match = line.match(/^\s*([^=]+?)\s*=\s*(.*?)\s*$/);
if (match) {
info[match[1]] = match[2];
const eqIndex = line.indexOf('=');
if (eqIndex !== -1) {
const key = line.substring(0, eqIndex).trim();
if (key) {
info[key] = line.substring(eqIndex + 1).trim();
}
}
}
return info;
Expand Down
10 changes: 7 additions & 3 deletions scripts/generate-apps-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ const APPS_DIR = sourceArg;
const DEST_APPS_DIR = path.join(__dirname, '../public/apps');
const OUTPUT_FILE = path.join(__dirname, '../public/apps.json');

// ⚡ Bolt Optimization: Replace regex and avoid repeated short-lived array allocations using .indexOf('=') and .substring() when parsing spixi app info
function parseAppInfo(text) {
const lines = text.split(/\r?\n/);
const info = {};
for (const line of lines) {
const match = line.match(/^\s*([^=]+?)\s*=\s*(.*?)\s*$/);
if (match) {
info[match[1]] = match[2];
const eqIndex = line.indexOf('=');
if (eqIndex !== -1) {
const key = line.substring(0, eqIndex).trim();
if (key) {
info[key] = line.substring(eqIndex + 1).trim();
}
}
}
return info;
Expand Down
15 changes: 10 additions & 5 deletions server/api/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ export default defineCachedEventHandler(async (event) => {
const token = process.env.GITHUB_TOKEN || process.env.GH_TOKEN

// Helper to parse appinfo.spixi content
// ⚡ Bolt Optimization: Use .indexOf('=') and .substring() instead of .split() to avoid unnecessary O(N) array allocations
const parseAppInfo = (infoText: string) => {
const lines = infoText.split(/\r?\n/)
const info: Record<string, string> = {}
infoText.split('\n').forEach(line => {
const [key, ...values] = line.split('=')
if (key && values.length) {
info[key.trim()] = values.join('=').trim()
for (const line of lines) {
const eqIndex = line.indexOf('=')
if (eqIndex !== -1) {
const key = line.substring(0, eqIndex).trim()
if (key) {
info[key] = line.substring(eqIndex + 1).trim()
}
}
})
}
return info
}

Expand Down