Agent Skillspierrecomputer/pierre › performance

performance

GitHub

指导优化循环、集合处理及遍历逻辑,避免嵌套循环和O(n^2)操作。建议预计算昂贵值、使用索引或反向扫描,并在布尔逻辑变更后简化控制流以提升性能与正确性。

.agents/skills/performance/SKILL.md pierrecomputer/pierre

Trigger Scenarios

修改循环结构 处理集合数据 调整无效化逻辑 树或Diff遍历 虚拟渲染计算

Install

npx skills add pierrecomputer/pierre --skill performance -g -y
More Options

Non-standard path

npx skills add https://github.com/pierrecomputer/pierre/tree/main/.agents/skills/performance -g -y

Use without installing

npx skills use pierrecomputer/pierre@performance

指定 Agent (Claude Code)

npx skills add pierrecomputer/pierre --skill performance -a claude-code -g -y

安装 repo 全部 skill

npx skills add pierrecomputer/pierre --all -g -y

预览 repo 内 skill

npx skills add pierrecomputer/pierre --list

SKILL.md

Frontmatter
{
    "name": "performance",
    "description": "Use when changing loops, collection processing, invalidation logic, tree\/diff traversal, path scanning, virtualized rendering calculations, or any code where repeated scans or boolean control flow affect performance or correctness."
}

Performance

Avoid nested loops and O(n^2) operations unless there is a clear reason.

  • Calculate expensive values once before a loop, not inside it.
  • Prefer precomputed maps, sets, indexes, or a single backward scan over nested repeated scans.
  • If you need to know whether meaningful elements remain, compute that boundary once before the main loop.

Example of the preferred pattern:

let lastMeaningfulIndex = items.length - 1;
for (let i = items.length - 1; i >= 0; i--) {
  if (items[i].someCondition) {
    lastMeaningfulIndex = i;
    break;
  }
}

for (let i = 0; i <= lastMeaningfulIndex; i++) {
  const isLast = i === lastMeaningfulIndex;
  // ...
}

After changing boolean logic or invalidation paths, simplify the final control flow before calling the work done. If code is already inside if (foo), do not keep || foo in assignments inside that block.

Version History

  • 3b70f81 Current 2026-07-24 22:03

Same Skill Collection

.agents/skills/browser-automation/SKILL.md
.agents/skills/git-commits/SKILL.md
.agents/skills/testing-and-verification/SKILL.md
.agents/skills/tooling-and-dependencies/SKILL.md
.agents/skills/typescript-monorepo/SKILL.md
.agents/skills/worktrees-and-dev-servers/SKILL.md
skills/diffs/SKILL.md
skills/theme/SKILL.md
skills/theming/SKILL.md
skills/trees/SKILL.md

Metadata

Files
0
Version
3b70f81
Hash
92904dfc
Indexed
2026-07-24 22:03

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-20 17:53
浙ICP备14020137号-1 $방문자$