Re: to be effcient or not to be efficient

Enrico Weigelt <[email protected]>
Newsgroups gmane.comp.multimedia.media-api
Message-ID <[email protected]>
* Toby Hudon <[email protected]> [2004-01-07 12:54:44 -0500]:

<snip>
> Then I'd like to hear it, because my last CS professor's idea 
> of "efficient" switch handling was replacing a 22 case switch 
> with a system where you have a class with a pure virtual 
> function and then inherit from it for 22 subclasses, then in 
> each subclass implement the virtual function which the orignial 
> function call calls in place of the switch, so that your code 
> is dependant on which subclass is being passed to the calling 
> function. Oh and do this kinda thing for every possible function 
> like execute, print, etc. Because as we know a 22 entry switch 
> statement would be bad and cause bugs. Much more so than several 
> hundred lines of code in 30 seperate files.
eh ?! did he tell you, _why_ this should be more efficent ? 
on general neumann-automatas, a switch in binary code looks like

:check1
CMP a,1
JNE check2
<something for code1>

:check2
CMP a,2
JNE check3...
<something for code2>

...

And vtable lookups require quite complex pointer arithmetics, i.e.
translating vtable addresses, ... I dont think that this will be 
faster on some common hardware.

In a switch() you can simply write down some code which then directly 
stands there in the binary. Using vtables, you have _always_ to use
separate functions. 


Well, I also have to live with such profs which tell their students
stupid things, from java missionars which tell all other languages
"too unclean and to unsecure" ("resources are available almost unlimited ...")
or wannabe-economics whose bookkeeping methods only work when you're not
going to make any profit ... well especially here in Ilmenau, many profs
are far, far away from the reality ...

> BTW I dropped out last year after his class was impossible to pass 
> without cheating. Sorry I can't rewrite an entire compiler in a language 
> I've never used before to support new features for a language I've never 
> heard of before in 3 weeks and then follow up with a full virtual machine 
> and debugger in 2 more without having more than just myself to do this 
> in the middle of all my other classes.

Yeah, thats the common problem at universities. Profs think their're alone
and you're studying only _their_ stuff. We for example have our math
sadists which believe CS is a small part of math and so give us CS-students
harder tasks than the math students ...

Those people are simply ill!

<snip>
> write data, in sequence
> not sure if we'd ever have a non-sequential write (encode)
hmm, would we call writing seeked AV streams also non-seuqential write ?

what should come out if we simply plug in an encoder as output device
into a movie player and then do seeking ? (did anyone check out, what 
xmms does in this case ?)


<snip>
> capabilities reporting messages? 
I personally prefer structs wich function pointers. There I would add 
interface version information. All unsupported functions are simply NULL.

<snip>
> Or do we just use try and if fail try something else? Note you could just 
> set an internal flag on the first success to remember what to do on every 
> subsequent call for the remainder of the video so you only have the mutliple 
> call overhead once.
This sounds quite complicated.


cu
-- 
---------------------------------------------------------------------
 Enrico Weigelt    ==   metux IT services

  phone:     +49 36207 519931         www:       http://www.metux.de/
  fax:       +49 36207 519932         email:     [email protected]
  cellphone: +49 174 7066481
---------------------------------------------------------------------
 Diese Mail wurde mit UUCP versandt.      http://www.metux.de/uucp/
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.