Re: to be effcient or not to be efficient
Steve Lhomme <[email protected]>
| Newsgroups | gmane.comp.multimedia.media-api |
|---|---|
| Message-ID | <[email protected]> |
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.