From 8f46527a0cec65964cf9fcf178e181a59846e0ed Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sat, 14 Mar 2020 16:37:40 +0200 Subject: [PATCH 1/2] fix type conversions for isFinalSigma --- std/assembly/util/string.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/std/assembly/util/string.ts b/std/assembly/util/string.ts index 6eed06e09f..b27960d748 100644 --- a/std/assembly/util/string.ts +++ b/std/assembly/util/string.ts @@ -551,13 +551,13 @@ export function isCaseIgnorable(c: u32): bool { // @ts-ignore: decorator @inline -export function isFinalSigma(buffer: usize, index: i32, len: i32): bool { +export function isFinalSigma(buffer: usize, index: isize, len: isize): bool { const lookaheadLimit = 30; // max lookahead limit var found = false; var pos = index; var minPos = max(0, pos - lookaheadLimit); while (pos > minPos) { - let c = codePointBefore(buffer, pos); + let c = codePointBefore(buffer, pos); if (!isCaseIgnorable(c)) { if (isCased(c)) { found = true; @@ -565,7 +565,7 @@ export function isFinalSigma(buffer: usize, index: i32, len: i32): bool { return false; } } - pos -= i32(c >= 0x10000) + 1; + pos -= isize(c >= 0x10000) + 1; } if (!found) return false; pos = index + 1; @@ -581,7 +581,7 @@ export function isFinalSigma(buffer: usize, index: i32, len: i32): bool { if (!isCaseIgnorable(c)) { return !isCased(c); } - pos += i32(c >= 0x10000) + 1; + pos += isize(c >= 0x10000) + 1; } return true; } From ee3bcf5d46ea714a2df055aa7bd47633de63f35e Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sat, 14 Mar 2020 16:46:27 +0200 Subject: [PATCH 2/2] more refactorings --- std/assembly/util/string.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/std/assembly/util/string.ts b/std/assembly/util/string.ts index b27960d748..0ae05927dc 100644 --- a/std/assembly/util/string.ts +++ b/std/assembly/util/string.ts @@ -557,7 +557,7 @@ export function isFinalSigma(buffer: usize, index: isize, len: isize): bool { var pos = index; var minPos = max(0, pos - lookaheadLimit); while (pos > minPos) { - let c = codePointBefore(buffer, pos); + let c = codePointBefore(buffer, pos); if (!isCaseIgnorable(c)) { if (isCased(c)) { found = true; @@ -571,9 +571,9 @@ export function isFinalSigma(buffer: usize, index: isize, len: isize): bool { pos = index + 1; var maxPos = min(pos + lookaheadLimit, len); while (pos < maxPos) { - let c = load(buffer + (pos << 1)); + let c = load(buffer + (pos << 1)); if (u32((c & 0xFC00) == 0xD800) & u32(pos + 1 != len)) { - let c1 = load(buffer + (pos << 1), 2); + let c1 = load(buffer + (pos << 1), 2); if ((c1 & 0xFC00) == 0xDC00) { c = (c - 0xD800 << 10) + (c1 - 0xDC00) + 0x10000; } @@ -588,11 +588,11 @@ export function isFinalSigma(buffer: usize, index: isize, len: isize): bool { // @ts-ignore: decorator @inline -function codePointBefore(buffer: usize, index: i32): i32 { +function codePointBefore(buffer: usize, index: isize): i32 { if (index <= 0) return -1; - var c = load(buffer + (index - 1 << 1)); + var c = load(buffer + (index - 1 << 1)); if (u32((c & 0xFC00) == 0xDC00) & u32(index - 2 >= 0)) { - let c1 = load(buffer + (index - 2 << 1)); + let c1 = load(buffer + (index - 2 << 1)); if ((c1 & 0xFC00) == 0xD800) { return ((c1 & 0x3FF) << 10) + (c & 0x3FF) + 0x10000; }