Move computation of parent directory outside for loop
A call to vtksys::SystemTools::GetParentDirectory()
turns out to be a
bottleneck in material parsing. Fix by moving this call outside the
for loop since it does not change within the loop.
Closes #18071 (closed)
Backport: paraview/release