FFORGE//RS
← Roadmap

rust / LEVEL 3

The cleanup pass that replaced its whole buffer

EST.35 MIN
01

THEORY / RETRIEVAL

What to restore

  • Distinguish Vec length from allocation capacity
  • Compose retain, sort_unstable and dedup in place
  • Verify allocation reuse without treating one benchmark as universal proof

Vec owns a buffer, length and capacity

Collecting into a new Vec allocates a second buffer and replacing the old value discards reusable capacity. Operations such as retain, slice sorting and deduplication can mutate the existing buffer while only reducing or permuting its initialized elements.

Prove the property that matters

Pointer and capacity checks are useful regression evidence for this bounded function because it never grows the vector. They are not a general performance claim: real optimization still starts from profiles, representative workloads and allocator-aware measurements.

CHECKPOINT

Which sequence produces sorted unique in-range readings without building a second Vec?

ISOLATED RUST 1.96
src/lib.rsEDIT

02 / PROFILING

Read the profile and fix the cause

Rewrite compact_readings in place. On valid inclusive bounds, retain only accepted readings, sort ascending and remove duplicates without replacing or shrinking the Vec allocation. Invalid bounds return false without mutation.

Initializing editor…
CLOUD SANDBOXnetwork off · 256 MB · 12 s
1 / 64 KB
OUTPUT
Runner is waiting for a submission.