From f862540c65e3b39baf76448492fc0c7b7fba6b0b Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sat, 18 Mar 2023 12:44:39 -0400 Subject: [PATCH] Account for seamless slices in C roc_str_len --- examples/typescript-interop/node/demo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/typescript-interop/node/demo.c b/examples/typescript-interop/node/demo.c index 73ba90dd09..a70944b96c 100644 --- a/examples/typescript-interop/node/demo.c +++ b/examples/typescript-interop/node/demo.c @@ -186,7 +186,7 @@ size_t roc_str_len(struct RocStr str) uint8_t last_byte = bytes[sizeof(str) - 1]; uint8_t last_byte_xored = last_byte ^ 0b10000000; size_t small_len = (size_t)(last_byte_xored); - size_t big_len = str.len; + size_t big_len = str.len & PTRDIFF_MAX; // Account for seamless slices // Avoid branch misprediction costs by always // determining both small_len and big_len,