Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: kEventParamPostTarget



On Jul 31, 2005, at 1:03 AM, Laurence Harris wrote:

On 7/31/05 3:52 AM, Yaron Tadmor didst favor us with:


To create and post the event I use:

EventRef event;
CreateEvent (NULL, 'XXXX', 'XXXX', GetCurrentEventTime(),

I'm a big believer in using named constants:

CreateEvent (kCFAllocatorDefault, 'XXXX', 'XXXX', GetCurrentEventTime(),


<offtopic>
I was never actually a fan of kCFAllocatorDefault. The biggest reason was that early versions of CarbonLib didn't even export that symbol, so you can't use it in code that targets pre-OS 9.0. That's a non- issue nowadays, but there's still no advantage to using the named "constant"--there is a disadvantage, however, because in this case it's not as efficient as a regular constant! The headers define it as


/* This is a synonym for NULL, if you'd rather use a named constant. */
CF_EXPORT const CFAllocatorRef kCFAllocatorDefault;

Which means that every time you use it, the compiler goes and looks it up in memory instead of just sticking a zero into r3 like it could if you use NULL. Larger code size for no benefit.
Neither of these issues are really a big deal--the cost of the load is one or two extra opcodes, and nobody supports Mac OS 8 any more. So nowadays you can use whichever technique you prefer. Personally I'll stick with the smaller code size, since I'm used to seeing NULL as the allocator anyway.
</offtopic>


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: kEventParamPostTarget (From: Laurence Harris <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.