From b715b2116aaee662baa690857bf5cd6817ca082f Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 27 Mar 2022 00:13:04 -0400 Subject: [PATCH] Remove unnecessary listLength type checking. --- src/object.c | 4 ---- src/plfunc.c | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/object.c b/src/object.c index b899427..b6553a8 100644 --- a/src/object.c +++ b/src/object.c @@ -35,10 +35,6 @@ void* scalloc(size_t size, size_t count) */ int listLength(const Object* listObj) { - if (!listObj || !isListy(*listObj)) { - return -1; - } - int len = 0; FOR_POINTER_IN_LIST(listObj) { len++; diff --git a/src/plfunc.c b/src/plfunc.c index bf12a31..3762c6a 100644 --- a/src/plfunc.c +++ b/src/plfunc.c @@ -307,10 +307,10 @@ Object len(Object* params, int length, struct Environment* env) { Object obj1 = params[0]; - Object o = numberObject(listLength(&obj1)); - if (o.number < 0) { + if (!isListy(obj1)) { return errorObject(NOT_A_LIST); } + Object o = numberObject(listLength(&obj1)); return o; }