in reply to Re^3: Fastest way to merge (and de-dup) two large arrays?
in thread Fastest way to merge (and de-dup) two large arrays?
I think perldigious is going with the idea that building the hash from the larger array initially and adding the smaller array to the larger one would be faster, as the initial hash build doesn't run any if checks (saving potentially millions of cycles)
It would need testing, but on the face of it this seems to be a reasonable idea. Given that all of the records will eventually end up in the hash, if this doesn't fit in memory, then the entire solution should be reworked to find a completely different method
my %seen = map {$_ => 1} @rows; foreach my $rawData (@data) { push(@rows,$rawData) unless $seen{$rawData}++; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Fastest way to merge (and de-dup) two large arrays?
by perldigious (Priest) on Aug 12, 2016 at 13:52 UTC |