Closed Bug 972601 Opened 10 years ago Closed 10 years ago

Convert nsTreeStyleCache::mTransitionTable and ::mCache to more modern hashtables

Categories

(Core :: XUL, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: mccr8, Assigned: mccr8)

References

Details

Attachments

(6 files)

This is somewhat odd.  There are two hash tables, one representing a finite state machine, and one representing some kind of cache of results for the finite state machine.

This involves two custom hashtable key classes, nsDFAState and nsTransitionKey.  The first one is odd because the things it can hold are from a linearly allocated set of integers, and the hash function is just the identity.  I guess because it is used for the cache, they wanted the lookup to be fast?  But I'm guessing it is okay to just replace it with a regular integer hash class.  nsTransitionKey is a pair, of an int and a COMPtr.  I'm not sure if there's a newer hashtable key class that allows pairs, or if one will have to be created.

This code is old, and landed as part of a big refactoring, so digging around in the history for it didn't clarify anything for me.
I think it's ok to replace the custom hash code. But this code needs to be performant -- it will be called many times during painting.
Assignee: nobody → continuation
Depends on: 999575
This also turns nsTransitionKey into an inner class of nsStyleContext, and changes it from an nsHashKey to a class to be used with nsGenericHashKey.

It also changes the intermediate values of the hash computation to uints, instead of signed ints, as that seems more right.
Attachment #8411092 - Flags: review?(dbaron)
It is now a pointless wrapper around uint32_t.
Attachment #8411093 - Flags: review?(dbaron)
Comment on attachment 8411092 [details] [diff] [review]
part 5 - Convert nsTreeStyleCache::mTransitionTable to nsClassHashtable.

>Bug 972601, part 5 - Convert nsTreeStyleCache::mTransitionTable to nsClassHashtable. r=dbaron
>
>This also turns nsTransitionKey into an inner class of nsStyleContext, and changes it from an nsHashKey to a class to be used with nsGenericHashKey.

of nsTreeStyleCache, not nsStyleContext

>+bool nsTreeStyleCache::Transition::operator==(const Transition& aOther) const

newline after bool

>+{
>+  return aOther.mState == mState && aOther.mInputSymbol == mInputSymbol;
>+}
>+
>+uint32_t nsTreeStyleCache::Transition::Hash() const

newline after uint32_t


I spent a bit of time checking that what both APIs expected from their Hash()/HashCode() function was the same, but it should have been obvious since they both use pldhash.  (i.e., no need to use the MFBT AddToHash functions)

r=dbaron



But please test that trees still paint reasonably after your patch, since we have almost no test coverage for it.  Look at, say, the bookmarks sidebar, about:config, and some of the things in the preferences UI.

(Also, it would probably be good to double-check that you're still hitting the cache at similar rates.)
Attachment #8411092 - Flags: review?(dbaron) → review+
Thanks for the reviews.

(In reply to David Baron [:dbaron] (needinfo? me) (UTC-7) from comment #9)
> of nsTreeStyleCache, not nsStyleContext
> newline after bool
> newline after uint32_t
Done.

> But please test that trees still paint reasonably after your patch, since we
> have almost no test coverage for it.  Look at, say, the bookmarks sidebar,
> about:config, and some of the things in the preferences UI.
>
> (Also, it would probably be good to double-check that you're still hitting
> the cache at similar rates.)

I looked around at those things you mentioned (I wasn't really sure what this code was for), and they look okay.  The cache rate looks more or less the same, too.

I'll land after the trees open.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: