aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2019-06-09 09:18:05 -0700
committerPaul Eggert2019-06-09 09:18:24 -0700
commit179b9c44c5dc6ba0cf8c9235b59c52aebcbaa828 (patch)
treef78f1cb04bd0e041603ba9fa8eed6768bc297439 /src
parent963d4e24263b0ff2add1a223f00387ca53d0658f (diff)
downloademacs-179b9c44c5dc6ba0cf8c9235b59c52aebcbaa828.tar.gz
emacs-179b9c44c5dc6ba0cf8c9235b59c52aebcbaa828.zip
* src/fns.c (cmpfn_eql): Simplify.
Diffstat (limited to 'src')
-rw-r--r--src/fns.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/fns.c b/src/fns.c
index 8307a36a09d..eaa2c07fbe4 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -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
3954static bool 3954static bool
3955cmpfn_eql (struct hash_table_test *ht, 3955cmpfn_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
3972static bool 3965static bool
3973cmpfn_equal (struct hash_table_test *ht, 3966cmpfn_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
3984static bool 3977static 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
3995static EMACS_UINT 3988static EMACS_UINT
3996hashfn_eq (struct hash_table_test *ht, Lisp_Object key) 3989hashfn_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
4004EMACS_UINT 3997EMACS_UINT
4005hashfn_equal (struct hash_table_test *ht, Lisp_Object key) 3998hashfn_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
4013EMACS_UINT 4006EMACS_UINT
4014hashfn_eql (struct hash_table_test *ht, Lisp_Object key) 4007hashfn_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
4024static EMACS_UINT 4017static EMACS_UINT
4025hashfn_user_defined (struct hash_table_test *ht, Lisp_Object key) 4018hashfn_user_defined (struct hash_table_test *ht, Lisp_Object key)