Faster check for ascii-space
Since ' ' is by far one of the most common characters, it is worthwhile to put it first, and short-circuit the rest of the function. On the same JSON benchmark, as the json_perf improvement, reading example.json 10 times from https://code.google.com/p/rapidjson/wiki/Performance. Before: 0.16s After: 0.11s
This commit is contained in:
parent
58eb70a5e2
commit
52949fbf18
1 changed files with 2 additions and 1 deletions
|
|
@ -82,7 +82,8 @@ pub fn is_uppercase(c: char) -> bool { general_category::Lu(c) }
|
|||
///
|
||||
#[inline]
|
||||
pub fn is_whitespace(c: char) -> bool {
|
||||
('\x09' <= c && c <= '\x0d')
|
||||
c == ' '
|
||||
|| ('\x09' <= c && c <= '\x0d')
|
||||
|| general_category::Zs(c)
|
||||
|| general_category::Zl(c)
|
||||
|| general_category::Zp(c)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue