diff options
| author | Paul Eggert | 2019-06-09 09:18:05 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-06-09 09:18:24 -0700 |
| commit | 179b9c44c5dc6ba0cf8c9235b59c52aebcbaa828 (patch) | |
| tree | f78f1cb04bd0e041603ba9fa8eed6768bc297439 /src | |
| parent | 963d4e24263b0ff2add1a223f00387ca53d0658f (diff) | |
| download | emacs-179b9c44c5dc6ba0cf8c9235b59c52aebcbaa828.tar.gz emacs-179b9c44c5dc6ba0cf8c9235b59c52aebcbaa828.zip | |
* src/fns.c (cmpfn_eql): Simplify.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 35 |
1 files changed, 14 insertions, 21 deletions
| @@ -3948,26 +3948,19 @@ HASH_INDEX (struct Lisp_Hash_Table *h, ptrdiff_t idx) | |||
| 3948 | return XFIXNUM (AREF (h->index, idx)); | 3948 | return XFIXNUM (AREF (h->index, idx)); |
| 3949 | } | 3949 | } |
| 3950 | 3950 | ||
| 3951 | /* Compare KEY1 and KEY2 in hash table HT using `eql'. Value is true | 3951 | /* Ignore HT and compare KEY1 and KEY2 using 'eql'. |
| 3952 | if KEY1 and KEY2 are the same. KEY1 and KEY2 must not be eq. */ | 3952 | Value is true if KEY1 and KEY2 are the same. */ |
| 3953 | 3953 | ||
| 3954 | static bool | 3954 | static bool |
| 3955 | cmpfn_eql (struct hash_table_test *ht, | 3955 | cmpfn_eql (struct hash_table_test *ht, |
| 3956 | Lisp_Object key1, | 3956 | Lisp_Object key1, |
| 3957 | Lisp_Object key2) | 3957 | Lisp_Object key2) |
| 3958 | { | 3958 | { |
| 3959 | if (FLOATP (key1) | 3959 | return !NILP (Feql (key1, key2)); |
| 3960 | && FLOATP (key2) | ||
| 3961 | && same_float (key1, key2)) | ||
| 3962 | return true; | ||
| 3963 | return (BIGNUMP (key1) | ||
| 3964 | && BIGNUMP (key2) | ||
| 3965 | && mpz_cmp (XBIGNUM (key1)->value, XBIGNUM (key2)->value) == 0); | ||
| 3966 | } | 3960 | } |
| 3967 | 3961 | ||
| 3968 | 3962 | /* Ignore HT and compare KEY1 and KEY2 using 'equal'. | |
| 3969 | /* Compare KEY1 and KEY2 in hash table HT using `equal'. Value is | 3963 | Value is true if KEY1 and KEY2 are the same. */ |
| 3970 | true if KEY1 and KEY2 are the same. */ | ||
| 3971 | 3964 | ||
| 3972 | static bool | 3965 | static bool |
| 3973 | cmpfn_equal (struct hash_table_test *ht, | 3966 | cmpfn_equal (struct hash_table_test *ht, |
| @@ -3978,7 +3971,7 @@ cmpfn_equal (struct hash_table_test *ht, | |||
| 3978 | } | 3971 | } |
| 3979 | 3972 | ||
| 3980 | 3973 | ||
| 3981 | /* Compare KEY1 and KEY2 in hash table HT using HT->user_cmp_function. | 3974 | /* Given HT, compare KEY1 and KEY2 using HT->user_cmp_function. |
| 3982 | Value is true if KEY1 and KEY2 are the same. */ | 3975 | Value is true if KEY1 and KEY2 are the same. */ |
| 3983 | 3976 | ||
| 3984 | static bool | 3977 | static bool |
| @@ -3989,8 +3982,8 @@ cmpfn_user_defined (struct hash_table_test *ht, | |||
| 3989 | return !NILP (call2 (ht->user_cmp_function, key1, key2)); | 3982 | return !NILP (call2 (ht->user_cmp_function, key1, key2)); |
| 3990 | } | 3983 | } |
| 3991 | 3984 | ||
| 3992 | /* Value is a hash code for KEY for use in hash table H which uses | 3985 | /* Ignore HT and return a hash code for KEY which uses 'eq' to compare keys. |
| 3993 | `eq' to compare keys. The value is at most INTMASK. */ | 3986 | The hash code is at most INTMASK. */ |
| 3994 | 3987 | ||
| 3995 | static EMACS_UINT | 3988 | static EMACS_UINT |
| 3996 | hashfn_eq (struct hash_table_test *ht, Lisp_Object key) | 3989 | hashfn_eq (struct hash_table_test *ht, Lisp_Object key) |
| @@ -3998,8 +3991,8 @@ hashfn_eq (struct hash_table_test *ht, Lisp_Object key) | |||
| 3998 | return XHASH (key) ^ XTYPE (key); | 3991 | return XHASH (key) ^ XTYPE (key); |
| 3999 | } | 3992 | } |
| 4000 | 3993 | ||
| 4001 | /* Value is a hash code for KEY for use in hash table H which uses | 3994 | /* Ignore HT and return a hash code for KEY which uses 'equal' to compare keys. |
| 4002 | `equal' to compare keys. The value is at most INTMASK. */ | 3995 | The hash code is at most INTMASK. */ |
| 4003 | 3996 | ||
| 4004 | EMACS_UINT | 3997 | EMACS_UINT |
| 4005 | hashfn_equal (struct hash_table_test *ht, Lisp_Object key) | 3998 | hashfn_equal (struct hash_table_test *ht, Lisp_Object key) |
| @@ -4007,8 +4000,8 @@ hashfn_equal (struct hash_table_test *ht, Lisp_Object key) | |||
| 4007 | return sxhash (key, 0); | 4000 | return sxhash (key, 0); |
| 4008 | } | 4001 | } |
| 4009 | 4002 | ||
| 4010 | /* Value is a hash code for KEY for use in hash table H which uses | 4003 | /* Ignore HT and return a hash code for KEY which uses 'eql' to compare keys. |
| 4011 | `eql' to compare keys. The value is at most INTMASK. */ | 4004 | The hash code is at most INTMASK. */ |
| 4012 | 4005 | ||
| 4013 | EMACS_UINT | 4006 | EMACS_UINT |
| 4014 | hashfn_eql (struct hash_table_test *ht, Lisp_Object key) | 4007 | hashfn_eql (struct hash_table_test *ht, Lisp_Object key) |
| @@ -4018,8 +4011,8 @@ hashfn_eql (struct hash_table_test *ht, Lisp_Object key) | |||
| 4018 | : hashfn_eq (ht, key)); | 4011 | : hashfn_eq (ht, key)); |
| 4019 | } | 4012 | } |
| 4020 | 4013 | ||
| 4021 | /* Value is a hash code for KEY for use in hash table H which uses as | 4014 | /* Given HT, return a hash code for KEY which uses a user-defined |
| 4022 | user-defined function to compare keys. The value is at most INTMASK. */ | 4015 | function to compare keys. The hash code is at most INTMASK. */ |
| 4023 | 4016 | ||
| 4024 | static EMACS_UINT | 4017 | static EMACS_UINT |
| 4025 | hashfn_user_defined (struct hash_table_test *ht, Lisp_Object key) | 4018 | hashfn_user_defined (struct hash_table_test *ht, Lisp_Object key) |