This needs a different approach

Ary Borenszweig ary at esperanto.org.ar
Mon Apr 28 14:29:33 PDT 2008


Premature optimization is bad.

Try doing it that way, and only optimize it if you see it's working slowly.

Saaa escribió:
> I think I get your code now :)
> 
> Tell me if I'm wrong:
> This approach makes initializing the  fruits list a bit more complex.
> Changing an item in the list to another fruit requires the GC (the previous 
> instance needs to be deleted)
> Changing an item is more costly than changing a number. (A lot of the items 
> get changed 30 times per second)
> 
> Wouldn't a function table be more appropriate?
> 
>> So with the get method I outlined above, the switch code becomes:
>>
>> get(data[i].type).eat();
>>
>> -Steve
>>
> 
> 


More information about the Digitalmars-d-learn mailing list