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

Use std::vector in Signal #1016

Merged
merged 5 commits into from
Dec 7, 2021
Merged

Use std::vector in Signal #1016

merged 5 commits into from
Dec 7, 2021

Commits on Dec 7, 2021

  1. Delegate implementation of connect and disconnect to main overload

    This makes updates easier, as only one of each method will need to be
    changed. The other overloads just wrap the parameters into a `Delegate`,
    and then pass it to the main overload.
    DanRStevens committed Dec 7, 2021
    Configuration menu
    Copy the full SHA
    9a9b686 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fe9fee7 View commit details
    Browse the repository at this point in the history
  3. Write manual existence checks for connect and disconnect

    Currently we are using `std::set`, which has implicit existence checks
    for the `insert` and `delete` operations. However, `std::set` requires
    the stored items to be "less than" comparable. The custom `Delegate`
    class has a custom `operator<`, while `std::function` does not. If we
    use `std::vector`, we won't need a custom `operator<`. We will however
    need to do manual existence checks when adding or removing delegates
    from the collection.
    
    As an aside, for small collections, it's faster to iterate through a
    `std::vector` than other more complex collections. The benefits of using
    `std::set` for fast lookup only become apparent when the collection size
    grows. As most `Signal` objects typically have at most one connection,
    we'd be better off using `std::vector` for faster operations.
    DanRStevens committed Dec 7, 2021
    Configuration menu
    Copy the full SHA
    e4daa5b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    819fd82 View commit details
    Browse the repository at this point in the history
  5. Remove explicit default initialization

    A `std::vector` will be implicitly initialized.
    DanRStevens committed Dec 7, 2021
    Configuration menu
    Copy the full SHA
    d54b61d View commit details
    Browse the repository at this point in the history