Bug 143747

Summary: JavaScriptCore: Use kCFAllocatorDefault where possible
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: JavaScriptCoreAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, commit-queue, ggaren, joepeck, mitz
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
[PATCH] Proposed Fix none

Description Joseph Pecoraro 2015-04-14 18:25:07 PDT
* SUMMARY
Use kCFAllocatorDefault instead of NULL/0/nullptr where possible.

This came up as a review comment for one of my changes. There are only a few in JSC, the other frameworks can be addressed separately later.
Comment 1 Joseph Pecoraro 2015-04-14 18:26:27 PDT
Created attachment 250771 [details]
[PATCH] Proposed Fix
Comment 2 Alexey Proskuryakov 2015-04-14 18:42:25 PDT
I'm curious what the rationale is. Isn't 0 slightly faster?
Comment 3 Joseph Pecoraro 2015-04-14 18:50:18 PDT
(In reply to comment #2)
> I'm curious what the rationale is. Isn't 0 slightly faster?

My rationale was "consistency and readability". In cases where the first parameter is an allocator, then specifying kCFAllocatorDefault removes any ambiguity that may exist if "0" or "nullptr" was used for the first argument.

That said, I don't really have strong opinions on this. It was brought up in a review on one of my patches.
Comment 4 Darin Adler 2015-04-15 10:08:11 PDT
Comment on attachment 250771 [details]
[PATCH] Proposed Fix

This is the clearest and most correct way to write it, but oh so wordy. In my non-WebKit code I almost always used NULL for this.
Comment 5 WebKit Commit Bot 2015-04-15 10:56:49 PDT
Comment on attachment 250771 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 250771

Committed r182847: <http://trac.webkit.org/changeset/182847>
Comment 6 WebKit Commit Bot 2015-04-15 10:56:52 PDT
All reviewed patches have been landed.  Closing bug.