Skip to content

Commit

Permalink
builtin: minor optimization in rune.map_to() (vlang#22810)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 authored Nov 9, 2024
1 parent e6c5b1b commit b7ffa8f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions vlib/builtin/rune.v
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ fn (c rune) map_to(mode MapMode) rune {
unsafe { *(cur_map + 3) }
}
if offset == rune_maps_ul {
is_odd := (c - unsafe { *cur_map }) % 2 == 1
if mode in [.to_upper, .to_title] && is_odd {
return c - 1
} else if mode == .to_lower && !is_odd {
return c + 1
// upper, lower, upper, lower, ... sequence
cnt := (c - unsafe { *cur_map }) % 2
if mode == .to_lower {
return c + 1 - cnt
}
return c
return c - cnt
} else if offset == rune_maps_utl {
// upper, title, lower, upper, title, lower, ... sequence
cnt := (c - unsafe { *cur_map }) % 3
if mode == .to_upper {
return c - cnt
Expand Down

0 comments on commit b7ffa8f

Please sign in to comment.