Skip to content

Commit 34c26b1

Browse files
committed
optimized listp, len
1 parent 24f4452 commit 34c26b1

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

arc.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -583,22 +583,20 @@ namespace arc {
583583

584584
int listp(atom expr)
585585
{
586-
atom p = expr;
587-
while (!no(p)) {
588-
if (p.type != T_CONS)
586+
while (!no(expr)) {
587+
if (expr.type != T_CONS)
589588
return 0;
590-
p = cdr(p);
589+
expr = cdr(expr);
591590
}
592591
return 1;
593592
}
594593

595-
size_t len(atom xs) {
596-
atom p = xs;
594+
size_t len(atom expr) {
597595
size_t ret = 0;
598-
while (!no(p)) {
599-
if (p.type != T_CONS)
596+
while (!no(expr)) {
597+
if (expr.type != T_CONS)
600598
return ret + 1;
601-
p = cdr(p);
599+
expr = cdr(expr);
602600
ret++;
603601
}
604602
return ret;

main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "arc.h"
22

3-
constexpr auto VERSION = "0.36.1";
3+
constexpr auto VERSION = "0.36.2";
44

55
void print_logo() {
66
printf("Arc++ %s\n", VERSION);

0 commit comments

Comments
 (0)