T
Thomas T. Veldhouse
Willy Denoyette said:| >> > The calls to substring IMO are going to be a little more costly.
| >>
| >> StringBuilder is probably not internally implemented in C#, but rather
in
| >> native code; thus, the allocating of memory and copying bytes will be
| >> optimized as opposed to doing it with substrings in C#. Most C/C++
develops
| >> likely understand this implicitly.
| >
| > Very, very little of StringBuilder is implemented directly in native
| > code, as far as I can tell with Reflector.
| >
|
| Reflector as in "reflection". As far as I am concerned, it would only
have a
| use in StringBuilder.AppendFormat(...). Otherwise, I expect calls like
| memcpy, wstrcpy, etc (or equivalents that work with BSTR). My point is
that
| such manipulation is FAR faster in native code with direct memory access,
so
| implementation in this manner makes sense.
|
| --
| Thomas T. Veldhouse
| Key Fingerprint: 2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1
|
|
No, V2 FCL StringBuilder is almost completely implemented in C# using unsafe
code constructs for performance critical path's. It doesn't even rely upon
the CRT. All there is is a couple of internal calls (the runtime), for
instance to allocate the initial string.
But all this is moot as mscorlib is native code (ngen'd) anyway.
Bingo. If you have access, care to share the code? If there are calls into
mscorlib, I think we are very likely agreeing.