Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

Update the implementation of unprotected scope #13

Merged
1 commit merged into from
Sep 6, 2017
Merged

Update the implementation of unprotected scope #13

1 commit merged into from
Sep 6, 2017

Conversation

jeehoonkang
Copy link
Contributor

This is a subset of RFC #10 (crossbeam-rs/rfcs#10). It doesn't change any interface, so I would like to post this PR without going for RFC.

In short, it implements @stjepang 's suggestion (crossbeam-rs/rfcs#10 (comment)): unprotected scope has a null bag, and garbages created within this scope are immediately disposed of.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Nice! I have just one minor nit.

src/mutator.rs Outdated
unsafe fn get_bag(&self) -> &mut Bag {
&mut *self.bag
#[inline]
unsafe fn get_bag(&self) -> Option<&mut Bag> {
Copy link

Choose a reason for hiding this comment

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

This can be just:

#[inline]
unsafe fn get_bag(&self) -> Option<&mut Bag> {
    self.bag.as_mut()
}

Copy link

Choose a reason for hiding this comment

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

Or, alternatively, delete this method and instead of calling self.get_bag() just write self.bag.as_mut() :)

Copy link

@arthurprs arthurprs left a comment

Choose a reason for hiding this comment

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

Looks good.

@jeehoonkang
Copy link
Contributor Author

@stjepang thanks! I removed get_bag(), as you advised.

@ghost ghost merged commit 5739ec4 into crossbeam-rs:master Sep 6, 2017
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants