in reply to Fastest way to merge (and de-dup) two large arrays?
The most likely much faster way instead of using the smartmatch operator is to tell Perl that you'll be looking up things in the smaller array very often by converting the smaller array to a hash:
my %seen; $seen{ $_ } = 1 for @data; foreach my $rawData (@rows) { if( $seen{ $rawData } ) { # don't do anything, already in array } else { push(@data,$rawData); $seen{ $rawData } = 1; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Fastest way to merge (and de-dup) two large arrays?
by perldigious (Priest) on Aug 11, 2016 at 18:55 UTC | |
by Corion (Patriarch) on Aug 11, 2016 at 19:12 UTC | |
by SimonPratt (Friar) on Aug 12, 2016 at 07:59 UTC | |
by perldigious (Priest) on Aug 12, 2016 at 13:52 UTC | |
|
Re^2: Fastest way to merge (and de-dup) two large arrays?
by perldigious (Priest) on Aug 11, 2016 at 19:34 UTC | |
by Corion (Patriarch) on Aug 11, 2016 at 19:37 UTC | |
by perldigious (Priest) on Aug 12, 2016 at 13:41 UTC | |
|
Re^2: Fastest way to merge (and de-dup) two large arrays?
by technojosh (Priest) on Aug 14, 2016 at 01:06 UTC |