Determine compiled code database location once

This code was calling stat() on each time it ran, since it kept checking
whether the directory for the compiled code exists. Just checking it
once when it succeeds and reusing the result should be fine.