Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass some SmartPointer variables by reference #16845

Merged
merged 1 commit into from Apr 3, 2024

Conversation

kronbichler
Copy link
Member

@kronbichler kronbichler commented Apr 3, 2024

... instead of by value. I observed in a profiler a lot of constructor and destructor calls to SmartPointer. Since those are not entirely trivial,

template <typename T, typename P>
template <class Q>
inline SmartPointer<T, P>::SmartPointer(const SmartPointer<T, Q> &tt)
: t(tt.t)
, id(tt.id)
, pointed_to_object_is_alive(false)
{
if (tt.pointed_to_object_is_alive && t != nullptr)
t->subscribe(&pointed_to_object_is_alive, id);
}
which then calls
Subscriptor::subscribe(std::atomic<bool> *const validity,
const std::string &id) const
{
std::lock_guard<std::mutex> lock(mutex);
if (object_info == nullptr)
object_info = &typeid(*this);
++counter;
const std::string &name = id.empty() ? unknown_subscriber : id;
++counter_map[name];
*validity = true;
validity_pointers.push_back(validity);
we should get rid of them.

@bangerth bangerth merged commit 9f251f3 into dealii:master Apr 3, 2024
16 checks passed
@kronbichler kronbichler deleted the pass_by_reference branch April 4, 2024 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants