• 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: Cocoa's custom class delegate conventions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa's custom class delegate conventions


  • Subject: Re: Cocoa's custom class delegate conventions
  • From: Sherm Pendley <email@hidden>
  • Date: Sat, 14 Jun 2003 15:29:24 -0400

On Saturday, June 14, 2003, at 05:31 AM, Bill Cheeseman wrote:

I've been told that there is some other "magic" optimization done in Cocoa,
but I don't know what it is. Something about caching the selectors?

IMP addresses are cached. The first time you send a particular message, the runtime has to do a sequential search through all of the objc_method_list arrays attached to a class definition to find a pointer to that method's implementation function - that is, its IMP.

When it's found, the IMP is stored in a hash, keyed on the class and selector. That way, it remains dynamic, but the second and subsequent lookups are much faster than a sequential search.

If you're curious and have some time on your hands, the ObjC runtime is part of Darwin. It's not exactly light reading, but it's definitely educational. ;-)

sherm--

"Though a program be but three lines long, someday it will have to be maintained."

-- The Tao of Programming
_______________________________________________
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.

References: 
 >Re: Cocoa's custom class delegate conventions (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Re: Cocoa's custom class delegate conventions
  • Next by Date: Re: Subclass
  • Previous by thread: Re: Cocoa's custom class delegate conventions
  • Next by thread: Re: Cocoa's custom class delegate conventions
  • Index(es):
    • Date
    • Thread