 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Estx Expert Cheater
Reputation: 0
Joined: 04 Mar 2008 Posts: 172
|
Posted: Wed Jun 18, 2008 11:48 pm Post subject: |
|
|
samurai: Your code is slightly better, I've hardly had to use a generic list because I've always predetermined the size of my array (there-for rarely used Array.Resize()). Doesn't really matter that you missed out using decimals because I suppose you don't need pin-point precision for the example lol.
Did some performance tests though, no speed difference for 500 grades.
My example speed (ticks): 156250
Your example speed (ticks): 156250
Although the performance hit wont come in until much higher variables are stored, it becomes just coding preference and efficiency again. Even though I would say Lists are preferable compared to resizing arrays.
Lol anyway! From my point of view, both samuri25404 and HalfPrime have the same conclusion but aren't understanding each other. You're both right >.>
As for the topic starter, your answer is on the first page. Either of the last two posts. Although if you keep on reading you might learn a thing or two anyway. ;D
|
|
| Back to top |
|
 |
DoomsDay Grandmaster Cheater
Reputation: 0
Joined: 06 Jan 2007 Posts: 768 Location: %HomePath%
|
Posted: Thu Jun 19, 2008 7:55 am Post subject: |
|
|
Clarification:
A while loop is a modification of the do-while loop, which simply jumps to the check first. In this case, a while loop is is not a greate solution, nor is the do-while - the most efficient would be a couple of goto statements:
The do-while flow looks like this: | Code: | loopLabel:
<code>
if (<condition>) goto loopLabel |
The while flow looks like this: | Code: | goto compareLabel
loopLabel:
<code>
compareLabel:
if (<condition>) goto loopLabel |
samuri25404's while loop looks like this: | Code: | goto preCompareCodeLabel
loopLabel:
<code>
preCompareCodeLabel:
<get the input>
if (<condition>) goto loopLabel |
But in this case, the code we want to produce should look like this: | Code: | loopLabel:
<get the input>
if (<input> == <stop>) goto outOfLoopLabel
<processing code>
goto loopLabel
outOfLoopLabel: |
The actual difference, actually,is the fact that in samuri25404's code there are 2 unnececery goto's at it's flow's begining, which if removed, would look like my code(the one presented in C#).
EDIT:
a do{if (!<condition>){break;}}while(0); could also work, depends on the compiler.
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Thu Jun 19, 2008 3:43 pm Post subject: |
|
|
Both of the things that you posted are considered bad practice in the programming world (or at least, the C#/.NET world).
I posted an ideal, common solution.
_________________
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|