|
From: <fl...@ma...> - 2003-07-21 20:08:08
|
Dont worry about optimizing it too much, I am more interested to make =
sure it works how it is supposed to work. And move to another task, we =
can always profile and optimize later... 1% of the code gets you 99% of =
the bang. The other important stuff to consider is code readability, I =
didnt have much problem to understand it, however there are still some =
deviations from the coding standard that you had followed almost =
flawlessly in this version of the code...
The use of the { in an improper place like in the virtual file like this
switch (startingPoint){
// If invalid value, assume default and continue
default:
advAssert(0,"Unknown starting point. _STINITIALPOSITION assumed");
};
It should be like this:
switch (startingPoint)
{
// If invalid value, assume default and continue
default:
{
advAssert(0,"Unknown starting point. _STINITIALPOSITION =
assumed");
}
};
By the way try not to use the switch continuation unless you really need =
to, the semantics of that structure is pretty difficult to follow for =
non seasoned C++ programmers. And it is easy to overlook its =
implications when debugging.
Ex:
switch (pepe)
{
case 1:
{ pepe--; };
case 2:=20
{
pepe++;=20
break;
};
};
I had saw too some unneeded uses of the continue keyword at the =
paqdeveloperstable.cpp file..
Ex:
// Binary search
while(max >=3D min)
{
mid=3Dmin + (max-min)/2;
if ( mid->filenameHash =3D=3D crcNumber )
{
this->namesList.erase(mid);
return;
}
else if (mid->filenameHash > crcNumber)
{ max =3D mid-1; continue; } // sx
else=20
{ min =3D mid+1; continue; } // dx
}
It should be:
// Binary search
while(max >=3D min)
{
mid=3Dmin + (max-min)/2;
if ( mid->filenameHash =3D=3D crcNumber )
{
this->namesList.erase(mid);
return;
}
else if (mid->filenameHash > crcNumber)
{ max =3D mid-1; } // sx
else=20
{ min =3D mid+1; } // dx
}
As stated above try to avoid using that kind of dynamic semantic rules =
(they are hidden gotos) that make pretty difficult the readability of =
the code... Read this as: "If there is another way to do it (more =
clearly) use it, if not we will have to live with that".
About the library stuff, dont worry I will do that personally. And no, =
we dont need a command line utility, that is what PAQ Explorer is for. =
About the PAQ Explorer if anyone reading this mail wants to take that =
task, you are welcome to raise your hand... By the way if you never used =
VCL it is not difficult at all (promise), in fact it is the easies way =
arround any GUI related programming problem, if you have a GUI to do in =
C++ consider use Borland to do that. It is amazing what it can do, by =
the way if you already know Delphi, it is the same library :D=20
Greetings
Red Knight
----- Original Message -----=20
From: Ermete Gaudenzi=20
To: xen...@li...=20
Sent: Saturday, July 19, 2003 7:01 PM
Subject: Re: [Xenocide-programming] always PAQ
Hi to all again.
I've finished the PAQ Manager implementation. YEP!
Now I'm going to review the code, optimize it, comment it better and =
so on..
Today I finally finished the developers table manager and I improved =
the speed in the addFile methods.
I changed the insertion algorithm from -append to the end then sort =
all- into -binary search the right place and insert there-.
The code is a bit more difficult to understand but the speed is really =
better !!
I tried to add the entire filenames of my hard disk into the archive =
with full path (of course without the real file data). There was 19079 =
files... whoops
Elapsed time: 32927 milli-seconds
I'm impressed... and I run the test in debug mode... let's try in =
release speed-optimized mode...
Elapsed time: 24466 milli-seconds
Even better !!! It's near the 1-file-per-millisecond limit :-))
This of course adding the file data (1byte), file descriptor and =
filename.
Future issues are:
- more comments and cleaner code
- improve the error handling (currently it's poor)
- make it a library instead of a class (ouch... I can't do this for =
now since I don't have the BCB)
- writing a test utility (the one I used is not serious)
- writing a command-line utility (really needed?)
- writing the PAQ Explorer. I never worked with GUI so I may not be =
the right person doing it
I suggest to do not put this code in the CVS yet, it's better to wait =
until at least the error handling has become serious.
I updated the task in sourceforge, incremented % complete to 70%
In the attached code I included the test utility... just for who is =
curious. Anyway that is really a mess, so be careful to don't gain a =
head ach reading it !!
Critics and comments are *ALWAYS* wellcome.
regards
exio82=20
-------------------------------------------------------------------------=
-----
|