<p style="padding:0 0 0 0; margin:0 0 0 0;">Hi,</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;">I noticed this too a few years ago when I translated xxHash from C to FPC.</p>

<p style="padding:0 0 0 0; margin:0 0 0 0;">Pushing the code to less lines improved speed so xxHash32 was as fast as in C.</p>

<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>

<table class="highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file" style="box-sizing: border-box; border-spacing: 0px; border-collapse: collapse; tab-size: 8; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'; font-size: 14px;" data-hpc="" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="C" data-tagsearch-path="xxhash.h">
<tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box; background-color: transparent;">
<td id="LC2370" class="blob-code blob-code-inner js-file-line" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; font-size: 12px; color: var(--color-fg-default); white-space: pre;"><span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">do</span> {</td>
</tr>
<tr style="box-sizing: border-box;">
<td id="L2371" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" style="box-sizing: border-box; padding: 0px 10px; position: relative; width: 50px; min-width: 50px; font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; font-size: 12px; line-height: 20px; color: var(--color-fg-subtle); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; user-select: none;" data-line-number="2371"> </td>
<td id="LC2371" class="blob-code blob-code-inner js-file-line" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; font-size: 12px; color: var(--color-fg-default); white-space: pre;">v1 = <span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">XXH32_round</span>(v1, <span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">XXH_get32bits</span>(input)); input += <span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">4</span>;</td>
</tr>
<tr style="box-sizing: border-box; background-color: transparent;">
<td id="L2372" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" style="box-sizing: border-box; padding: 0px 10px; position: relative; width: 50px; min-width: 50px; font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; font-size: 12px; line-height: 20px; color: var(--color-fg-subtle); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; user-select: none;" data-line-number="2372"> </td>
<td id="LC2372" class="blob-code blob-code-inner js-file-line" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; font-size: 12px; color: var(--color-fg-default); white-space: pre;">v2 = <span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">XXH32_round</span>(v2, <span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">XXH_get32bits</span>(input)); input += <span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">4</span>;</td>
</tr>
<tr style="box-sizing: border-box;">
<td id="L2373" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" style="box-sizing: border-box; padding: 0px 10px; position: relative; width: 50px; min-width: 50px; font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; font-size: 12px; line-height: 20px; color: var(--color-fg-subtle); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; user-select: none;" data-line-number="2373"> </td>
<td id="LC2373" class="blob-code blob-code-inner js-file-line" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; font-size: 12px; color: var(--color-fg-default); white-space: pre;">v3 = <span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">XXH32_round</span>(v3, <span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">XXH_get32bits</span>(input)); input += <span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">4</span>;</td>
</tr>
<tr style="box-sizing: border-box; background-color: transparent;">
<td id="L2374" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" style="box-sizing: border-box; padding: 0px 10px; position: relative; width: 50px; min-width: 50px; font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; font-size: 12px; line-height: 20px; color: var(--color-fg-subtle); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; user-select: none;" data-line-number="2374"> </td>
<td id="LC2374" class="blob-code blob-code-inner js-file-line" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; font-size: 12px; color: var(--color-fg-default); white-space: pre;">v4 = <span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">XXH32_round</span>(v4, <span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">XXH_get32bits</span>(input)); input += <span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">4</span>;</td>
</tr>
<tr style="box-sizing: border-box;">
<td id="L2375" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" style="box-sizing: border-box; padding: 0px 10px; position: relative; width: 50px; min-width: 50px; font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; font-size: 12px; line-height: 20px; color: var(--color-fg-subtle); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; user-select: none;" data-line-number="2375"> </td>
<td id="LC2375" class="blob-code blob-code-inner js-file-line" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; font-size: 12px; color: var(--color-fg-default); white-space: pre;">
<p style="padding:0 0 0 0; margin:0 0 0 0;">} <span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">while</span> (input < limit);</p>

<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>

</td>
</tr>
</tbody>
</table>
<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 />
<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 />