diff options
| author | Paul Pogonyshev | 2016-04-08 14:02:48 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-04-08 15:33:59 -0700 |
| commit | a4aa94d0cdffb45723786aa798174e942d509774 (patch) | |
| tree | d4a498fd0319d004ef1e42885f1f91e9bc2172a2 /src | |
| parent | b2746dbf562dc4821bc111488b0e5b6ca5fc6061 (diff) | |
| download | emacs-a4aa94d0cdffb45723786aa798174e942d509774.tar.gz emacs-a4aa94d0cdffb45723786aa798174e942d509774.zip | |
New primitives sxhash-eq, sxhash-eql
* doc/lispref/hash.texi (Defining Hash), etc/NEWS: Document this.
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns):
Add sxhash-equal, sxhash-eq, sxhash-eql.
* lisp/subr.el (sxhash): Now an alias for sxhash-equal.
* src/fns.c (Fsxhash_eq, Fsxhash_eql): New functions.n
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 24 |
1 files changed, 22 insertions, 2 deletions
| @@ -4447,8 +4447,26 @@ sxhash (Lisp_Object obj, int depth) | |||
| 4447 | Lisp Interface | 4447 | Lisp Interface |
| 4448 | ***********************************************************************/ | 4448 | ***********************************************************************/ |
| 4449 | 4449 | ||
| 4450 | DEFUN ("sxhash-eq", Fsxhash_eq, Ssxhash_eq, 1, 1, 0, | ||
| 4451 | doc: /* Compute identity hash code for OBJ and return it as integer. | ||
| 4452 | In other words, hash codes of two non-`eq' lists will be (most likely) | ||
| 4453 | different, even if the lists contain the same elements. */) | ||
| 4454 | (Lisp_Object obj) | ||
| 4455 | { | ||
| 4456 | return make_number (hashfn_eq (NULL, obj)); | ||
| 4457 | } | ||
| 4458 | |||
| 4459 | DEFUN ("sxhash-eql", Fsxhash_eql, Ssxhash_eql, 1, 1, 0, | ||
| 4460 | doc: /* Compute identity hash code for OBJ and return it as integer. | ||
| 4461 | In comparison to `sxhash-eq', it is also guaranteed that hash codes | ||
| 4462 | of equal float numbers will be the same, even if the numbers are not | ||
| 4463 | the same Lisp object. */) | ||
| 4464 | (Lisp_Object obj) | ||
| 4465 | { | ||
| 4466 | return make_number (hashfn_eql (NULL, obj)); | ||
| 4467 | } | ||
| 4450 | 4468 | ||
| 4451 | DEFUN ("sxhash", Fsxhash, Ssxhash, 1, 1, 0, | 4469 | DEFUN ("sxhash-equal", Fsxhash_equal, Ssxhash_equal, 1, 1, 0, |
| 4452 | doc: /* Compute a hash code for OBJ and return it as integer. */) | 4470 | doc: /* Compute a hash code for OBJ and return it as integer. */) |
| 4453 | (Lisp_Object obj) | 4471 | (Lisp_Object obj) |
| 4454 | { | 4472 | { |
| @@ -5066,7 +5084,9 @@ syms_of_fns (void) | |||
| 5066 | DEFSYM (Qkey_or_value, "key-or-value"); | 5084 | DEFSYM (Qkey_or_value, "key-or-value"); |
| 5067 | DEFSYM (Qkey_and_value, "key-and-value"); | 5085 | DEFSYM (Qkey_and_value, "key-and-value"); |
| 5068 | 5086 | ||
| 5069 | defsubr (&Ssxhash); | 5087 | defsubr (&Ssxhash_eq); |
| 5088 | defsubr (&Ssxhash_eql); | ||
| 5089 | defsubr (&Ssxhash_equal); | ||
| 5070 | defsubr (&Smake_hash_table); | 5090 | defsubr (&Smake_hash_table); |
| 5071 | defsubr (&Scopy_hash_table); | 5091 | defsubr (&Scopy_hash_table); |
| 5072 | defsubr (&Shash_table_count); | 5092 | defsubr (&Shash_table_count); |