<p style="padding:0 0 0 0; margin:0 0 0 0;">Sorry, it was copy-paste from github and it broke formatting</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">do {</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> v1 = XXH32_round(v1, XXH_get32bits(input)); input += 4;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> v2 = XXH32_round(v2, XXH_get32bits(input)); input += 4;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> v3 = XXH32_round(v3, XXH_get32bits(input)); input += 4;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> v4 = XXH32_round(v4, XXH_get32bits(input)); input += 4;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> } while (input < limit);</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> repeat</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> v1 := cPrime32x1 * RolDWord(v1 + cPrime32x2 * PLongWord(ABuffer)^, 13);</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> v2 := cPrime32x1 * RolDWord(v2 + cPrime32x2 * PLongWord(ABuffer+4)^, 13);</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> v3 := cPrime32x1 * RolDWord(v3 + cPrime32x2 * PLongWord(ABuffer+8)^, 13);</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> v4 := cPrime32x1 * RolDWord(v4 + cPrime32x2 * PLongWord(ABuffer+12)^, 13);</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> inc(ABuffer, 16);</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">until not (ABuffer <= pLimit); </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">______________________________________________________________<br />
> Od: "James Richters via fpc-pascal" <fpc-pascal@lists.freepascal.org><br />
> Komu: "'FPC-Pascal users discussions'" <fpc-pascal@lists.freepascal.org><br />
> Datum: 09.11.2022 13:47<br />
> Předmět: [fpc-pascal] Program efficiency<br />
></p>
I was wondering if breaking up large complicated formulas into smaller<br />
sections that use more variables is less efficient than just the large<br />
formula.<br />
<br />
In other words.. is<br />
<br />
A:=(B+C/D)-E^F;<br />
G:=H*(I+J);<br />
K:=L+M/N;<br />
O:= A+G-K;<br />
<br />
Less efficient than<br />
O:= ((B+C/D)-E^F)+ (H*(I+J))-(L+M/N);<br />
<br />
Or does it end up being the same when it's done?<br />
<br />
I have a tendency to avoid using variables even though the code would be<br />
infinitely more understandable if it was broken into sections and more<br />
variables were used, but I'm wondering if this is really any more efficient<br />
or if it just seems like it should be... after all storing things in a<br />
variable and reading them out should take some time... but then again the<br />
processor only works on one operation at a time anyway, so the final<br />
assembly code would probably have to store things somewhere and get them<br />
back... so.. is it really faster?<br />
<br />
So if I never need the value a second time, is it really better to avoid<br />
variables?<br />
<br />
I could break it up an use comments:<br />
O:= ((B+C/D)-E^F)+ //A<br />
(H*(I+J))- //G<br />
(L+M/N); //K<br />
<br />
This got me thinking, it would be cool if there was some king of utility<br />
that counted clock cycles for you while your program ran..and then I could<br />
just try a sample program both ways and see what the results are...<br />
<br />
James<br />
<br />
_______________________________________________<br />
fpc-pascal maillist - fpc-pascal@lists.freepascal.org<br />
<a href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br />