Skip to content

Commit

Permalink
isspace: reduce need for category_code call, and inline
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyrne committed May 28, 2015
1 parent bb848b8 commit f04f10d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions base/utf8proc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ iscntrl(c::Char) = (c <= Char(0x1f) || Char(0x7f) <= c <= Char(0x9f))

ispunct(c::Char) = (UTF8PROC_CATEGORY_PC <= category_code(c) <= UTF8PROC_CATEGORY_PO)

# 0x85 is the Unicode Next Line (NEL) character
isspace(c::Char) = c == ' ' || '\t' <= c <='\r' || c == Char(0x85) || category_code(c)==UTF8PROC_CATEGORY_ZS
# \u85 is the Unicode Next Line (NEL) character
# the check for \ufffd allows for branch removal on ASCIIStrings
@inline isspace(c::Char) = c == ' ' || '\t' <= c <='\r' || c == '\u85' || '\ua0' <= c && c != '\ufffd' && category_code(c)==UTF8PROC_CATEGORY_ZS

isprint(c::Char) = (UTF8PROC_CATEGORY_LU <= category_code(c) <= UTF8PROC_CATEGORY_ZS)

Expand Down

0 comments on commit f04f10d

Please sign in to comment.