Bug 143747 - JavaScriptCore: Use kCFAllocatorDefault where possible
Summary: JavaScriptCore: Use kCFAllocatorDefault where possible
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-14 18:25 PDT by Joseph Pecoraro
Modified: 2015-04-15 10:56 PDT (History)
5 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (3.40 KB, patch)
2015-04-14 18:26 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.