You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VecIntoIter.next() is remove(0) per element — consuming iteration over a Vec is O(n²) #938
impl[T] Iter[T] for VecIntoIter[T]:
// remove(0) is D27's proven element transfer; the memmove-per-next
// cost stands until a front-cursor variant earns its unsafe.
mut fn next() -> Option[T]:
if self.vec.len() == 0: return None
Some(self.vec.remove(0))
Every next() memmoves the remaining elements, so for x in vec.into_iter() (D33's consuming surface) is O(n²). The comment knows; this issue makes it a tracked item rather than a note.
Fix
A front cursor: VecIntoIter { vec, idx } where next() moves element idx out (a proven element transfer via the existing D27 take/slot machinery or a raw move that blanks the slot) and the iterator's drop releases the un-yielded tail (D33: "the iterator owns the tail"). The drop audit must cover: fully consumed, partially consumed then dropped, zero-iteration.
There are 11 remove(0) sites across lib/std and src; the other notable one is BTreeMap.insert (#937's O(n²) rebuild).
Ruling (2026-09-01): the engine comes from the migrated corpora (c-algorithms / TommyDS / STC, migrated whole; M*LIB's B+ tree surgically) with a With facade choosing the winner — see docs/stdlib_sourcing_plan.md and the note on #940. This issue stays open as the facade deliverable.
Fixed on branch stc-facades (commit 0e9b82e): ListIntoIter.next() moves the head out through its own address and advances the buffer's start (D115, with_vec_take_front_es), O(1) per element. Evidence: the vec-into-iter row of test/complexity/stdlib.w is a PASS (it carried this issue as an expected failure); behav_list_sort and the existing consuming-iteration fixtures pass.
Activity
ehartford commentedon Sep 2, 2026
Ruling (2026-09-01): the engine comes from the migrated corpora (c-algorithms / TommyDS / STC, migrated whole; M*LIB's B+ tree surgically) with a With facade choosing the winner — see docs/stdlib_sourcing_plan.md and the note on #940. This issue stays open as the facade deliverable.
Complete callable FnAbi descriptors and stdlib Phase 0 (#1129)
C algorithms phase1 (#1142)
ehartford commentedon Oct 22, 2026
Fixed on branch stc-facades (commit 0e9b82e):
ListIntoIter.next()moves the head out through its own address and advances the buffer's start (D115,with_vec_take_front_es), O(1) per element. Evidence: thevec-into-iterrow oftest/complexity/stdlib.wis a PASS (it carried this issue as an expected failure);behav_list_sortand the existing consuming-iteration fixtures pass.Phase 3 facades over the STC engines (D148): PriorityQueue, OrderedSe…