• 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: Using "IMP" to speed up loops?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using "IMP" to speed up loops?


  • Subject: Re: Using "IMP" to speed up loops?
  • From: Marcel Weiher <email@hidden>
  • Date: Sun, 10 Nov 2002 21:13:05 +0100

On Sunday, November 10, 2002, at 05:20 Uhr, Ken Tozier wrote:

I was reading up on how to use IMP in the NSObject documentation in
order to speed up some of my loops, but the examples don't look right.

The documentation suggested declaring IMP's like this:

typedef BOOL (*ASCIICompareIMP)(id, SEL, unsigned char);

EqualIMP test;

test = (EqualIMP)[target methodForSelector:@selector(isEqual:)];

And using them like this:

while ( !test(target, @selector(isEqual:), someObject) )
{
...
}

But given that the initialization line:

test = (EqualIMP)[target methodForSelector:@selector(isEqual:)];

already encapsulates "id" and "SEL" from the prototype, I would have
expected it to be used like:

while ( !test(someObject) )
{
...
}

What's the scoop?

The scoop is that methodForSelector simply returns a C function pointer. It is not a "currying" operation.

Marcel

--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
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: 
 >Using "IMP" to speed up loops? (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: "weak link" framework refs for 10.1 compatibility?
  • Next by Date: Re: Move a file to the Trash
  • Previous by thread: Re: Using "IMP" to speed up loops?
  • Next by thread: [Repost] Subclassing NSTableColumn
  • Index(es):
    • Date
    • Thread