How are transactions in forks verified efficiently? In this answer here, it's stated that Bitcoin uses a hashtable of all currently unspent outputs, in order to verify that the inputs of transactions haven't already been spent.

How does this interact with forks? If the Bitcoin client receives some blocks that go at the end of a fork that isn't the longest fork (perhaps, once they have all been verified, the new fork will be longer), how does it know what outputs are unspent in the fork that the blocks are being added to? A hashtable of unspent outputs in the current longest fork won't cut it.
Transactions in forks are not verified completely until the node attempts to switch to that fork. Before that, only those checks are performed that don't depend on previous transactions. In the source code, there is a function CheckBlock, which does only some of the checks, and ConnectBlock, which checks everything. The latter function is called only when the block is about to be accepted into the longest chain, so the hash table of unspent outputs is available.