[Mono-dev] String.GetHashCode()

Robert Jordan robertj at gmx.net
Sat Dec 1 11:09:00 EST 2007

Tinco Andringa wrote:
> (Woops, only replied to kamil)
> If Jerome is right and the overhead is only 4 bytes, then overhead
> shouldn't be a problem at all. The worst case size of a string would
> be 1 character, of 2 bytes + something to end it with, like an int
> containing its length, 2 bytes, or a terminating character, probably
> 2 bytes too. Making it at least 4 bytes.  A worst case scenario of

Look at a heavy string consumer: [g]mcs. The average string
length it has to process is probably only 4-5 chars long.
That's roundabout 12 bytes. Adding 4 bytes for the hash code
is a huge overhead that only pays out if GetHashCode is
called frequently, but this is definitely not a common scenario
for most of the strings.


More information about the Mono-devel-list mailing list