Add simple caching to XML compilation

XML compilation stage will perform many (expensive) resource ID
lookups - for the same entries. Adding this simple cache can
dramatically improve performance of this stage (often a bottleneck)

Change-Id: I61356b6b3f0d90b7ac549b781e3ac8dd02282559
Updated: fixed for Mac OS X (also tested on Windows, Linux)