Closed
Bug 1653011
Opened 4 years ago
Closed 4 years ago
WeakPtr is inefficient when inheritance is involved.
Categories
(Core :: MFBT, defect)
Core
MFBT
Tracking
()
RESOLVED
FIXED
mozilla80
Tracking | Status | |
---|---|---|
firefox80 | --- | fixed |
People
(Reporter: emilio, Assigned: emilio)
Details
Attachments
(1 file)
Consider the following case, for which we have multiple occurrences of like WebGL{Child,Parent} or WebGPUChild, etc:
class Base : SupportsWeakPtr<Base> {};
class Foo : Base {};
Ideally you'd be able to use WeakPtr<Foo>
, but right now you can't, and instead you need to do:
class Foo : Base, SupportsWeakPtr<Foo> {};
That bloats the object by another word, which is quite unfortunate.
Assignee | ||
Comment 1•4 years ago
|
||
Furthermore, when you use:
void doSomething(Foo* f) {
WeakPtr<Foo> weak(f);
}
Does compile, but it overflows the stack because we get here, which goes to operator=
, but since there's no SupportsWeakPtr<Foo>
, we get to the operator=(const WeakPtr&)
using the implicit constructor (thus back to one).
Assignee | ||
Comment 2•4 years ago
|
||
Having two classes in the inheritance chain inherit from SupportsWeakPtr
now won't compile, but you can use WeakPtr<Derived> when any base class
inherits from SupportsWeakPtr.
Updated•4 years ago
|
Assignee: nobody → emilio
Status: NEW → ASSIGNED
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/be4b0f6e68c9
Simplify and make WeakPtr<Derived> usable and compact. r=froydnj,sg,geckoview-reviewers,jgilbert,kvark,snorp
Comment 4•4 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
status-firefox80:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla80
You need to log in
before you can comment on or make changes to this bug.
Description
•