else if (HASH_TABLE_P (collection))
{
struct Lisp_Hash_Table *h = XHASH_TABLE (collection);
- Lisp_Object key = Qnil;
i = hash_lookup (h, string, NULL);
if (i >= 0)
- tem = HASH_KEY (h, i);
+ {
+ tem = HASH_KEY (h, i);
+ goto found_matching_key;
+ }
else
for (i = 0; i < HASH_TABLE_SIZE (h); ++i)
- if (!NILP (HASH_HASH (h, i))
- && (key = HASH_KEY (h, i),
- SYMBOLP (key) ? key = Fsymbol_name (key) : key,
- STRINGP (key))
- && EQ (Fcompare_strings (string, make_number (0), Qnil,
- key, make_number (0) , Qnil,
- completion_ignore_case ? Qt : Qnil),
- Qt))
- {
- tem = key;
- break;
- }
- if (!STRINGP (tem))
- return Qnil;
+ {
+ if (NILP (HASH_HASH (h, i))) continue;
+ tem = HASH_KEY (h, i);
+ Lisp_Object strkey = (SYMBOLP (tem) ? Fsymbol_name (tem) : tem);
+ if (!STRINGP (strkey)) continue;
+ if (EQ (Fcompare_strings (string, Qnil, Qnil,
+ strkey, Qnil, Qnil,
+ completion_ignore_case ? Qt : Qnil),
+ Qt))
+ goto found_matching_key;
+ }
+ return Qnil;
+ found_matching_key: ;
}
else
return call3 (collection, string, predicate, Qlambda);
(ert-deftest test-completion-symbol-hashtable-predicate ()
(minibuf-tests--test-completion-pred
#'minibuf-tests--strings-to-symbol-hashtable
- ;; The predicate recieves a string as the key in this case.
- (lambda (table)
- (let ((in-table (minibuf-tests--part-of-hashtable table)))
- (lambda (k v) (funcall in-table (intern k) v))))))
+ #'minibuf-tests--part-of-hashtable))
(ert-deftest test-completion-symbol-hashtable-completion-regexp ()
(minibuf-tests--test-completion-regexp
#'minibuf-tests--strings-to-symbol-hashtable))