Skip to main content

arrayuniq

Function arrayuniq 

Source
pub fn arrayuniq(x: Vec<String>, freeok: i32) -> Vec<String>
Expand description

Direct port of static void arrayuniq(char **x, int freeok) from Src/params.c:4473. First-wins dedupe of x, in-place. C uses simple O(n²) scan for arrays under 10 entries, switching to a HashTable for larger arrays. freeok controls whether to zsfree() duplicates (only safe when caller owns the strings — Rust drop semantics handle it).

Signature note: C takes char **x + in-place mutation; Rust takes owned Vec<String> and returns the deduped result. freeok is preserved but is a no-op in Rust (drops free automatically). The hashtable / simple-loop tiering follows the same threshold (10) as C.