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

feat: Add ChangeSet that can be collected into from iterators, and joined over for easy application to components #344

Merged
merged 1 commit into from
Feb 11, 2018

Conversation

Rhuagh
Copy link
Member

@Rhuagh Rhuagh commented Feb 11, 2018

This change is Reviewable

@torkleyy
Copy link
Member

Reviewed 8 of 8 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@torkleyy
Copy link
Member

:lgtm:

Thank you!


Review status: all files reviewed at latest revision, all discussions resolved, some commit checks pending.


Comments from Reviewable

@Rhuagh
Copy link
Member Author

Rhuagh commented Feb 11, 2018

Not 100% ready yet.

@Rhuagh
Copy link
Member Author

Rhuagh commented Feb 11, 2018

Ready now I believe.

@torkleyy
Copy link
Member

Reviewed 1 of 1 files at r3.
Review status: all files reviewed at latest revision, 3 unresolved discussions.


src/changeset.rs, line 58 at r3 (raw file):

    pub fn add(&mut self, entity: Entity, value: T)
    where
        T: AddAssign + Default,

I don't think the Default is necessary.


src/changeset.rs, line 73 at r3 (raw file):

}

impl<T> FromIterator<(Entity, T)> for ChangeSet<T>

An Extend implementation would also be useful


src/changeset.rs, line 86 at r3 (raw file):

}

impl<'a, T> Join for &'a ChangeSet<T> {

I think we also need an implementation for ChangeSet and &mut ChangeSet.


Comments from Reviewable

@torkleyy
Copy link
Member

Review status: all files reviewed at latest revision, 4 unresolved discussions.


src/changeset.rs, line 47 at r3 (raw file):

impl<T> ChangeSet<T> {
    /// Create a new change set
    pub fn new() -> Self {

One might want to keep the ChangeSet to save a allocations, so in addition to Extend a clear method would also be useful.


Comments from Reviewable

…ined over for easy application to components
@Rhuagh
Copy link
Member Author

Rhuagh commented Feb 11, 2018

Review status: 7 of 8 files reviewed at latest revision, 4 unresolved discussions.


src/changeset.rs, line 47 at r3 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

One might want to keep the ChangeSet to save a allocations, so in addition to Extend a clear method would also be useful.

Done.


src/changeset.rs, line 58 at r3 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

I don't think the Default is necessary.

Done.


src/changeset.rs, line 73 at r3 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

An Extend implementation would also be useful

Done.


src/changeset.rs, line 86 at r3 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

I think we also need an implementation for ChangeSet and &mut ChangeSet.

Done.


Comments from Reviewable

}

unsafe fn get(v: &mut Self::Value, id: Index) -> Self::Type {
let value: *mut Self::Value = v as *mut Self::Value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is taken from the Join on &mut Storage, it's required for the compiler to understand that v is mutable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fails to validate the lifetime without it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The basic issue is that it fails to match &mut on the function signature to &'a for the Join implementation, and it's not possible to set &'a on the function signature because it would not match the trait then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right.

@torkleyy
Copy link
Member

Reviewed 1 of 1 files at r4.
Review status: all files reviewed at latest revision, 3 unresolved discussions.


src/changeset.rs, line 40 at r4 (raw file):

/// # }
/// ```
pub struct ChangeSet<T> {

This needs a Drop implementation clearing the DenseVecStorage.


src/changeset.rs, line 76 at r4 (raw file):

        for id in &self.mask {
            unsafe {
                self.inner.remove(id);

Can use UnprotectedStorage::clean instead.


Comments from Reviewable

@torkleyy
Copy link
Member

:lgtm:

Thank you!

bors r+


Review status: :shipit: all files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from Reviewable

bors bot added a commit that referenced this pull request Feb 11, 2018
344: feat: Add ChangeSet that can be collected into from iterators, and joined over for easy application to components r=torkleyy a=Rhuagh



<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/slide-rs/specs/344)
<!-- Reviewable:end -->
@bors
Copy link
Contributor

bors bot commented Feb 11, 2018

Build succeeded

@bors bors bot merged commit a05bff4 into amethyst:master Feb 11, 2018
@Rhuagh Rhuagh deleted the feature/changeset branch May 9, 2018 20:42
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.

2 participants