Re: to be effcient or not to be efficient

"Toby Hudon" <[email protected]>
Newsgroups gmane.comp.multimedia.media-api
Message-ID <[email protected]>
----- Original Message -----
From: Steve Lhomme <[email protected]>
Date: Thu, 08 Jan 2004 19:50:05 +0100
To: "The attempt to create a new,  open standard codec API" <[email protected]>
Subject: Re: [Media-api] to be effcient or not to be efficient

> Toby Hudon wrote:
> 
> >>If the vtable is set up by the API library (as opposed to a specific
> >>codec/filter) it might be nicer to set unimplemented functions to
> >>some dummy functions which just return an error instead of NULL; otherwise
> >>the caller has to always check whether a pointer is NULL before calling the
> >>function.
> >>
> > 
> > 
> > Umm... but if you have a function that just returns "not supported", won't you have to check for that every time after you call to see if what you just did produced the right result or find some way to store a state so you know not to call it? Checking for NULL first just saves the function call.
> 
> But as it's deep inside the code it may be called many times.
> For speed efficiency it's better to do as much checking as possible in 
> the init. Then the actual processing will have to check for much less 
> errors.
> 

I agree, I was just trying to say that checking if a function pointer is null is functionally equivalent to calling the function and having it return some value that indicates it's an unsupported function, but the latter method just involves an extra pointless function call. Even if you're just doing it in init it's silly to call a function to get information you could already have by the function not being there.
-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.