Re: NSMakePoint and such - what about memory allocation?
Re: NSMakePoint and such - what about memory allocation?
- Subject: Re: NSMakePoint and such - what about memory allocation?
- From: Allan Odgaard <email@hidden>
- Date: Sat, 22 May 2004 06:38:37 +0200
On 22. May 2004, at 5:16, Jim Witte wrote:
ehm... you do know that C is a standard, and compilers should adhere
to it rather than introduce "smart" new notation on their own? :)
Yes, but if p = NSPoint(50,50) where p is an automatic variable, and
is thus allocated as a record on the stack, which is then assigns
directly, as
Sorry, I thought you wanted implicit constructors (as mentioned in the
post you replied to). I think your NSPoint()'s should have read
NSMakePoint() (which would have made your statement legal, and the
source of my confusion).
There is of cause nothing in the standard which prevents the compiler
from removing/optimizing "redundant" code. But I honestly think that
gcc is sort of broken when it comes to this. A statement similar to
yours, e.g.:
NSLine l = NSMakeLine(NSMakePoint(1, 2), NSMakePoint(3, 4)); [1]
PrintLine(l);
Generates ~40 instructions (having the NSMake... functions inlined, but
not the PrintLine function). And that is using -Os (optimize for
*size*).
I would think/hope that the commercial compilers (CodeWarrior and
IBM's) do it better! ;)
[1] I added a suiting NSLine typedef and NSMakeLine function for this
to work.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.