Optimization: check against previous file name and use its FileEntry.

(cherry picked from commit 0517b3627c6aeb9f7c10dcc31f3e0ef06513b7af)