GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: improve GetColumnWidth performance · nodejs/node@d2a10ad

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_i18n.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_i18n.cc‎

Copy file name to clipboardExpand all lines: src/node_i18n.cc
+9-10Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -728,16 +728,6 @@ static void ToASCII(const FunctionCallbackInfo<Value>& args) {
728728
// Refs: https://github.com/KDE/konsole/blob/8c6a5d13c0/src/konsole_wcwidth.cpp#L101-L223
729729
static int GetColumnWidth(UChar32 codepoint,
730730
bool ambiguous_as_full_width = false) {
731-
const auto zero_width_mask = U_GC_CC_MASK | // C0/C1 control code
732-
U_GC_CF_MASK | // Format control character
733-
U_GC_ME_MASK | // Enclosing mark
734-
U_GC_MN_MASK; // Nonspacing mark
735-
if (codepoint != 0x00AD && // SOFT HYPHEN is Cf but not zero-width
736-
((U_MASK(u_charType(codepoint)) & zero_width_mask) ||
737-
u_hasBinaryProperty(codepoint, UCHAR_EMOJI_MODIFIER))) {
738-
return 0;
739-
}
740-
741731
// UCHAR_EAST_ASIAN_WIDTH is the Unicode property that identifies a
742732
// codepoint as being full width, wide, ambiguous, neutral, narrow,
743733
// or halfwidth.
@@ -761,6 +751,15 @@ static int GetColumnWidth(UChar32 codepoint,
761751
case U_EA_HALFWIDTH:
762752
case U_EA_NARROW:
763753
default:
754+
const auto zero_width_mask = U_GC_CC_MASK | // C0/C1 control code
755+
U_GC_CF_MASK | // Format control character
756+
U_GC_ME_MASK | // Enclosing mark
757+
U_GC_MN_MASK; // Nonspacing mark
758+
if (codepoint != 0x00AD && // SOFT HYPHEN is Cf but not zero-width
759+
((U_MASK(u_charType(codepoint)) & zero_width_mask) ||
760+
u_hasBinaryProperty(codepoint, UCHAR_EMOJI_MODIFIER))) {
761+
return 0;
762+
}
764763
return 1;
765764
}
766765
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.