Simplify location-replace logic - fewer ops, easier to understand
Merge pull request #654 from cmc333333/opt-simpify-lr

Simplify location-replace logic - fewer ops, easier to understand