• 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: Zeroing out instance variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Zeroing out instance variables


  • Subject: Re: Zeroing out instance variables
  • From: Michael Ash <email@hidden>
  • Date: Sun, 18 Apr 2010 21:52:23 -0400

On Sun, Apr 18, 2010 at 2:09 AM, Kyle Sluder <email@hidden> wrote:
> On Sat, Apr 17, 2010 at 8:29 PM, Ben Haller
> <email@hidden> wrote:
>>  I don't think I'm crazy about this.  There are many different subclasses,
>> so each subclass would have its own corresponding struct, and every ivar
>> access would go through an indirection; it sounds very confusing and messy.
>>  Not to say there might not be cases where it would be the correct design;
>> but for my situation, I think I'm happier with my current design.  Thanks
>> for the suggestion, though!
>
> Dirty little secret: every ivar access on 64-bit is already indirected
> through the runtime. Otherwise the runtime couldn't support
> non-fragile instance variables. :)
>
> You could theoretically get better performance if your instance
> variable were a pointer-to-struct. But if your way is sufficiently
> performant, stick with it.

If by "indirected through the runtime" you mean "accesses one global
variable to get an offset". It does not, as one might take your
comment to indicate, actually call any runtime functions.

Putting everything in a pointer to a struct won't be faster. You have
to access an ivar anyway to get the pointer, and then you've added
another dereference before you can get your data. In addition, you've
hurt locality of reference, so will probably have worse cache
performance characteristics.

Mike
_______________________________________________

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

  • Follow-Ups:
    • Re: Zeroing out instance variables
      • From: Kyle Sluder <email@hidden>
References: 
 >Zeroing out instance variables (From: Ben Haller <email@hidden>)
 >Re: Zeroing out instance variables (From: Ken Thomases <email@hidden>)
 >Re: Zeroing out instance variables (From: Ben Haller <email@hidden>)
 >Re: Zeroing out instance variables (From: Charles Srstka <email@hidden>)
 >Re: Zeroing out instance variables (From: Kyle Sluder <email@hidden>)
 >Re: Zeroing out instance variables (From: Ben Haller <email@hidden>)
 >Re: Zeroing out instance variables (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Introspecting the current method
  • Next by Date: Re: Introspecting the current method
  • Previous by thread: Re: Zeroing out instance variables
  • Next by thread: Re: Zeroing out instance variables
  • Index(es):
    • Date
    • Thread