Java creation of new set too slow
- by Mgccl
I have this program where it have some recursive function similar to this:
lambda(HashSet<Integer> s){
for(int i=0;i<w;i++){
HashSet<Integer> p = (HashSet) s.clone();
p.addAll(get_next_set());
lambda(p);
}
}
What I'm doing is union every set with the set s. And run lambda on each one of the union.
I run a profiler and found the c.clone() operation took 100% of the time of my code. Are there any way to speed this up considerably?