Closed Bug 207220 Opened 21 years ago Closed 5 years ago

Convert nsBindingManager to typesafe datastructures

Categories

(Core :: XBL, defect, P3)

defect

Tracking

()

RESOLVED WONTFIX
mozilla1.5alpha

People

(Reporter: peterv, Assigned: peterv)

Details

Attachments

(1 file)

 
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → mozilla1.5alpha
Attached patch v1Splinter Review
Attachment #124280 - Flags: review?(bsmedberg)
Comment on attachment 124280 [details] [diff] [review]
v1

>+class nsIContentHashKey : public PLDHashEntryHdr

I have reservations about using a non-nsISupports key, although it may be
necessary for performance reasons. According to COM theory, you can't compare
two nsIContent* to check object identity (only nsISupports* are guaranteed for
identity).

Since we know that nsIContent is not implemented as a tearoff, it may be
worthwhile to ignore the COM rules here to avoid the extra QI on every call to
GetInsertionParent

>+  NS_PRECONDITION(aOldDocument, "no old document");
>+  if (!aOldDocument)
>     return NS_ERROR_NULL_POINTER;

nit: NS_ENSURE_ARG_POINTER(aOldDocument) is cleaner and easier to read

>+    nsIDOMNodeList* contentList = new nsAnonymousContentList(aList);
>+    if (!contentList)
>+      // XXX Should we Remove here?
Hmmm, there's a good case for it... would it introduce crashes in odd places?

> nsBindingManager::ProcessAttachedQueue()
[snip]
>+  PRInt32 count = mAttachedQueue.Count();
>+  PRInt32 i;
>+  for (i = 0; i < count; ++i) {
>+    if (mAttachedQueue.Count() > 0) {
>+      nsCOMPtr<nsIXBLBinding> binding = mAttachedQueue.ObjectAt(0);
>+      mAttachedQueue.RemoveObjectAt(0);
>       binding->ExecuteAttachedHandler();
>+    }
[snip]
>+  mAttachedQueue.Clear();

If this is a reentrant loop, I would use a while loop instead;
nsCOMArray<T>::Count() is a cheap inline call that you can repeat:
while(mAttachedQueue.Count())

Why are you calling Clear() after you have removed all the items?

r=me if you address nsIContentHashKey and the ProcessAttachedQueue loop.
Attachment #124280 - Flags: review?(bsmedberg) → review+
QA Contact: ian → xbl

XBL is now disabled in Firefox (Bug 1583314) and is in the process of being removed from Gecko (Bug 1566221), so closing bugs requesting changes to its implementation as wontfix.

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: