From f72f2ae60a3e395517847fc5dbc70bcc062f82df Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sat, 18 Jun 2022 22:00:49 +0200 Subject: [PATCH] [smjs] minor optimisation: one strlen less --- src/scripting/smjs/cache_object.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/scripting/smjs/cache_object.c b/src/scripting/smjs/cache_object.c index f23883c75..e62f6e0e1 100644 --- a/src/scripting/smjs/cache_object.c +++ b/src/scripting/smjs/cache_object.c @@ -113,12 +113,9 @@ jsval_to_Latin1(JSContext *ctx, JS::HandleValue hvp, size_t *length) /* Memory must be freed in caller */ JSString *st = JS::ToString(ctx, hvp); JS::UniqueChars chars = JS_EncodeStringToLatin1(ctx, st); + *length = JS_GetStringLength(st); - if (length) { - *length = JS_GetStringLength(st); - } - - return null_or_stracpy(chars.get()); + return memacpy(chars.get(), *length); } static bool