You are free to look into it of course, but I'm pretty sure the pathfinding engine doesn't use any virtual methods that you can hook into
OK so that settled it, no worries. We'll have to stick to our hacky method that overwrites unit.path.dest.
I'm not sure what that would achieve, assuming you're looking to improve performance, not change the path as such. Having DF first calculate the path, then calculate a path using an alternative method and then replace the original path with the hacked one is bound to be costlier. In order to replace the pathing you'd at least have to hack the DF code to produce a short fake path that your alternative can pick up, but if you've managed to do that you can just as well call your replacement code from that stub to produce a real path. Obviously, in order to do this you'd have to locate the relevant code, figure out what the parameters are (including variations), and find out what the results are (quite possibly an updated path in the unit plus some kind of return value to indicate success/failure (with possible indications of the kind of failure)).
If you somehow were able to determine when DF was going to perform a path calculation, replacing the destination in between it being set and the path calculated would allow you to ensure the native calculation produces a very short (and cheap) path, of course.
And now something completely different: How do you find out if a unit is a spy? I've tried to compare the visible name string with the normal one, without getting a single mismatch, so that's probably not it. It seems the gobbos have sent multiple spies to note cage trap locations along multiple entrance paths, and ripping up the traps not triggered during the last siege and placing new ones there did not seem to help for the current one, although the revealed path is slightly different.
I haven't decided what to do with the spies, but having 50% of the visitors being monks and peddlers is FAR to high a proportion for my liking (yes, I know that can be handled by not having dedicated temples, which I'm going to do in the next fortress, but not the current one).