Commit dad2a0a
authored
[Repo Assist] perf(rust-guard): hoist invariant integrity/secrecy calls outside per-item loops (#6005)
🤖 *Repo Assist — automated AI assistant.*
## Summary
Eliminates redundant `Vec` allocations in three `label_response_items`
branches by hoisting constant integrity/secrecy calls outside their
loops.
## Problem
Three item-labeling loops were recomputing identical `Vec` values on
**every iteration**:
| Branch | Repeated call(s) |
|--------|-----------------|
| `list_gists` / `get_gist` | `reader_integrity(scope_names::USER, ctx)`
× N |
| `list_notifications` / `get_notification_details` |
`private_user_label()` × N **and** `none_integrity("", ctx)` × N |
| `list_releases` / `get_latest_release` / `get_release_by_tag` |
`merged_integrity(&repo_full_name, ctx)` × N |
For a 30-item batch (the default limit) this was ~90 redundant heap
allocations per call. In WASM, every allocation is expensive since the
linear memory allocator scans free lists on each call.
## Fix
Hoist each invariant call before its loop; clone the pre-built `Vec` per
item. Also extracts a `DEFAULT_BRANCH_NAMES` constant in `helpers.rs`,
consistent with `WRITE_OPERATIONS`, `BLOCKED_TOOLS`, and similar named
arrays.
The `get_file_contents` branch already uses this pattern correctly —
this change makes the rest of the code consistent.
Closes #5997
## Test Status
- `cargo check` ✅
- `cargo test` ✅ — 411 tests passed, 0 failed
> Generated by [Repo
Assist](https://github.com/github/gh-aw-mcpg/actions/runs/26101078502/agentic_workflow)
· ● 2.6M ·
[◷](https://github.com/search?q=repo%3Agithub%2Fgh-aw-mcpg+%22gh-aw-workflow-id%3A+repo-assist%22&type=pullrequests)
>
> To install this [agentic
workflow](https://github.com/githubnext/agentics/blob/851905c06e905bf362a9f6cc54f912e3df747d55/workflows/repo-assist.md),
run
> ```
> gh aw add
githubnext/agentics@851905c
> ```
<!-- gh-aw-agentic-workflow: Repo Assist, engine: copilot, version:
1.0.40, model: claude-sonnet-4.6, id: 26101078502, workflow_id:
repo-assist, run:
https://github.com/github/gh-aw-mcpg/actions/runs/26101078502 -->
<!-- gh-aw-workflow-id: repo-assist -->4 files changed
Lines changed: 133 additions & 68 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1522 | 1522 | | |
1523 | 1523 | | |
1524 | 1524 | | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
1525 | 1528 | | |
1526 | 1529 | | |
1527 | 1530 | | |
1528 | | - | |
1529 | | - | |
1530 | | - | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
1531 | 1534 | | |
1532 | 1535 | | |
1533 | 1536 | | |
| |||
Lines changed: 33 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
86 | | - | |
| 85 | + | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
208 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
209 | 210 | | |
210 | 211 | | |
211 | 212 | | |
| |||
287 | 288 | | |
288 | 289 | | |
289 | 290 | | |
290 | | - | |
291 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
292 | 294 | | |
293 | 295 | | |
294 | 296 | | |
| |||
308 | 310 | | |
309 | 311 | | |
310 | 312 | | |
| 313 | + | |
| 314 | + | |
311 | 315 | | |
312 | 316 | | |
313 | 317 | | |
314 | 318 | | |
315 | 319 | | |
316 | 320 | | |
317 | | - | |
318 | | - | |
| 321 | + | |
| 322 | + | |
319 | 323 | | |
320 | 324 | | |
321 | 325 | | |
| |||
345 | 349 | | |
346 | 350 | | |
347 | 351 | | |
| 352 | + | |
348 | 353 | | |
349 | 354 | | |
350 | 355 | | |
| |||
357 | 362 | | |
358 | 363 | | |
359 | 364 | | |
360 | | - | |
361 | | - | |
| 365 | + | |
| 366 | + | |
362 | 367 | | |
363 | 368 | | |
364 | 369 | | |
| |||
371 | 376 | | |
372 | 377 | | |
373 | 378 | | |
| 379 | + | |
| 380 | + | |
374 | 381 | | |
375 | 382 | | |
376 | 383 | | |
| |||
386 | 393 | | |
387 | 394 | | |
388 | 395 | | |
389 | | - | |
390 | | - | |
| 396 | + | |
| 397 | + | |
391 | 398 | | |
392 | 399 | | |
393 | 400 | | |
| |||
398 | 405 | | |
399 | 406 | | |
400 | 407 | | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
401 | 412 | | |
402 | 413 | | |
403 | 414 | | |
404 | 415 | | |
405 | 416 | | |
406 | 417 | | |
407 | | - | |
408 | | - | |
| 418 | + | |
| 419 | + | |
409 | 420 | | |
410 | 421 | | |
411 | 422 | | |
| |||
422 | 433 | | |
423 | 434 | | |
424 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
425 | 439 | | |
426 | 440 | | |
427 | 441 | | |
| |||
430 | 444 | | |
431 | 445 | | |
432 | 446 | | |
433 | | - | |
434 | | - | |
| 447 | + | |
| 448 | + | |
435 | 449 | | |
436 | 450 | | |
437 | 451 | | |
| |||
0 commit comments