Hmm does anyone know what effect this would have at machine code level? The only reason at the moment that i continue to not streamline my code is for readability sort of.
Printable View
Hmm does anyone know what effect this would have at machine code level? The only reason at the moment that i continue to not streamline my code is for readability sort of.
Define 'streamline'.
Here is an example...
streamlined...Code:If sInfo.nPos >= sInfo.nMax - sInfo.nPage Then
DetectScrollLoc = True
Else
DetectScrollLoc = False
End If
Edit:Code:DetectScrollLoc = (sInfo.nPos >= sInfo.nMax - sInfo.nPage)
Above quote is from wikipedia. I am just uncertain if it is a good method. Apparently some schools do not agree with doing such stuff.Quote:
Computational tasks are often performed in several manners with varying efficiency. For example, consider the following C code snippet to sum all integers from 1 to N:
This code can (assuming no overflow) be rewritten using a mathematical formula like:Quote:
int i, sum = 0;
for (i = 1; i <= N; i++)
sum += i;
printf ("sum: %d\n", sum);
The optimization, often done automatically, is therefore to pick a method that is more computationally efficient while retaining the same functionality. However, a significant improvement in performance can often be achieved by solving only the actual problem and removing extraneous functionality.Code:int sum = (N * (N+1)) / 2;
printf ("sum: %d\n", sum);
Optimization is not always an obvious or intuitive process. In the example above, the ‘optimized’ version might actually be slower than the original software if N were sufficiently small and the computer were much faster at performing addition and looping operations than multiplications and divisions.
The first is a comparison, branch and store. The second is a comparison and store. The second will therefore be quicker as branches are a major slowdown.
I don't know about VB but a good compiler might optimise that difference out.
Sorry *bump* may have just missed the edit above.