PathElementsFactory: optimize .relativize()

We can know the size of the resulting array after we have skipped all common
elements in both name arrays: it is the sum of the first and second array size,
minus twice the number of common elements.

This has two benefits:

* if the size is 0 we know we have to return an empty path, and this is a
constant;
* otherwise, we allocate an array of the exact needed size.
PathElementsFactory: document .relativize() more