There is scm_c_memq for avoiding hare&tortoise, but for this use case, the explicit code seems like the saner option. Even without hare&tortoise, the list would be consed together each time without further measures.
https://codereview.appspot.com/579570043/diff/577750045/lily/stencil-integral.cc File lily/stencil-integral.cc (right): https://codereview.appspot.com/579570043/diff/577750045/lily/stencil-integral.cc#newcode115 lily/stencil-integral.cc:115: && (SCM_EQ_P (head, ly_symbol2scm ("moveto")) SCM_EQ_P is an old deprecated macro. Use scm_is_eq instead. Same performance. https://codereview.appspot.com/579570043/diff/577750045/lily/stencil-integral.cc#newcode127 lily/stencil-integral.cc:127: return get_path_list (scm_cdr (l)); Not caused by this patch, but this does look like something nicer addressed by a loop rather than tail recursion with regard to C++ idioms. https://codereview.appspot.com/579570043/