diff options
| author | Andrea Corallo | 2020-07-09 16:42:16 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2020-07-09 16:42:16 +0100 |
| commit | 5f13016cedd245a7388ffafddffa20268afaf023 (patch) | |
| tree | bd54c451ff742cbcec6962acdc6d3aa717f1172c /src | |
| parent | 02bf2e08e27a00cde891a20affe96653fe44c7da (diff) | |
| parent | 19cf8e5be7c1b02dbc0831d8b64560533a59587c (diff) | |
| download | emacs-5f13016cedd245a7388ffafddffa20268afaf023.tar.gz emacs-5f13016cedd245a7388ffafddffa20268afaf023.zip | |
Merge remote-tracking branch 'savannah/master' into wip2
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 14 |
1 files changed, 14 insertions, 0 deletions
| @@ -1530,11 +1530,21 @@ same_float (Lisp_Object x, Lisp_Object y) | |||
| 1530 | return !neql; | 1530 | return !neql; |
| 1531 | } | 1531 | } |
| 1532 | 1532 | ||
| 1533 | /* True if X can be compared using `eq'. | ||
| 1534 | This predicate is approximative, for maximum speed. */ | ||
| 1535 | static bool | ||
| 1536 | eq_comparable_value (Lisp_Object x) | ||
| 1537 | { | ||
| 1538 | return SYMBOLP (x) || FIXNUMP (x); | ||
| 1539 | } | ||
| 1540 | |||
| 1533 | DEFUN ("member", Fmember, Smember, 2, 2, 0, | 1541 | DEFUN ("member", Fmember, Smember, 2, 2, 0, |
| 1534 | doc: /* Return non-nil if ELT is an element of LIST. Comparison done with `equal'. | 1542 | doc: /* Return non-nil if ELT is an element of LIST. Comparison done with `equal'. |
| 1535 | The value is actually the tail of LIST whose car is ELT. */) | 1543 | The value is actually the tail of LIST whose car is ELT. */) |
| 1536 | (Lisp_Object elt, Lisp_Object list) | 1544 | (Lisp_Object elt, Lisp_Object list) |
| 1537 | { | 1545 | { |
| 1546 | if (eq_comparable_value (elt)) | ||
| 1547 | return Fmemq (elt, list); | ||
| 1538 | Lisp_Object tail = list; | 1548 | Lisp_Object tail = list; |
| 1539 | FOR_EACH_TAIL (tail) | 1549 | FOR_EACH_TAIL (tail) |
| 1540 | if (! NILP (Fequal (elt, XCAR (tail)))) | 1550 | if (! NILP (Fequal (elt, XCAR (tail)))) |
| @@ -1622,6 +1632,8 @@ The value is actually the first element of ALIST whose car equals KEY. | |||
| 1622 | Equality is defined by TESTFN if non-nil or by `equal' if nil. */) | 1632 | Equality is defined by TESTFN if non-nil or by `equal' if nil. */) |
| 1623 | (Lisp_Object key, Lisp_Object alist, Lisp_Object testfn) | 1633 | (Lisp_Object key, Lisp_Object alist, Lisp_Object testfn) |
| 1624 | { | 1634 | { |
| 1635 | if (eq_comparable_value (key) && NILP (testfn)) | ||
| 1636 | return Fassq (key, alist); | ||
| 1625 | Lisp_Object tail = alist; | 1637 | Lisp_Object tail = alist; |
| 1626 | FOR_EACH_TAIL (tail) | 1638 | FOR_EACH_TAIL (tail) |
| 1627 | { | 1639 | { |
| @@ -1672,6 +1684,8 @@ DEFUN ("rassoc", Frassoc, Srassoc, 2, 2, 0, | |||
| 1672 | The value is actually the first element of ALIST whose cdr equals KEY. */) | 1684 | The value is actually the first element of ALIST whose cdr equals KEY. */) |
| 1673 | (Lisp_Object key, Lisp_Object alist) | 1685 | (Lisp_Object key, Lisp_Object alist) |
| 1674 | { | 1686 | { |
| 1687 | if (eq_comparable_value (key)) | ||
| 1688 | return Frassq (key, alist); | ||
| 1675 | Lisp_Object tail = alist; | 1689 | Lisp_Object tail = alist; |
| 1676 | FOR_EACH_TAIL (tail) | 1690 | FOR_EACH_TAIL (tail) |
| 1677 | { | 1691 | { |