Remove unnecessary listLength type checking.
This commit is contained in:
parent
9a454e6a30
commit
b715b2116a
|
@ -35,10 +35,6 @@ void* scalloc(size_t size, size_t count)
|
||||||
*/
|
*/
|
||||||
int listLength(const Object* listObj)
|
int listLength(const Object* listObj)
|
||||||
{
|
{
|
||||||
if (!listObj || !isListy(*listObj)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
FOR_POINTER_IN_LIST(listObj) {
|
FOR_POINTER_IN_LIST(listObj) {
|
||||||
len++;
|
len++;
|
||||||
|
|
|
@ -307,10 +307,10 @@ Object len(Object* params, int length, struct Environment* env)
|
||||||
{
|
{
|
||||||
Object obj1 = params[0];
|
Object obj1 = params[0];
|
||||||
|
|
||||||
Object o = numberObject(listLength(&obj1));
|
if (!isListy(obj1)) {
|
||||||
if (o.number < 0) {
|
|
||||||
return errorObject(NOT_A_LIST);
|
return errorObject(NOT_A_LIST);
|
||||||
}
|
}
|
||||||
|
Object o = numberObject(listLength(&obj1));
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue