[gjs] byteArray: Clean up resolve op
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] byteArray: Clean up resolve op
- Date: Tue, 8 Jan 2013 16:49:11 +0000 (UTC)
commit 56b8b716b937ed1bf04e84079a78e10a9b1b776f
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Jan 3 17:29:55 2013 -0500
byteArray: Clean up resolve op
Only set the *objp value after success, leaving it at NULL
otherwise.
https://bugzilla.gnome.org/show_bug.cgi?id=690982
gjs/byteArray.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/gjs/byteArray.c b/gjs/byteArray.c
index 7e899dd..825c296 100644
--- a/gjs/byteArray.c
+++ b/gjs/byteArray.c
@@ -367,7 +367,7 @@ byte_array_new_resolve(JSContext *context,
ByteArrayInstance *priv;
jsval id_val;
- *objp = obj;
+ *objp = NULL;
priv = priv_from_js(context, obj);
@@ -383,12 +383,7 @@ byte_array_new_resolve(JSContext *context,
gsize idx;
if (!gjs_value_to_gsize(context, id_val, &idx))
return JS_FALSE;
- if (idx >= priv->array->len) {
- *objp = NULL;
- } else {
- /* leave objp set */
- g_assert(*objp != NULL);
-
+ if (idx < priv->array->len) {
/* define the property - AAARGH. Best I can tell from
* reading the source, this is unavoidable...
* which means using "for each" or "for ... in" on byte
@@ -406,6 +401,8 @@ byte_array_new_resolve(JSContext *context,
byte_array_set_prop,
JSPROP_ENUMERATE))
return JS_FALSE;
+
+ *objp = obj;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]