Preserve inputs during reuse
A Go code buffer extends ranges and reuses storage for unread codes and incoming chunks.
What needs to change
Repair compactAndJoin so the returned joined codes and storage reuse satisfy the buffer contract.
Reproduce
- Run go run main.go with the supplied input and compare joined codes and the reuse flag.
Acceptance criteria
Your review marks · Saved in this browser. Test acceptance is tracked separately.
Notes
main.go supplies unread bounds and an incoming chunk that may share any part of the input buffer. Both result portions must retain their values as they were at function entry.
The result must start in the input’s backing storage whenever its length fits capacity; otherwise it must use new storage. Temporary snapshots are allowed. Empty output needs no allocation; exact new capacity is not assessed.
Supplied input is well formed: 0<=seed count<=capacity<=64; both range pairs satisfy 0<=start<=end<=seed count; code and seed values are integers in -1000..1000. The caller assumes this domain rather than validating it.