[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: Re: kdemultimedia/mpeglib/lib/input
From: Stephan Kulow <coolo () kde ! org>
Date: 2002-03-20 10:22:22
[Download RAW message or body]
On Tuesday 19 March 2002 23:50, Frerich Raabe wrote:
> On Tuesday 19 March 2002 23:40, Malte Starostik wrote:
> > Am Tuesday 19 March 2002 23:25 schrieb Frerich Raabe:
> > > On Tuesday 19 March 2002 20:28, Malte Starostik wrote:
> > > > Modified Files:
> > > > fileInputStream.cpp
> > > > Log Message:
> > > > LOL
> > > >
> > > > - if (bytesRead == 0){
> > > > - bytesRead=0;
> > > > - }
> > >
> > > Better safe than sorry, I guess.
> >
> > Right, any objections against this?
> >
> > switch (bytesRead)
> > {
> > case 0: bytesRead = 0; break;
> > case 1: bytesRead = 1; break;
> > case 2: bytesRead = 2; break;
> > case 3: bytesRead = 3; break;
> > case 4: bytesRead = 4; break;
> > case 5: bytesRead = 5; break;
> > default: bytesRead = bytesRead; break;
> > }
> >
> > Should make it even safer, especially for small values of bytesRead.
>
> I propose creating an 'Number' baseclass with a pure virtual 'value()'
> method from which you derive 'One', 'Two' and 'Three'. Then use a
> parametrized factory function to create the correct subclass, depending on
> bytesRead. You can then safely call 'bytesRead = number->value();' and thus
> let the compiler figure out which number to assign, which is clearly less
> error prone.
>
And I want to see the compiler that optimizes _that_ out :)
Greetings, Stephan
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic