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

Set vector properties via iterator in stylo #16721

Merged
merged 3 commits into from May 4, 2017

Conversation

Manishearth
Copy link
Member

@Manishearth Manishearth commented May 3, 2017

https://bugzilla.mozilla.org/show_bug.cgi?id=1360882

Avoids transient allocations


This change is Reviewable

@highfive
Copy link

highfive commented May 3, 2017

Heads up! This PR modifies the following files:

  • @bholley: components/style/properties/gecko.mako.rs, components/style/properties/data.py, components/style/values/computed/mod.rs, components/style/stylearc.rs, components/style/properties/helpers.mako.rs and 1 more
  • @emilio: components/style/properties/gecko.mako.rs, components/style/properties/data.py, components/style/values/computed/mod.rs, components/style/stylearc.rs, components/style/properties/helpers.mako.rs and 1 more

@highfive
Copy link

highfive commented May 3, 2017

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify style code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 3, 2017
@Manishearth
Copy link
Member Author

r? @emilio

@highfive highfive assigned emilio and unassigned cbrewster May 3, 2017
@Manishearth
Copy link
Member Author

Copy link
Member

@emilio emilio left a comment

Choose a reason for hiding this comment

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

Generally looks reasonable, but I want to know why the take() business is needed. It adds a fair amount of complexity, which I think should not be needed.

specified_value,
computed,
inherited_style.get_font());
% if property.is_vector and product == "gecko":
Copy link
Member

Choose a reason for hiding this comment

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

Can we just make the same API for servo and call collect inside the servo function?

computed,
inherited_style.get_font());
% if property.is_vector and product == "gecko":
let mut s = context.mutate_style().take_${data.current_style_struct.name_lower}();
Copy link
Member

Choose a reason for hiding this comment

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

Why exactly is all this take business needed? I don't see any reason why it should be, right?

Copy link
Member

Choose a reason for hiding this comment

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

(we talked on IRC, and yes, this is needed. can you leave a comment here?)

Copy link
Member

Choose a reason for hiding this comment

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

I guess we rely on the property that a vector property doesn't access its own style struct to compute itself, don't we? Let's have it clearly documented.

Copy link
Member

Choose a reason for hiding this comment

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

(Well, actually I guess they can use self, so we'd be good there too).

In general I don't love the complexity this patch introduces overall, but since I don't have a better suggestion right now, other than the other comments...

///
/// This lets us build arcs that we can mutate before
/// freezing, without needing to change the allocation
pub struct UniqueArc<T: ?Sized>(Arc<T>);
Copy link
Member

Choose a reason for hiding this comment

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

Let's move this out of here, to keep this as close as the original arc.rs as possible.

Copy link
Member

Choose a reason for hiding this comment

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

Meh, actually, I guess it's fine, and being here allows using the private member without unsafety or exposing extra stuff, so...

for (servo, gecko) in v.0.into_iter().zip(self.gecko.mTransitions.iter_mut()) {
let v = v.into_iter();

if v.len() != 0 {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Does ExactSizeIterator support is_empty? If so, let's use it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, it's unstable

Copy link
Member

@emilio emilio left a comment

Choose a reason for hiding this comment

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

Ok, r=me with the nits and the path for servo being made the same (should be a one-liner in the property code).

v: I)
where I: IntoIterator<Item = longhands::${shorthand}_position_${orientation[0]}::computed_value::single_value::T>,
I::IntoIter: ExactSizeIterator
{
Copy link
Member

Choose a reason for hiding this comment

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

Indentations is off here.

pub fn set_${shorthand}_image<I>(&mut self, images: I, cacheable: &mut bool)
where I: IntoIterator<Item = longhands::${shorthand}_image::computed_value::single_value::T>,
I::IntoIter: ExactSizeIterator
{
Copy link
Member

Choose a reason for hiding this comment

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

and here (and below)

I::IntoIter: ExactSizeIterator + Clone
{
let v = v.into_iter();
debug_assert!(v.len() != 0);
Copy link
Member

Choose a reason for hiding this comment

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

is_empty. also in all the similar use-cases below

///
/// This lets us build arcs that we can mutate before
/// freezing, without needing to change the allocation
pub struct UniqueArc<T: ?Sized>(Arc<T>);
Copy link
Member

Choose a reason for hiding this comment

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

Meh, actually, I guess it's fine, and being here allows using the private member without unsafety or exposing extra stuff, so...

@Manishearth Manishearth force-pushed the vector-iter branch 2 times, most recently from 7f3eb81 to ed0b058 Compare May 4, 2017 05:38
@Manishearth
Copy link
Member Author

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

📌 Commit ed0b058 has been approved by emilio

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 4, 2017
@bors-servo
Copy link
Contributor

🔒 Merge conflict

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels May 4, 2017
@Manishearth
Copy link
Member Author

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

📌 Commit 8bc277b has been approved by emilio

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 4, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit 8bc277b with merge e2b6e9b0ee64839db4fd3425e7c6f0f6cb29d202...

@bors-servo
Copy link
Contributor

💔 Test failed - linux-rel-css

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels May 4, 2017
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels May 4, 2017
@Manishearth
Copy link
Member Author

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

📌 Commit 33fb27c has been approved by emilio

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 4, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit 33fb27c with merge e23c8f1...

bors-servo pushed a commit that referenced this pull request May 4, 2017
Set vector properties via iterator in stylo

https://bugzilla.mozilla.org/show_bug.cgi?id=1360882

Avoids transient allocations

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

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-msvc-dev
Approved by: emilio
Pushing e23c8f1 to master...

@bors-servo bors-servo merged commit 33fb27c into servo:master May 4, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label May 4, 2017
@Manishearth Manishearth deleted the vector-iter branch May 7, 2019 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants