[Mono-dev] [PATCH] Boost speed of UnicodeEncoding

Marek Safar marek.safar at seznam.cz
Thu Mar 16 18:28:53 EST 2006


Hello Kornél,
> As you can see converting 1 character became slower. But longer 
> strings are
> much faster converted (4 bytes for example). Just to show how inefficient
> the old code was converting 1024 characters is about 20-30 times 
> faster than
> it was before.
Really nice.

>
> I think converting a single character should not be optimized as doing 
> so is
> already inefficient. It's much faster to use convert it inline using 
> shift
> operators.
But you already do this test here

+        if (byteCount >= 2) 

+        {

just write else section with fast path for 0 and 1 byte count here.

+        else {

+            while (count >= 16) {

+                dest[0] = src[1];

+                dest[1] = src[0];

+                dest[2] = src[3];

Why is it not a part of string.memcpy ?

Marek





More information about the Mono-devel-list mailing list