_unique() performance update

also fix bug when $desired===null passed as argument