- hashtable-hash-function used to return an incorrect hash function

that the one supplied to make-hashtable; fixed.
- div and mod raise an error, rather than an assertion when given 
  zero second argument; fixed.
This commit is contained in:
Abdulaziz Ghuloum 2009-04-11 21:39:53 +03:00
parent 6bab4af5b4
commit 810fe75fa1
3 changed files with 11 additions and 10 deletions

View File

@ -15,7 +15,7 @@
(library (ikarus hash-tables)
(export make-eq-hashtable make-eqv-hashtable make-hashtable
(export make-eq-hashtable make-eqv-hashtable make-hashtable
hashtable-ref hashtable-set! hashtable?
hashtable-size hashtable-delete! hashtable-contains?
hashtable-update! hashtable-keys hashtable-mutable?
@ -36,7 +36,7 @@
hashtable-equivalence-function hashtable-hash-function
string-hash string-ci-hash symbol-hash))
(define-struct hasht (vec count tc mutable? hashf equivf))
(define-struct hasht (vec count tc mutable? hashf equivf hashf0))
;;; directly from Dybvig's paper
(define tc-pop
@ -337,7 +337,8 @@
(define (dup-hasht h mutable? n)
(let* ([hashf (hasht-hashf h)]
[tc (and (not hashf) (let ([x (cons #f #f)]) (cons x x)))])
(make-hasht (make-base-vec n) 0 tc mutable? hashf (hasht-equivf h))))
(make-hasht (make-base-vec n) 0 tc mutable?
hashf (hasht-equivf h) (hasht-hashf0 h))))
(let ([v (hasht-vec h)] [n (hasht-count h)])
(let ([r (dup-hasht h mutable? (vector-length v))])
(let f ([i ($fxsub1 n)] [j ($fxsub1 (vector-length v))] [r r] [v v])
@ -363,7 +364,7 @@
[()
(let ([x (cons #f #f)])
(let ([tc (cons x x)])
(make-hasht (make-base-vec 32) 0 tc #t #f eq?)))]
(make-hasht (make-base-vec 32) 0 tc #t #f eq? #f)))]
[(k)
(if (and (or (fixnum? k) (bignum? k)) (>= k 0))
(make-eq-hashtable)
@ -374,7 +375,7 @@
[()
(let ([x (cons #f #f)])
(let ([tc (cons x x)])
(make-hasht (make-base-vec 32) 0 tc #t #f eqv?)))]
(make-hasht (make-base-vec 32) 0 tc #t #f eqv? #f)))]
[(k)
(if (and (or (fixnum? k) (bignum? k)) (>= k 0))
(make-eqv-hashtable)
@ -402,7 +403,7 @@
(unless (procedure? equivf)
(die who "equivalence function is not a procedure" equivf))
(if (and (or (fixnum? k) (bignum? k)) (>= k 0))
(make-hasht (make-base-vec 32) 0 #f #t (wrap hashf) equivf)
(make-hasht (make-base-vec 32) 0 #f #t (wrap hashf) equivf hashf)
(die who "invalid initial capacity" k))]))
(define hashtable-ref
@ -495,7 +496,7 @@
(define (hashtable-hash-function h)
(if (hasht? h)
(hasht-hashf h)
(hasht-hashf0 h)
(die 'hashtable-hash-function "not a hash table" h)))
(define (string-hash s)

View File

@ -3378,7 +3378,7 @@
(cond
[(and (fixnum? n) (fixnum? m))
(cond
[(eq? m 0) (error 'div "division by 0")]
[(eq? m 0) (die 'div "division by 0")]
[(eq? m -1) (- n)]
[else
(let ([d0 ($fxquotient n m)])
@ -3396,7 +3396,7 @@
(cond
[(and (fixnum? n) (fixnum? m))
(cond
[(eq? m 0) (error 'mod "division by 0")]
[(eq? m 0) (die 'mod "division by 0")]
[else
(let ([d0 ($fxquotient n m)])
(let ([m0 ($fx- n ($fx* d0 m))])

View File

@ -1 +1 @@
1764
1765