Repository navigation
Reduce allocations in SelectorMap (Rule Hash) code - #1299
Merged
Merged
Conversation
Do this by receiving a borrowed pointer in get_id_name(), etc.. Also, move the received argument in insert() method (instead of cloning it).
Contributor
There was a problem hiding this comment.
nit: I doubt it makes a difference, but this will be slightly faster and clearer (avoids the bounds check) if you just do:
let mut curr_declarations = ~[];
for rule in rules.iter() { ... }
declarations_list.push(curr_declarations);
The push does a move of curr_declarations so it won't copy.
Contributor
|
Looks pretty good, just one small comment and I'll r+ |
Contributor
Author
|
Yeah. Wasn't sure if push would lead to more allocation :) |
bors-servo
pushed a commit
that referenced
this pull request
Nov 22, 2013
Issue #1274 Also: + Reduce number of clones of Rule + Make Rule have Arc<Selector>
Contributor
|
@pcwalton @pradeep90 92fa43 and ae1f168 are questionable. It doesn't remove any clones, and it is going to reallocate the vector more often. It shouldn't be calling map on the vector, but rather:
This will use with_capacity. |
eefriedman
added a commit
to eefriedman/servo
that referenced
this pull request
Sep 29, 2015
Making the Stylist usage threadsafe without unsafe code or extra locking required some changes to WorkQueue; the changes are mostly straightforward. Some refactoring of LayoutTaskData was also required: this is basically just splitting the structure in two so the borrow checker can understand that building a SharedLayoutContext only borrows part of LayoutTaskData. The "frozen" part is the part that can't be safely modified while a parallel work-queue is running. It might be worth considering switching to some sort of threadsafe channel to avoid the mutexes... see Rust RFC PR servo#1299. Fixes servo#2604. Pretty sure the issue with the other version mentioned there was just that it held on to the lock too long.
eefriedman
added a commit
to eefriedman/servo
that referenced
this pull request
Sep 29, 2015
Making the Stylist usage threadsafe without unsafe code or extra locking required some changes to WorkQueue; the changes are mostly straightforward. Some refactoring of LayoutTaskData was also required: this is basically just splitting the structure in two so the borrow checker can understand that building a SharedLayoutContext only borrows part of LayoutTaskData. The "frozen" part is the part that can't be safely modified while a parallel work-queue is running. It might be worth considering switching to some sort of threadsafe channel to avoid the mutexes... see Rust RFC PR servo#1299. Fixes servo#2604. Pretty sure the issue with the other version mentioned there was just that it held on to the lock too long.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #1274
Also: