Runtime optimization: cache inode of each dir to avoid duplication via symlinks
Submitted by Daniel Macks
Assigned to pkg..@..op.org
Over its history and among vendors, the prefix where X11 gets installed has changed several times. Some vendors supply symlinks from the "old" location when they change to installing at a new location and/or links from some standard location to a less-standard place the vendor uses. These provide good compatibility, but they mean I might have several generations of /.../X11/.../pkgconfig paths in my PKG_CONFIG_PATH (or pre-configured via pkg-config's ./configure --with-pc-path= flag). Also, during some builds, I might pass something already in --with-pc-path via PKG_CONFIG_PATH in order to give precedence to a location of something that is masked by default.
In both cases, pkg-config winds up encountering the same actual pkgconfig/ directory more than once, either real vs symlink or multiple entries of the actual path in the search list. It then rereads and re-parses its whole *.pc contents and obviously ignoring every one of them. If pkg-config cached the inode or other unique information about the "actual" directory when reading it, it could then check whether a directory had already been processed and not bother reprocessing it. For my bare-bones OS X 10.8 machine, there are 3 pointers to the X11 prefix (all of which are in my build scripts so that they are exactly portable to other systems), which is what contains the vast majority of my .pc files, so this optimization cuts out almost 2/3 of the processing every time pkg-config runs.