[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: get_path_list: use loop instead of tail recursion (issue 579570046 b
From: |
dak |
Subject: |
Re: get_path_list: use loop instead of tail recursion (issue 579570046 by address@hidden) |
Date: |
Sat, 18 Apr 2020 06:06:01 -0700 |
Reviewers: hanwenn,
Message:
On 2020/04/17 09:12:18, hanwenn wrote:
> LGTM
>
>
https://codereview.appspot.com/579570046/diff/579580044/lily/stencil-integral.cc
> File lily/stencil-integral.cc (right):
>
>
https://codereview.appspot.com/579570046/diff/579580044/lily/stencil-integral.cc#newcode111
> lily/stencil-integral.cc:111: for (;scm_is_pair (l); l = scm_cdr (l))
Reformatted. Not uploading a separate review for this one, though.
Description:
get_path_list: use loop instead of tail recursion
Please review this at https://codereview.appspot.com/579570046/
Affected files (+3, -4 lines):
M lily/stencil-integral.cc
Index: lily/stencil-integral.cc
diff --git a/lily/stencil-integral.cc b/lily/stencil-integral.cc
index
6f4dfbae3fee4e764a9a308f290d009e2bb5fae9..449b1ff4a86792350ec21269e4160a43064029f0
100644
--- a/lily/stencil-integral.cc
+++ b/lily/stencil-integral.cc
@@ -108,7 +108,7 @@ get_number_list (SCM l)
SCM
get_path_list (SCM l)
{
- if (scm_is_pair (l))
+ for (;scm_is_pair (l); l = scm_cdr (l))
{
if (scm_is_true (scm_memv (scm_car (l),
scm_list_n (ly_symbol2scm ("moveto"),
@@ -121,9 +121,8 @@ get_path_list (SCM l)
SCM_UNDEFINED))))
return l;
SCM res = get_path_list (scm_car (l));
- if (scm_is_false (res))
- return get_path_list (scm_cdr (l));
- return res;
+ if (scm_is_true (res))
+ return res;
}
return SCM_BOOL_F;
}