projects
/
platform
/
upstream
/
perl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
bb88be5
)
utf8.h: Save a branch in a macro
author
Karl Williamson
<public@khwilliamson.com>
Sun, 2 Sep 2012 19:09:48 +0000
(13:09 -0600)
committer
Karl Williamson
<public@khwilliamson.com>
Fri, 14 Sep 2012 03:14:01 +0000
(21:14 -0600)
By adding a mask, we can save a branch. The two expressions match the
exact same code points.
utf8.h
patch
|
blob
|
history
diff --git
a/utf8.h
b/utf8.h
index
2de54a7
..
e312d87
100644
(file)
--- a/
utf8.h
+++ b/
utf8.h
@@
-164,7
+164,7
@@
Perl's extended UTF-8 means we can have start bytes up to FF.
#define UNI_IS_INVARIANT(c) (((UV)c) < 0x80)
#define UTF8_IS_START(c) (((U8)c) >= 0xc2)
-#define UTF8_IS_CONTINUATION(c) (((
U8)c) >= 0x80 && (((U8)c) <= 0xbf)
)
+#define UTF8_IS_CONTINUATION(c) (((
(U8)c) & 0xC0) == 0x80
)
#define UTF8_IS_CONTINUED(c) (((U8)c) & 0x80)
/* Masking with 0xfe allows low bit to be 0 or 1; thus this matches 0xc[23] */