When processing a new transaction, in addition to spending the Coins of its txin’s, it creates a new Coins for its outputs. The existing ModifyCoins function will first make sure this Coins does not already exist. It can not exist due to BIP 30, but because of that, the lookup can’t be cached and always has to go to the database. Since we are creating the Coins to match the new tx anyway, there is no point in checking if it exists first anyway. However this should not be used for coinbase tx’s in order to preserve the historical behavior of overwriting the two existing duplicate tx pairs.
In conjunction with #6931 this will help ConnectBlock be much more efficient with caching access to the database.
This still needs unit tests which exercise the new functionality.