• 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: Is this the correct way to cache an IMP?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is this the correct way to cache an IMP?


  • Subject: Re: Is this the correct way to cache an IMP?
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Thu, 5 Aug 2010 15:12:08 +0200

Le 5 août 2010 à 14:59, Graham Cox a écrit :

> I have a Obj-C method that is highly recursive, and needs to run at maximum performance. With this in mind, I am locally caching the method's own IMP to avoid the message dispatch for the recursive calls. It seems to work and gives a measurable benefit, but I need to be absolutely certain it's right before committing it to a release. Can anyone comment on whether it actually is right? Have I missed anything? Anything even faster?
>

Probably not faster, but cleaner IHMO:

@implementation MyObject

static
void _RecursivelySearchWithRect(MyObject *self, NSRect rect, NSUInteger indx) {
	// Do something and access ivar using 'self->ivar' syntax if needed.
	// As long as this function is defined between "@implementation MyObject" and "@end", you can perfectly access private ivar directly.

// recurse
	_RecursivelySearchWithRect(self, rect, subnode);
}

- (void) recursivelySearchWithRect:(NSRect) rect index:(NSUInteger) indx {
  _RecursivelySearchWithRect(self, rect, indx);
}

@end

-- Jean-Daniel




_______________________________________________

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: Is this the correct way to cache an IMP?
      • From: Graham Cox <email@hidden>
References: 
 >Is this the correct way to cache an IMP? (From: Graham Cox <email@hidden>)

  • Prev by Date: Is this the correct way to cache an IMP?
  • Next by Date: Re: Is this the correct way to cache an IMP?
  • Previous by thread: Is this the correct way to cache an IMP?
  • Next by thread: Re: Is this the correct way to cache an IMP?
  • Index(es):
    • Date
    • Thread