Enhance build-outline.mjs by increasing concurrency limit from 32 to 64 for icon processing and optimizing filename collection using a Set for O(1) lookup.
This commit is contained in:
parent
bdf6b4ea52
commit
d0a295babf
|
|
@ -36,7 +36,7 @@ const buildOutline = async () => {
|
||||||
const icons = getAllIcons(true)
|
const icons = getAllIcons(true)
|
||||||
const compileOptions = getCompileOptions()
|
const compileOptions = getCompileOptions()
|
||||||
|
|
||||||
// Process all strokes in parallel
|
// Process all strokes in parallel (200, 300, 400 at once)
|
||||||
await Promise.all(Object.entries(strokes).map(async ([strokeName, stroke]) => {
|
await Promise.all(Object.entries(strokes).map(async ([strokeName, stroke]) => {
|
||||||
let filesList = {}
|
let filesList = {}
|
||||||
|
|
||||||
|
|
@ -50,8 +50,8 @@ const buildOutline = async () => {
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
// Collect filenames for later cleanup
|
// Collect filenames for later cleanup (Set for O(1) lookup)
|
||||||
filesList[type] = iconsToProcess.map(({ name, unicode }) => `u${unicode.toUpperCase()}-${name}.svg`)
|
filesList[type] = new Set(iconsToProcess.map(({ name, unicode }) => `u${unicode.toUpperCase()}-${name}.svg`))
|
||||||
|
|
||||||
// Process icons in parallel with concurrency limit
|
// Process icons in parallel with concurrency limit
|
||||||
let processed = 0
|
let processed = 0
|
||||||
|
|
@ -110,7 +110,7 @@ const buildOutline = async () => {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`\nError processing ${strokeName}/${type}/${name}:`, error.message)
|
console.error(`\nError processing ${strokeName}/${type}/${name}:`, error.message)
|
||||||
}
|
}
|
||||||
}, 32) // 32 concurrent tasks
|
}, 64) // 64 concurrent tasks
|
||||||
|
|
||||||
console.log(`Stroke ${strokeName}/${type}: ${processed} processed, ${cached} cached`)
|
console.log(`Stroke ${strokeName}/${type}: ${processed} processed, ${cached} cached`)
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +119,7 @@ const buildOutline = async () => {
|
||||||
for (const [type] of Object.entries(icons)) {
|
for (const [type] of Object.entries(icons)) {
|
||||||
const existedFiles = (await glob(resolve(DIR, `icons-outlined/${strokeName}/${type}/*.svg`))).map(file => basename(file))
|
const existedFiles = (await glob(resolve(DIR, `icons-outlined/${strokeName}/${type}/*.svg`))).map(file => basename(file))
|
||||||
existedFiles.forEach(file => {
|
existedFiles.forEach(file => {
|
||||||
if (filesList[type].indexOf(file) === -1) {
|
if (!filesList[type].has(file)) {
|
||||||
console.log('Remove:', file)
|
console.log('Remove:', file)
|
||||||
fs.unlinkSync(resolve(DIR, `icons-outlined/${strokeName}/${type}/${file}`))
|
fs.unlinkSync(resolve(DIR, `icons-outlined/${strokeName}/${type}/${file}`))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue