Avoid wp<>::unsafe_get() with a few exceptions
Avoid using wp<>::unsafe_get() except in a log, and other specific cases when it's known to be safe. Use more specific subclass types for parameters to avoid down-casts. When a constructor or method parameter is "this" of an object that is currently being constructed, it's better to use a raw pointer rather than either sp<> or wp<>. Using the raw pointer is safe, provided either: - it is "this" of an object being constructed (which has sp<> refcount of 0), - or the caller already holds an sp<> The raw pointer is simpler and faster, and it avoids the problem of the sp<> reference count being incremented and then decremented to zero on scope exit, which would cause the object's destructor to run while the object is still being constructed. Also removed some dead code per a review comment. Change-Id: I7375f64da3aec11b928c33cb01faff186252ef5e
Loading
Please register or sign in to comment