Revert r216862 due to a performance regression

Reported by Alexey Volkov in PR21115