Closed
Bug 976373
Opened 10 years ago
Closed 10 years ago
Collect mutation records to a list, not to an array
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla30
People
(Reporter: smaug, Assigned: smaug)
Details
Attachments
(2 files)
10.42 KB,
patch
|
mccr8
:
review+
|
Details | Diff | Splinter Review |
10.45 KB,
patch
|
Details | Diff | Splinter Review |
Currently we collect mutation records to a list, but that is malloc/free heavy in case we have lots of records. So we could just collect them to a list and create the result array on demand.
Attachment #8381032 -
Flags: review?(continuation)
Comment 1•10 years ago
|
||
We've got a nice LinkedList abstraction in mfbt, btw.
Comment 2•10 years ago
|
||
Yeah, I was thinking of suggesting that, but does it support having the next pointer be an nsRefPtr?
Assignee | ||
Comment 3•10 years ago
|
||
That LinkedList is not nice in any way, especially not for strong references.
Comment 4•10 years ago
|
||
Comment on attachment 8381032 [details] [diff] [review] patch Review of attachment 8381032 [details] [diff] [review]: ----------------------------------------------------------------- ::: content/base/src/nsDOMMutationObserver.cpp @@ +601,5 @@ > mozilla::dom::Sequence<mozilla::dom::OwningNonNull<nsDOMMutationRecord> > > mutations; > + if (mutations.SetCapacity(mPendingMutationCount)) { > + // We can't use TakeRecords easily here, because it deals with > + // different type of array, and we want to optimize out any extra copying. nit: "with different" -> "with a different" @@ +602,5 @@ > mutations; > + if (mutations.SetCapacity(mPendingMutationCount)) { > + // We can't use TakeRecords easily here, because it deals with > + // different type of array, and we want to optimize out any extra copying. > + nsRefPtr<nsDOMMutationRecord> current; If you wanted to avoid code duplication here, you could turn this loop into a template, and then instantiate it in the two places you need to do a copy loop. ::: content/base/src/nsDOMMutationObserver.h @@ +392,5 @@ > + if (!mLastPendingMutation) { > + MOZ_ASSERT(!mFirstPendingMutation); > + mFirstPendingMutation = aRecord; > + mLastPendingMutation = mFirstPendingMutation; > + } else { Maybe |MOZ_ASSERT(mFirstPendingMutation);|?
Attachment #8381032 -
Flags: review?(continuation) → review+
Assignee | ||
Comment 5•10 years ago
|
||
Assignee | ||
Comment 6•10 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/7ea5a64f9279
Comment 7•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/7ea5a64f9279
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•