A lot of time and CPU is wasted dealing with superfluous getblocks requests from peers (this can be seen if just the first commit is merged). The 2nd commit makes the node ignore getblocks requests that are duplicating the previous requests (rather than loop through up to 500 blocks looking for the "end block" mentioned in the request).
This will cause some getblocks requests due to orphan blocks to be ignored, but this will be ok as the invs will already have been sent. All IBD will be unaffected.