Memoize pathname cwd

This time only offering the cwd() memoization in the pull request.

Something looks fishy though - git says you need to merge 3 commits, but two of them are no-ops. It's me reverse merging from you and from one of the branches you merged in. Which is exactly why there are no diffs at all about those commits.

I wonder if it is safe to just merge them in, or if there is a way to avoid git offering them... I will search around for some tips.