Re: How to tell if an interface method has been implemented



Jon Skeet [C# MVP] wrote:

It would take more time if you had to do it every time, yes. You'd want to cache that information - indeed, you might end up putting objects which only had stub implementations into a different collection, etc. It all depends on the situation.

I have never tested anything like this, but I imagine the time to call an empty method to be extremely small - if the compiler doesn't optimize away the call to begin with. I guess if you were going to use a single bool flag per method and just checked it on later calls, you might save some time. But as soon as any kind of more complicated lookup comes into play, such as using collections of any kind, I can't believe you'll actually save time compared to just calling the method.


Anyway, it's again one of these things: I'd just call the method, unless the profiler shows me that this is a bad idea.



               Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog
.



Relevant Pages

  • buffer/vm cache, turn off for a specific file ?
    ... What seems to happen is that the OS, linux, caches each ... Is there any way to ask the system to *not* to cache a file after ... still happen with a local file system. ... so it is not really practical to play with kernel options ...
    (comp.unix.programmer)
  • Re: PowerBook 15" - strange problems
    ... >take it to the nearest Apple dealer, and ask them to play with the RAM... ... cache on it and would frequently kernel panic after going to sleep. ... frozen iTunes display. ...
    (comp.sys.mac.portables)
  • CSourceStream filter
    ... I can get it to play just fine. ... I cant seem to clear the internal graph cache. ... DeliverBeginFlush() ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: Saving cached QuickTime movies
    ... which I can certainly play offline. ... What version of QuickTime are you using? ... QuickTime 7 cache files seem to ... I didn't get anything out of the cache, ...
    (uk.comp.sys.mac)