Replace hangul hack with widecharwidth version

This updates widecharwidth to
6d3d55b419db93934517cb568d1a3d95909b4c7b, which includes the same
Hangul Jamo check in a separate table.

This should slightly speed up most width calculation because we no
longer need to do it for most chars, including the overwhelmingly
common ascii ones.

Also the range is increased and should better match reality.
This commit is contained in:
Fabian Homborg
2022-01-21 17:10:52 +01:00
parent 372f03ba20
commit f40c054a6a
2 changed files with 9 additions and 7 deletions

View File

@@ -243,12 +243,6 @@ int fish_wcwidth(wchar_t wc) {
else if (wc == variation_selector_15)
return 0;
// Korean Hangul Jamo median vowels and final consonants.
// These can either appear in combined form, taking 0 width themselves,
// or standalone with a 1 width. Since that's literally not expressible with wcwidth(),
// we take the position that the typical way for them to show up is composed.
if (wc >= L'\u1160' && wc <= L'\u11FF') return 0;
// Check for Emoji_Modifier property. Only the Fitzpatrick modifiers have this, in range
// 1F3FB..1F3FF. This is a hack because such an emoji appearing on its own would be drawn as
// width 2, but that's unlikely to be useful. See #8275.

View File

@@ -1,5 +1,5 @@
/**
* widechar_width.h, generated on 2021-10-26.
* widechar_width.h, generated on 2022-01-01.
* See https://github.com/ridiculousfish/widecharwidth/
*
* SHA1 file hashes:
@@ -378,6 +378,12 @@ static const struct widechar_range widechar_combining_table[] = {
{0xE0100, 0xE01EF}
};
/* Width 0 combining letters. */
static const struct widechar_range widechar_combiningletters_table[] = {
{0x01160, 0x011FF},
{0x0D7B0, 0x0D7FF}
};
/* Width 2 characters. */
static const struct widechar_range widechar_doublewide_table[] = {
{0x01100, 0x0115F},
@@ -1463,6 +1469,8 @@ int widechar_wcwidth(uint32_t c) {
return widechar_non_character;
if (widechar_in_table(widechar_combining_table, c))
return widechar_combining;
if (widechar_in_table(widechar_combiningletters_table, c))
return widechar_combining;
if (widechar_in_table(widechar_doublewide_table, c))
return 2;
if (widechar_in_table(widechar_ambiguous_table, c))