Skip to content

Commit

Permalink
refactor: slightly faster queue adaptation
Browse files Browse the repository at this point in the history
Refactor and optimize queue adaptation in refinement step (likely negligible impact on performance).

### Before

```asm
        lea               eax, [rdx + 2*rdx]
        cmp               eax, ecx
        sete              r8b
        lea               eax, [rdx + 2*rdx + 1]
        cmp               eax, ecx
        sete              al
        lea               edx, [rdx + 2*rdx + 2]
        cmp               edx, ecx
        sete              cl
        or                cl, al
        or                cl, r8b
        movzx             eax, cl
```

### After

```asm
        movsxd            rax, ecx
        imul              rcx, rax, 1431655766
        mov               rax, rcx
        shr               rax, 63
        shr               rcx, 32
        add               ecx, eax
        xor               eax, eax
        cmp               ecx, edx
        sete              al
```
  • Loading branch information
andywiecko committed Nov 14, 2024
1 parent 0fea9d0 commit 4f68f7e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Runtime/Triangulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3531,7 +3531,7 @@ private void AdaptQueues(NativeList<int> heQueue, NativeList<int> tQueue)
for (int i = 0; i < heQueue.Length; i++)
{
var he = heQueue[i];
if (he == 3 * tId + 0 || he == 3 * tId + 1 || he == 3 * tId + 2)
if (he / 3 == tId)
{
heQueue[i] = -1;
continue;
Expand Down

0 comments on commit 4f68f7e

Please sign in to comment.