stdlib: cleanup in Char.ml by using char range patterns (#9221)

stdlib/char.ml: [minor] use range patterns for {lowercase,uppercase} functions
master
hhugo 2020-01-04 22:15:52 +08:00 committed by Gabriel Scherer
parent 2fba4c0ce6
commit 475df06021
1 changed files with 18 additions and 20 deletions

View File

@ -46,29 +46,27 @@ let escaped = function
bytes_unsafe_set s 3 (unsafe_chr (48 + n mod 10)); bytes_unsafe_set s 3 (unsafe_chr (48 + n mod 10));
unsafe_to_string s unsafe_to_string s
let lowercase c = let lowercase = function
if (c >= 'A' && c <= 'Z') | 'A' .. 'Z'
|| (c >= '\192' && c <= '\214') | '\192' .. '\214'
|| (c >= '\216' && c <= '\222') | '\216' .. '\222' as c ->
then unsafe_chr(code c + 32) unsafe_chr(code c + 32)
else c | c -> c
let uppercase c = let uppercase = function
if (c >= 'a' && c <= 'z') | 'a' .. 'z'
|| (c >= '\224' && c <= '\246') | '\224' .. '\246'
|| (c >= '\248' && c <= '\254') | '\248' .. '\254' as c ->
then unsafe_chr(code c - 32) unsafe_chr(code c - 32)
else c | c -> c
let lowercase_ascii c = let lowercase_ascii = function
if (c >= 'A' && c <= 'Z') | 'A' .. 'Z' as c -> unsafe_chr(code c + 32)
then unsafe_chr(code c + 32) | c -> c
else c
let uppercase_ascii c = let uppercase_ascii = function
if (c >= 'a' && c <= 'z') | 'a' .. 'z' as c -> unsafe_chr(code c - 32)
then unsafe_chr(code c - 32) | c -> c
else c
type t = char type t = char