[Mono-dev] Could String constructors be redirected to managed methods?

Kornél Pál kornelpal at gmail.com
Mon Jul 10 20:40:44 EDT 2006


I know that the string is allocated by the constructor

----- Original Message ----- 
From: "Zoltan Varga" <vargaz at gmail.com>
To: "Kornél Pál" <kornelpal at gmail.com>
Cc: <mono-devel-list at lists.ximian.com>
Sent: Monday, July 10, 2006 6:42 PM
Subject: Re: [Mono-dev] Could String constructors be redirected to managed 
methods?


                                 Hi,

  String ctors are handled specially by the runtime, since the size of
the string
which needs to be allocated is dictated by the parameters of the ctor, so we
can't do the usual 'allocate an object, then call its ctor' stuff, the
unmanaged ctor
has to allocate the string object. This is why these ctors are implemented 
in
unmanaged code.

              Zoltan

On 7/10/06, Kornél Pál <kornelpal at gmail.com> wrote:
> Hi,
>
> The following methods are currently implemented using unmanaged code:
> unsafe public extern String (sbyte *value);
> unsafe public extern String (sbyte *value, int startIndex, int length);
> unsafe public extern String (sbyte *value, int startIndex, int length,
> Encoding enc);
>
> They all should use Encoding classes (overloads without encoding 
> parameters
> should use Encoding.Default). I think they could be implemented more 
> easily
> and probably much faster using managed code.
>
> I attached a patch draft that contains CreateString methods that should be
> called instead of unmanaged code to show an example why this could be 
> easier
> and faster.
>
> Is it possible to redirect these constructors to CreateString methods
> instead of unmanaged functions? If possible how could this be implemented?
>
> Thanks for your help.
>
> Kornél
>
>
> _______________________________________________
> 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