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

[Performance improvement] Duplicate empty node check removal from Subscription.hpp #23316

Open
PavloZMN opened this issue Jun 22, 2024 · 0 comments

Comments

@PavloZMN
Copy link

Describe problem solved by the proposed feature

In class Subscription.hpp, check for empty field _node can be called two or three times in a row.
For example, method updated():

	bool updated()
	{
		if (!valid()) {
			subscribe();
		}

		return valid() ? Manager::updates_available(_node, _last_generation) : false;
	}

Method valid contains check for empty _node:
bool valid() const { return _node != nullptr; }

Method subscribe has the same check:

	bool Subscription::subscribe()
{
	if (_node != nullptr) {
		return true;
	}
       ...

Means, check _node != nullptr can be called two or three times in a row.

Describe your preferred solution

Only subscribe method is used for _node emptiness check.
Performance and code readability will be improved.

Describe possible alternatives

Current version is working fine.

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant