This case is a nice one. Have been looking at it and @HughParsonage seems right to me: that case (where the pattern is not matched to any column name) does not overwrite the names redundantly. Even where only a few column names are matched, it only updates those. So if those don't touch key or index names, then the key or index name updates will be saved too. The setnames(DT, new) form seems fine then and no improvement possible.
The PR nicely improves the other form (setnames(DT, old, new)) which wasn't doing any of the redundancy checking or saving.