Avoid unnecessary os.path.realpath() calls in _ensure_real_directory()
Staging performance has been quite slow for me and the biggest offender when profiling has been os.path.realpath() being called from _ensure_real_directory().
When tracing calls to this function, I found that we called os.path.realpath() on the same directory many times. This is unnecessary as we process the filelist in directory-first order. The code is now changed to only ensure directories exist when we hit a directory; the rest of the time this isn't needed.
In my profile of bst shell
on base.bst from the gnome-modulesets repo,
time spent in _ensure_real_directory() goes from 11 seconds to 0.12
seconds.
Depends on !198 (closed)
Fixes #174 (closed)
Edited by Sam Thursfield