ptr: optimize {swap,replace,read}_ptr