Skip to content

Commit d39b8fc

Browse files
committed
Bring back some performance, on VteBench, we get 58% throughput boost and on the
raw feeding test we get 20%, unclear to me why the same data on different tests produces such wild results, but I will take it.
1 parent 13ba575 commit d39b8fc

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

Sources/SwiftTerm/Utilities.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ struct UnicodeUtil {
312312

313313
/**
314314
* Number of column positions of a wide-character code. This is used to measure runes as displayed by text-based terminals.
315-
* - Returns: The width in columns, 0 if the argument is the null character, -1 if the value is not printable, otherwise the number of columsn that the rune occupies.
315+
* - Returns: The width in columns, 0 if the argument is the null character,
316+
* -1 if the value is not printable, otherwise the number of columsn that the rune occupies.
316317
* - Parameter rune: a UnicodeScalar
317318
*/
318319
static func columnWidth (rune: UnicodeScalar) -> Int
@@ -322,7 +323,16 @@ struct UnicodeUtil {
322323
if irune == 0 {
323324
return 0
324325
}
325-
if irune < 0x20 || (irune >= 0x7F && irune <= 0xA0) {
326+
// control characeters return -1
327+
if irune < 0x20 {
328+
return -1
329+
}
330+
// ascii letters use one column
331+
if irune < 0x7f {
332+
return 1
333+
}
334+
// more non-printable characters
335+
if irune <= 0xA0 {
326336
return -1
327337
}
328338

0 commit comments

Comments
 (0)