Closed Bug 1251530 Opened 6 years ago Closed 6 years ago

Use 'MakeUnique' instead of 'new' to populate UniquePtr variable in AddCSSValuePair

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
trivial

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox47 --- fixed

People

(Reporter: dholbert, Assigned: dholbert)

References

Details

Attachments

(1 file)

Just noticed a UniquePtr anti-pattern that I let slip through in review (but should've caught) in bug 1110460 part 3.

The UniquePtr header says:

> 619  *   UniquePtr<char> p;
> 620  *   p = new char;           // ERROR
> 621  *   p.reset(new char);      // works, but fugly
> 622  *   p = MakeUnique<char>(); // preferred
http://mxr.mozilla.org/mozilla-central/source/mfbt/UniquePtr.h#619

...with more details about why MakeUnique() is preferred.

We added a "fugly" line here: 
http://hg.mozilla.org/mozilla-central/diff/64a6ad689503/layout/style/StyleAnimationValue.cpp#l1.49

Filing this bug on replacing it with MakeUnique.
Summary: Use MakeUnique for UniquePtr assignment, in AddCSSValuePair → Use 'MakeUnique' instead of 'new' to populate UniquePtr variable in AddCSSValuePair
Attached patch fixSplinter Review
Here's the fix, just following the recommendation quoted in comment 0.
Attachment #8723950 - Flags: review?(jwatt)
Comment on attachment 8723950 [details] [diff] [review]
fix

Good catch!
Attachment #8723950 - Flags: review?(jwatt) → review+
Flags: in-testsuite-
https://hg.mozilla.org/mozilla-central/rev/5aa8163c1cdd
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
You need to log in before you can comment on or make changes to this bug.