|
Posted by Simon Stienen on 04/03/07 01:32
You could array_intersect + array_unique before array_diffing to get the
part numbers that are in common first. This speeds up array_diff, since it
has to compare fewer items. However, as you have to array_intersect (+
array_unique) first, overall performance might even be decreased.
Another approach might be to array_flip the common numbers instead off
array_uniqueing them (since flipping does unique them anyway), then looping
the arrays yourself using foreach or array_filter and check for the
existance of he number using isset($common_flipped[$number]). I'm not into
PHPs array interna, but this might use a search tree (as it's an index
lookup) and therefore a complexity of O(log(n)) per item, while I suspect
array_diff to iterate through the items, therefore having a complexity of
O(n). AIMB: I'm not into the interna, but it might be faster at large tile
lists.
[Back to original message]
|