Remove unnecessary listLength type checking.

This commit is contained in:
Sage Vaillancourt 2022-03-27 00:13:04 -04:00
parent 9a454e6a30
commit b715b2116a
2 changed files with 2 additions and 6 deletions

View File

@ -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++;

View File

@ -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;
}