[gjs/ewlsh/text-encoding: 21/24] jsapi-util-string: Clean up gjs_string_from_utf8() to use early return
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/ewlsh/text-encoding: 21/24] jsapi-util-string: Clean up gjs_string_from_utf8() to use early return
- Date: Mon, 14 Jun 2021 05:07:44 +0000 (UTC)
commit 219c9b7f8665cb504dea0d7361820b7de72414de
Author: Evan Welsh <contact evanwelsh com>
Date: Sun Jun 13 18:11:55 2021 -0700
jsapi-util-string: Clean up gjs_string_from_utf8() to use early return
gjs/jsapi-util-string.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/gjs/jsapi-util-string.cpp b/gjs/jsapi-util-string.cpp
index b2ea9f3d..e5de20c2 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -99,10 +99,11 @@ gjs_string_from_utf8(JSContext *context,
{
JS::ConstUTF8CharsZ chars(utf8_string, strlen(utf8_string));
JS::RootedString str(context, JS_NewStringCopyUTF8Z(context, chars));
- if (str)
- value_p.setString(str);
+ if (!str)
+ return false;
- return str != nullptr;
+ value_p.setString(str);
+ return true;
}
bool
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]