Skip to content

Commit b08ab44

Browse files
committed
some tuning
1 parent 9fd2b33 commit b08ab44

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/UTF8.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,14 +1390,26 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
13901390
int localasciirun = 16;
13911391
if (processedLength + localasciirun + 64 <= inputLength)
13921392
{
1393-
for (; processedLength + localasciirun + 16 <= inputLength; localasciirun += 16)
1393+
Vector128<byte> block = AdvSimd.LoadVector128(pInputBuffer + processedLength + localasciirun);
1394+
if (AdvSimd.Arm64.MaxAcross(Vector128.AsUInt32(AdvSimd.And(block, v80))).ToScalar() == 0)
13941395
{
1395-
Vector128<byte> block = AdvSimd.LoadVector128(pInputBuffer + processedLength + localasciirun);
1396-
if (AdvSimd.Arm64.MaxAcross(Vector128.AsUInt32(AdvSimd.And(block, v80))).ToScalar() != 0)
1396+
localasciirun += 16;
1397+
for (; processedLength + localasciirun + 64 <= inputLength; localasciirun += 64)
13971398
{
1398-
break;
1399+
Vector128<byte> block1 = AdvSimd.LoadVector128(pInputBuffer + processedLength + localasciirun);
1400+
Vector128<byte> block2 = AdvSimd.LoadVector128(pInputBuffer + processedLength + localasciirun + 16);
1401+
Vector128<byte> block3 = AdvSimd.LoadVector128(pInputBuffer + processedLength + localasciirun + 32);
1402+
Vector128<byte> block4 = AdvSimd.LoadVector128(pInputBuffer + processedLength + localasciirun + 48);
1403+
Vector128<byte> or = AdvSimd.Or(AdvSimd.Or(block1, block2), AdvSimd.Or(block3, block4));
1404+
1405+
if (AdvSimd.Arm64.MaxAcross(Vector128.AsUInt32(AdvSimd.And(or, v80))).ToScalar() != 0)
1406+
{
1407+
break;
1408+
}
13991409
}
1410+
14001411
}
1412+
14011413
processedLength += localasciirun - 16;
14021414
}
14031415
}

0 commit comments

Comments
 (0)