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 upLazily compute and cache the classnames of elements in the style sharing cache. #12912
Comments
|
Please make a comment here if you intend to work on this issue. Thank you! |
|
I'd like to work on this :) |
|
Hi! The mentioned bug landed, so it's yours! Let me know if you need any help :) |
|
Hi, |
|
No problem! So, in the file That function currently takes two elements and compares the two vectors. The key point here is that one element comes straight from the cache, and we might be computing its class attribute a lot of times even when we know it shouldn't change. So what we'd have to do is adding a field to the This field should be an We should add this field, and then write if candidate.class_attribute.is_none() {
// compute the class attribute
}
return candidate.class_attribute.unwrap() == element_class_attributeI hope that helps, thanks! |
Cached element class names in style sharing cache with lazy computation <!-- Please describe your changes on the following line: --> Fixes #12912 Added a field to StyleSharingCandidate to lazily compute and cache the class names. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/12962) <!-- Reviewable:end -->
Cached element class names in style sharing cache with lazy computation <!-- Please describe your changes on the following line: --> Fixes #12912 Added a field to StyleSharingCandidate to lazily compute and cache the class names. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #12912 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/12962) <!-- Reviewable:end -->
When #12668 lands, we can compute the
StyleSharingCandidateclass names the same way as we're computing theCommonStyleAffectingAttributesinstead of once per test.Code:
components/style/matching.rsTests: