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

Kornél Pál kornelpal at hotmail.com
Thu Mar 16 18:37:19 EST 2006


Hi,

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

You are right there are already count tests so some more doesn't count.:)

>...
> Why is it not a part of string.memcpy ?

memcpy copies memory. But UnicodeEncoding has support for little and big
endian encodings as well. If the endian used by the encoder differs from the
machine endian bytes has to be swapped. There allways has to be two
different code for little and big endian encoding. Previously shift
operators were used but using memcpy and byte access using unsafe code seems
to be faster.

Kornél

----- Original Message -----
From: "Marek Safar" <marek.safar at seznam.cz>
To: "Kornél Pál" <kornelpal at hotmail.com>
Cc: "Atsushi Eno" <atsushi at ximian.com>; <mono-devel-list at lists.ximian.com>
Sent: Friday, March 17, 2006 12:28 AM
Subject: Re: [Mono-dev] [PATCH] Boost speed of UnicodeEncoding


> 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
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>




More information about the Mono-devel-list mailing list