-
March 29th, 2012, 09:01 AM
#1
Passing std:: or boost::shared_ptr as a reference to a function
I was playing with PVS-Studio static analysis tool recently, and it suggested me to replace passing of const std::shared_ptr<type> arg to const std::shared_ptr<type>& arg.
I perfectly understand that it is a good way to optimize performance as when I pass shared_ptrs by value there are increments / decrements of reference counters which are interlocked operations.
So the question is - is there any reason I should not do such optimization? Is there any corner case I did not consider?
I'm now trying to see it is makes sense to optimize this way one heavily-used interface, so would appreciate comments.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|