|
From: | fanglungang |
Subject: | [Emms-patches] Re:Patch emms-browser.el |
Date: | Thu, 20 Jan 2011 01:03:33 +0800 (CST) |
Hi All,
I think I fixed a bug: the `case-fold-string=' defined is incorrect. It can't
deal with the entries of different keys but same hash value. Meanwhile
the hash value conflict for Chinese string seems to be quite large.
Here is a test case. In this case, two keys (Chinese string) has same hash
value. You'll find all the `puthash' put values into same bucket.
(let ((a "宋兵甲")
(b "宋兵乙")
(hash (make-hash-table :test 'case-fold)))
(puthash a "foo" hash)
(puthash a "bar" hash)
(puthash b "hi" hash)
(message (format "%s=>%s" a (gethash a hash)))
(message (format "%s=>%s" b (gethash b hash)))
nil)
Attached is my fix
Regards,
lgfang
*** /home/lgfang/tmp/emms/lisp/emms-browser.el 2011-01-09 21:53:40.894901760 +0800
--- /home/storage/daily/my-notes/emacs/extensions/emms/emms-browser.el 2011-01-19 23:28:09.464936676 +0800
***************
*** 674,680 ****
(sort-lines nil (point-min) (point-max)))))
(defun case-fold-string= (a b)
! (compare-strings a nil nil b nil nil t))
(defun case-fold-string-hash (a)
(sxhash (upcase a)))
--- 674,682 ----
(sort-lines nil (point-min) (point-max)))))
(defun case-fold-string= (a b)
! (if (equal (compare-strings a nil nil b nil nil t) t)
! t
! nil))
(defun case-fold-string-hash (a)
(sxhash (upcase a)))
[Prev in Thread] | Current Thread | [Next in Thread] |