On 7/29/13 11:38 AM, Simon Sapin wrote:
type Namespace = i32 // Is this some kind of interning as well?
In Gecko, yes.
* Use vectors / arrays instead of linked lists for AtomList,
PseudoClassList and SelectorList. (Less allocations) This could make it
more difficult to point somewhere in the middle of list (especially in
Rust), but I don’t know how important that is.
I don't think we generally need to point into the middle of those lists.
* Use a single optional string for an ID selector instead of a list. If
a (combinator-separated part in Selectors L4 spec terminology) "compound
selector" that has more than ID simple selector selector, either they
are all the same and we only need one string (#foo#foo is the same as
#foo), or they are different and the selector never matches.
#foo#foo has different specificity from #foo, so we need to keep track
of that.
And #foo#bar never matches, but still needs to be present in the CSSOM....
* Use a bit field for simple (non-functional) pseudo-classes. Same as ID
selectors, repeating the same pseudo-class does not change the selector.
(eg. :empty:empty is the same as :empty. This is true for all
pseudo-classes defined in Selectors 4 AFAIK.)
Again, except for specificity...
So I think here are the main issues we have with Gecko's selectors, in
terms of your structs, that aren't discussed in your mail:
1) The linked list for SelectorList leads to lots of cache misses as we
traverse it, last we measured.
2) The Selector struct is pretty large and most of the stuff in it is
unset for most selectors. The vast majority of selectors are tag, id,
or class, with namespace almost always '*'.
-Boris
_______________________________________________
dev-servo mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-servo