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

Remove branching when calling a wrapper method #19

Closed
acki-m opened this issue May 1, 2016 · 1 comment
Closed

Remove branching when calling a wrapper method #19

acki-m opened this issue May 1, 2016 · 1 comment

Comments

@acki-m
Copy link
Contributor

acki-m commented May 1, 2016

All wrappers (property, method, constructor, destructor & enumeration) currently hold a pointer to the wrapper base class.
When the client holds a valid item, the pointer is set, otherwise its a nullptr.
Every invoke of a member method for the wrappers mentioned above, checks for nullptr.
That's an unnecessary check, just provide for the invalid case a derived class,
which handles this case. All if checks could be removed.

To get the idea:

Current implementation:

variant method::invoke(instance object) const
{
    if (is_valid())
        return m_wrapper->invoke(object);
    else
        return variant();
}

New implementation:

variant method::invoke(instance object) const
{
    return m_wrapper->invoke(object);
}

m_wrapper would point to the a derived class which implement the invalid case.

@acki-m acki-m changed the title Remove branching when calling a wrapper methods Remove branching when calling a wrapper method May 1, 2016
@acki-m
Copy link
Contributor Author

acki-m commented May 28, 2016

fixed with merging branch: rmv_if_branch_from_wrapper

@acki-m acki-m closed this as completed May 28, 2016
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