• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Instance vars, local vars and speed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Instance vars, local vars and speed


  • Subject: Re: Instance vars, local vars and speed
  • From: Negm-Awad Amin <email@hidden>
  • Date: Mon, 4 Aug 2008 14:59:54 +0200


Am Mo,04.08.2008 um 14:51 schrieb Jean-Daniel Dupas:


Le 4 août 08 à 13:26, Trygve Inda a écrit :

I am transitioning some code from Carbon to Cocoa and redesigning a lot of
how things work. I am doing a bit of low-level pixel manipulation and
wondering about speed of access to variables declared in a method vs those
declared at the object level.


Obviously things like x,y loop counters are local to a method, but some
things need to be shared between methods and rather then passing values
around, it would be cleaner to declare these at the object level.


How much of a hit am I going to take?

Would it be best to declare them at the object level and copy it into a
local as needed... Will the compiler be smart enough to sort this out?


Will it ever put object (instance) variables in a register?

I know it may require real world testing, but it affects my overall design
too. Note that it could be going through a loop roughly 3 million times on a
large image.


Many thanks,

Trygve


IMHO, this is just premature optimisation.

That said, there is no cost to access an ivar using the 32 bits runtime, and I don't think the cost on 64 bits runtime is important enough to bother with it.
I agree with this! It is not important how often $something is used, but which part of all-over costs it produces. If this operation is done 2389447982374329847239843298 times, the user maybe will wait four weeks. With a little cost added he will wait four weeks and two hours. Problem?

On the other hand I'm mnot sure, whether his problem ist really oo. It sounds a little bit to me, that he makes something oo, which is not oo. There *can* be advantages to put "compound values" in an object. But there is no need to do so every time. Sometimes a C-Structure is a good solution, that works: NSRect, NSPoint …

Amin






_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

Amin Negm-Awad email@hidden




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Instance vars, local vars and speed (From: Trygve Inda <email@hidden>)
 >Re: Instance vars, local vars and speed (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: Documentation
  • Next by Date: Re: Documentation
  • Previous by thread: Re: Instance vars, local vars and speed
  • Next by thread: Re: Instance vars, local vars and speed
  • Index(es):
    • Date
    • Thread