On 07/31/2014 04:52 PM, Robert O'Callahan wrote: > Is there anything blocking us from mass-removing nsAutoPtr/nsAutoArrayPtr > in favour of UniquePtr?
I'm not unsure what the state of mass-rewriting tools are these days, to start. But assuming they're up to snuff, there might or might not be. There are a variety of little differences that rewriting would have to carefully consider: * nsAutoPtr<T> implicitly converts to T*, UniquePtr requires get() * nsAutoPtr<T> has one of the bad (T&) constructors that's probably in ubiquitous use (and those can't safely be changed except manually, unless you want to pretend all existing code is correct) * nsAutoPtr can be assigned T*, UniquePtr can only be assigned nullptr or a temporary/moved UniquePtr And probably more beyond that, I was just skimming. Additionally, UniquePtr is best used by threading it through interfaces, beyond just immediate use sites. Rather than returning a raw pointer, code should return UniquePtr instead. Rather than extracting a raw pointer to pass to a method, code should pass Move(ptr) instead, and that argument should be a UniquePtr&&. These changes can't be mechanized. > I think it's more important to remove old stuff than add new stuff, so the > sooner we can mass-remove nsAutoPtr/nsAutoArrayPtr the better. In principle, perhaps. But JS wanted UniquePtr as much as gfx (among others, I believe) did, and nsAutoPtr wouldn't cut it there, so it had to happen anyway. Jeff _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform