4 ms·
ARC actually has some interesting advantages over smart pointers. For one, there is a large amount of static analysis done at compile time that allows the syst
by antimagic 11y ago
ARC actually has some interesting advantages over smart pointers. For one, there is a large amount of static analysis done at compile time that allows the system to avoid unnecessary increment/decrements of the reference counter - this can have significant performance improvements in tight inner loops, and can't be achieved using smart pointers.
- plorkyeran 11y agoMy experience has been that the awesomeness of ARC's optimizations is greatly overstated. The compiler inserts retain/release pairs around every operation that could potentially need them, and then the optimizer eliminates the redundant ones. Pretty much the only interesting nonlocal optimization it does it turn autoreleased return values into retained returns, which isn't an issue for shared_ptr to begin with.
- pjmlp 11y agoNothing in ANSI C++ forbids compiler vendors to make their compilers *_ptr<>() aware, but AFAIK none of them take advantage of it.