Re: to be effcient or not to be efficient

Tuukka Toivonen <[email protected]>
Newsgroups gmane.comp.multimedia.media-api
Message-ID <Pine.GSO.4.58.0401082058260.13832@stekt37>
On Thu, 8 Jan 2004, Toby Hudon wrote:

>> >  .seek_frame = NULL; /* not implemented call */
>> 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
>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

- If the pointer may be NULL, you must check for it _before_ calling a
  function and then you need another check _after_ the function to check
  the return value for possible other errors anyway.
  Therefore, dummy non-NULL pointers are more efficient (faster).

- You might not care about possible errors, and in that case no
  checks are necessary at all if non-NULL pointers are guaranteed
  (it's also safer: some buggy code might not check for NULL
  pointers but just call directly a function that is usually
  implemented anyway, with dummy pointers no harm is done,
  but with NULL function pointer there would be a segfault).
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.