partially optimising array diff