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 upTurn flow::base and friends into methods #19565
Conversation
highfive
commented
Dec 14, 2017
|
Heads up! This PR modifies the following files:
|
highfive
commented
Dec 14, 2017
|
cc @pcwalton You wrote in a 2013 comment here that adding "virtual methods" to the Flow trait has a cost. Can you elaborate on that? Is it still true today? servo/components/layout/flow.rs Line 81 in 26feea3 |
|
Well, you pay the virtual call, I suppose... |
Oh right, while calling |
|
Moved these methods to a separate trait that is implemented directly on both sized and unsized types, to avoid virtual calls. |
| @@ -76,6 +76,30 @@ use table_wrapper::TableWrapperFlow; | |||
| #[allow(unsafe_code)] | |||
| pub unsafe trait HasBaseFlow {} | |||
|
|
|||
| /// Methods to get the `BaseFlow` from any `HasBaseFlow` type. | |||
| pub trait GetBaseFlow { | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
mbrubeck
Dec 15, 2017
Author
Contributor
Making this trait GetBaseFlow: HasBaseFlow works, but I'm not sure if it adds anything. There's no technical reason for this trait to require HasBaseFlow for all impls.
|
@bors-servo r+ |
|
|
Turn flow::base and friends into methods This feels more idiomatic in modern Rust, and replaces code like this: `flow::base(&**root_flow).restyle_damage` with this: `root_flow.base().restyle_damage`. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because they are refactoring only <!-- 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/19565) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
Turn flow::base and friends into methods This feels more idiomatic in modern Rust, and replaces code like this: `flow::base(&**root_flow).restyle_damage` with this: `root_flow.base().restyle_damage`. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because they are refactoring only <!-- 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/19565) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
|
|
|
|
mbrubeck commentedDec 14, 2017
•
edited by SimonSapin
This feels more idiomatic in modern Rust, and replaces code like this:
flow::base(&**root_flow).restyle_damagewith this:
root_flow.base().restyle_damage../mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is