clean up reference-counting in xpcom/

RESOLVED FIXED in Firefox 43

Status

()

Core
XPCOM
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: froydnj, Assigned: froydnj)

Tracking

unspecified
mozilla43
Points:
---

Firefox Tracking Flags

(firefox43 fixed)

Details

Attachments

(1 attachment)

Comment hidden (empty)
Created attachment 8644939 [details] [diff] [review]
clean up reference-counting in xpcom/

Mostly, what we're doing here is eliminating:

  NS_ADDREF(*aOutParam = ptr);

in favor of:

  ptr.forget(aOutParam);

which is smaller and more efficient.  Various null-checks might have been
eliminated in passing as well.
Attachment #8644939 - Flags: review?(erahm)
Comment on attachment 8644939 [details] [diff] [review]
clean up reference-counting in xpcom/

Review of attachment 8644939 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, nice cleanup. r=me

::: xpcom/glue/nsArrayEnumerator.cpp
@@ -92,5 @@
>  NS_NewArrayEnumerator(nsISimpleEnumerator** aResult, nsIArray* aArray)
>  {
> -  nsSimpleArrayEnumerator* enumer = new nsSimpleArrayEnumerator(aArray);
> -  if (!enumer) {
> -    return NS_ERROR_OUT_OF_MEMORY;

Presumably it's OK to get rid of this b/c the allocator our new operator uses is infallible?
Attachment #8644939 - Flags: review?(erahm) → review+
> Presumably it's OK to get rid of this b/c the allocator our new operator
> uses is infallible?

Yes. |operator new| is infallible by default, though you can make it fallible by passing a |fallible_t| argument. See memory/mozalloc/mozalloc.h for details.
We also have some documentation on infallible allocation here:
https://developer.mozilla.org/en-US/docs/Infallible_memory_allocation

Comment 5

2 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/69980d43dea7
https://hg.mozilla.org/mozilla-central/rev/69980d43dea7
Status: NEW → RESOLVED
Last Resolved: 2 years ago
status-firefox43: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
You need to log in before you can comment on or make changes to this bug.