Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMake ToCss' SequenceWriter not monomorphise like a maniac anymore #19838
Conversation
highfive
commented
Jan 22, 2018
|
Heads up! This PR modifies the following files:
|
highfive
commented
Jan 22, 2018
|
@bors-servo try |
Make ToCss' SequenceWriter not monomorphise like a maniac anymore
|
|
|
@bors-servo try |
Make ToCss' SequenceWriter not monomorphise like a maniac anymore <!-- 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/19838) <!-- Reviewable:end -->
|
/me likes :) Not sure if you want to wait for @SimonSapin's / @bholley's review or not, if you don't just feel free to land with r=me. |
| None, None /* No extra custom properties */); | ||
| .single_value_to_css( | ||
| &get_property_id_from_nscsspropertyid!(property, ()), | ||
| &mut CssWriter::new(&mut string), |
This comment has been minimized.
This comment has been minimized.
emilio
Jan 22, 2018
Member
We should make this pass buffer directly. Mind filing an issue? Though I don't recall if @bholley's patch fixed this.
| has_written: false, | ||
| let has_prefix = self.inner.prefix.is_some(); | ||
| if !has_prefix { | ||
| self.inner.prefix = Some(self.separator); |
This comment has been minimized.
This comment has been minimized.
| where | ||
| W: Write, | ||
| { | ||
| /// Creates a new `CssWriter`. |
This comment has been minimized.
This comment has been minimized.
| /// A writer tailored for serialising CSS. | ||
| /// | ||
| /// Coupled with SequenceWriter, this allows callers to transparently handle | ||
| /// things like comma-separated values etc. |
This comment has been minimized.
This comment has been minimized.
emilio
Jan 22, 2018
Member
Maybe put an example of how this is used? I had to read it a bit carefully.
In particular, what state does prefix represent? If I'm not wrong, when writing a sequence:
- We start with prefix =
Some(""). - On the first
item, assuming it writes something, ittakes the prefix. - On the second one, since there's no prefix, we set
prefix: Some(sequence_separator), and reset it after theto_csscall begins. - ...
| self.has_written = true; | ||
| item.to_css(&mut self.inner)?; | ||
| if !has_prefix { | ||
| self.inner.prefix = None; |
This comment has been minimized.
This comment has been minimized.
emilio
Jan 22, 2018
Member
I think it'd be nice, more as a self-documenting assert than as a sanity-check, that in this case self.inner.prefix is either None or self.separator before the assignment (since even though it can change down the line, it should always be mutated by another SequenceWriter, and thus resetted too.
|
|
|
@bors-servo try |
Make ToCss' SequenceWriter not monomorphise like a maniac anymore <!-- 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/19838) <!-- Reviewable:end -->
|
|
|
|
|
|
Now that SequenceWriter<W> does not monomorphise excessively, we can actually type check a derived ToCss without too much type recursion.
Make ToCss' SequenceWriter not monomorphise like a maniac anymore <!-- 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/19838) <!-- Reviewable:end -->
|
|
|
@bors-servo r+ |
|
|
|
@bors-servo p=7 |
Make ToCss' SequenceWriter not monomorphise like a maniac anymore <!-- 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/19838) <!-- Reviewable:end -->
|
|
ionutgoldan
commented
Jan 25, 2018
|
Good news! This noticeably reduced build times on Windows. == Change summary for alert #11256 (as of Tue, 23 Jan 2018 16:57:02 GMT) == Improvements: 9% build times windows2012-64 opt rusttests taskcluster-c4.4xlarge 2,321.94 -> 2,103.34 For up to date results, see: https://treeherder.mozilla.org/perf.html#/alerts?id=11256 |
nox commentedJan 22, 2018
•
edited by SimonSapin
This change is