3、到:1.public static bool IsWhiteSpace(char c) { 2. if (IsLatin1(c)) { 3. return (IsWhiteSpaceLatin1(c)); 4. } 5. return CharUnicodeInfo.IsWhiteSpace(c); 6.} 7. 8.然后CharUnicodeInfo.IsWhiteSpace成了: 9. 10.internal static bool IsWhiteSpace(char c) 11.{ 12. UnicodeCategory
4、uc = GetUnicodeCategory(c); 13. // In Unicode 3.0, U+2028 is the only character which is under the category "LineSeparator". 14. // And U+2029 is th eonly character which is under the category "ParagraphSeparator". 15. switch (uc) { 16. case (UnicodeCategory.SpaceSepara
5、tor): 17. case (UnicodeCategory.LineSeparator): 18. case (UnicodeCategory.ParagraphSeparator): 19. return (true); 20. } 21. 22. return (false); 23.} GetUnicodeCategory()方法调用InternalGetUnicodeCategory()方法,而且实际上相当快,但现在我们依次已经有了4个方法调用!以下这段代码是由一位评论者提供的,可用于快速实现
6、定制版本和JIT默认内联:1.// whitespace detection method: very fast, a lot faster than Char.IsWhiteSpace 2.[MethodImpl(MethodImplOptions.AggressiveInlining)] // if it's not inlined then it will be slow!!! 3.public static bool isWhiteSpace(char ch) { 4. // this is surprisingly faster than the e
7、quivalent if statement 5. switch (ch) { 6. case 'u0009': case 'u000A': case 'u000B': case 'u000C': case 'u000D': 7/7文档1. case 'u0020': case 'u0085': case 'u00A0': case 'u1680': case 'u2000': 2. case 'u2001': case 'u2002': case 'u2003': case 'u200