optimize some code around merge
Merge pull request #10049 from vipulnsward/optimize_around_merge_v1

optimize some code around merge