* Refactor Gemini model display: filter old versions, group low/high pro, and improve naming * Fix potential negative minutes and refine Gemini 3 Pro grouping logic based on PR feedback * The account change process has been sped up * Address PR review: enhance error message and parameterize polling interval in process handler * Address PR review: fix potential race condition in database backup logic * fix: prevent renderer white screen and harden sentry gating * feat: localize model labels * chore: enable hoisted node-linker * chore: ignore .agent/.claude/.codex in prettier --------- Co-authored-by: Draculabo <[email protected]>
33 lines
768 B
Markdown
33 lines
768 B
Markdown
---
|
|
title: Combine Multiple Array Iterations
|
|
impact: LOW-MEDIUM
|
|
impactDescription: reduces iterations
|
|
tags: javascript, arrays, loops, performance
|
|
---
|
|
|
|
## Combine Multiple Array Iterations
|
|
|
|
Multiple `.filter()` or `.map()` calls iterate the array multiple times. Combine into one loop.
|
|
|
|
**Incorrect (3 iterations):**
|
|
|
|
```typescript
|
|
const admins = users.filter((u) => u.isAdmin);
|
|
const testers = users.filter((u) => u.isTester);
|
|
const inactive = users.filter((u) => !u.isActive);
|
|
```
|
|
|
|
**Correct (1 iteration):**
|
|
|
|
```typescript
|
|
const admins: User[] = [];
|
|
const testers: User[] = [];
|
|
const inactive: User[] = [];
|
|
|
|
for (const user of users) {
|
|
if (user.isAdmin) admins.push(user);
|
|
if (user.isTester) testers.push(user);
|
|
if (!user.isActive) inactive.push(user);
|
|
}
|
|
```
|