[Mono-devel-list] Char.IsXXX() patch: from InternalCall to managed

Ben Maurer 05mauben at hawken.edu
Wed Feb 18 08:02:55 EST 2004


Hey Atsushi,

Very good catch. Actually, this has alot of impact because in the
future, this method might be able to be inlined.

For IsWhitespace, I would rather see all the switch elements enumerated
out. This is going to be faster than calling the other method, even if
it will get inlined (as I understand it, that is the design of the
Switch statement).

Also, rather than the magic characters, can you please use constants and
a quick comment describing what they are:

// This character is the `foo' character. it is a whitespace character
const char seperator_foo = '\u2029';

Here:
+    int i = (int) c;
+    return i >= 0x2000 && i <= 0x200b

you should be able to do:

return c >= '\u2000' && c <= '\u200b';

-- Ben

>>> Atsushi Eno <atsushi at ximian.com> 02/18/04 01:19 AM >>>
Hello,

I found that existing Char.IsWhitespace() and Char.IsSeparator() are
slower than MS.NET. I found that they are InternalCall, so I tried to
implement them in Char.cs natively and the got 2x speed. So I think
it would be better if we move these (and the same kind of) methods
into managed world.

BTW, Char.IsWhiteSpace() and g_unichar_isspace() are different in
some characters such as vertical space ('\v').

If it does not matter, I'll commit the patch later.

Thanks,
Atsushi Eno





More information about the Mono-devel-list mailing list