[gjs] 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] jsapi-util-string: Clean up gjs_string_from_utf8() to use early return
- Date: Fri, 2 Jul 2021 04:25:25 +0000 (UTC)
commit 2bf42756288173310c261488c70d2383619665f3
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]