]> git.donarmstrong.com Git - lilypond.git/commitdiff
Optimize assoc_tail for various key types
authorDavid Kastrup <dak@gnu.org>
Mon, 7 Mar 2016 11:03:31 +0000 (12:03 +0100)
committerDavid Kastrup <dak@gnu.org>
Sat, 19 Mar 2016 13:20:03 +0000 (14:20 +0100)
lily/nested-property.cc

index d45f395b304388dba633411a53c339b2005a9e3f..6ce5234fc33178df530d653cde34d5d9d7278fad 100644 (file)
@@ -51,6 +51,10 @@ assv_tail (SCM key, SCM alist, SCM based_on = SCM_EOL)
 SCM
 assoc_tail (SCM key, SCM alist, SCM based_on = SCM_EOL)
 {
+  if (SCM_IMP (key))
+    return assq_tail (key, alist, based_on);
+  if (scm_is_number (key) || scm_is_true (scm_char_p (key)))
+    return assv_tail (key, alist, based_on);
   for (SCM p = alist; !scm_is_eq (p, based_on); p = scm_cdr (p))
     {
       if (ly_is_equal (scm_caar (p), key))
@@ -79,10 +83,8 @@ SCM assq_pop_x (SCM key, SCM *alist)
 SCM
 evict_from_alist (SCM key, SCM alist, SCM alist_end)
 {
-// shortcircuit to an eq-using assoc_tail variant when key is a symbol
-// (common case)
-  SCM p = scm_is_symbol (key) ? assq_tail (key, alist, alist_end)
-    : assoc_tail (key, alist, alist_end);
+  SCM p = assoc_tail (key, alist, alist_end);
+
   if (scm_is_true (p))
     return partial_list_copy (alist, p, scm_cdr (p));
   return alist;