Changeset 9028 in project


Ignore:
Timestamp:
02/26/08 15:44:28 (12 years ago)
Author:
Kon Lovett
Message:

Canon dir struct

Location:
release/3/perfect-hash
Files:
2 added
4 copied
10 moved

Legend:

Unmodified
Added
Removed
  • release/3/perfect-hash/trunk/perfect-hash-record-macros.scm

    r9024 r9028  
    1313
    1414;; 2^(fxlog2 n) for positive n
    15 #;(define-inline (fxpow2log2 n)
     15#;
     16(define-inline (fxpow2log2 n)
    1617  (let loop ([ncnt 1])
    1718    (if (fx< ncnt n)
    18       (loop (fxshl ncnt 1))
    19       ncnt ) ) )
     19        (loop (fxshl ncnt 1))
     20        ncnt ) ) )
    2021
    2122(define-macro (%constantly X)
     
    3132  (vec pht-vector pht-vector-set!)
    3233  (siz pht-size pht-size-set!)
    33   #;(a pht-a pht-a-set!)
    34   #;(b pht-b pht-b-set!)
    35   #;(mask pht-mask pht-mask-set!))
     34  #;
     35  (a pht-a pht-a-set!)
     36  #;
     37  (b pht-b pht-b-set!)
     38  #;
     39  (mask pht-mask pht-mask-set!))
    3640
    3741(define-inline (pht-empty-mark? val)
     
    4448  (fxshr (pht-length pht) 1) )
    4549
    46 #;(define-inline (check-vector-limit cnt)
     50#;
     51(define-inline (check-vector-limit cnt)
    4752  (when (fx> cnt (perfect-hash-table-count-maximum))
    4853    (error "perfect hash table limit reached" cnt)) )
  • release/3/perfect-hash/trunk/perfect-hash-support.scm

    r9024 r9028  
    55
    66(define-macro (stats-expand!? FORM #!optional (OTHER '(begin)))
    7   #;FORM OTHER )
     7  #;
     8  FORM
     9  OTHER )
    810
    911(define-macro (stats!? FORM #!optional (OTHER '(begin)))
     
    6163  ((pht-equivalence-procedure pht) key1 key2) )
    6264
    63 #;(define-inline (pht-mask-for-count cnt)
     65#;
     66(define-inline (pht-mask-for-count cnt)
    6467  (fxshr most-positive-fixnum (fx- fixnum-precision (fxlog2 cnt))) )
    6568
    66 #;(define-inline (new-pht-mask! pht cnt)
     69#;
     70(define-inline (new-pht-mask! pht cnt)
    6771  (pht-mask-set! pht (pht-mask-for-count cnt)) )
    6872
    69 #;(define-inline (%pht-hash-index h a b m)
     73#;
     74(define-inline (%pht-hash-index h a b m)
    7075  (let ([h (fxand (fxxor (fxshr h a) (fxshr h b)) m)])
    7176    (fx+ h h) ) )
    7277
    73 #;(define %pht-hash-index
     78#;
     79(define %pht-hash-index
    7480  (foreign-lambda* unsigned-int
    7581    ((unsigned-integer h) (unsigned-int a) (unsigned-int b) (unsigned-int m))
    7682    "unsigned int c = ((h >> a) ^ (h >> b)) & m; return(c + c);") )
    7783
    78 #;(define-inline (pht-hash-index pht key)
     84#;
     85(define-inline (pht-hash-index pht key)
    7986  (%pht-hash-index (pht-hash-value pht key) (pht-a pht) (pht-b pht) (pht-mask pht)) )
    8087
     
    8895(define-inline (pht-vector-update! pht vec #;cnt)
    8996  (pht-vector-set! pht vec)
    90   #;(new-pht-mask! pht cnt) )
     97  #;
     98  (new-pht-mask! pht cnt) )
    9199
    92100(define-inline (pht-clear-vector! vec)
     
    94102
    95103(define-inline (pht-vec-ref idx vec)
    96   #;(vector-ref vec idx)
     104  #;
     105  (vector-ref vec idx)
    97106  (##sys#slot vec idx) )
    98107
    99108(define-inline (pht-vec-set! idx obj vec)
    100   #;(vector-set! vec idx obj)
     109  #;
     110  (vector-set! vec idx obj)
    101111  (##sys#setslot vec idx obj) )
    102112
     
    140150  (not (pht-key-empty? idx vec)) )
    141151
    142 #;(define-inline (pht-used-slot? idx vec)
     152#;
     153(define-inline (pht-used-slot? idx vec)
    143154  (and (not (pht-key-empty? idx vec))
    144155       (not (pht-value-empty? idx vec))) )
     
    153164         (pht-key-equal? pht key keyat)) ) )
    154165
    155 #;(define-inline (pht-key-slot-equal? pht key idx vec)
     166#;
     167(define-inline (pht-key-slot-equal? pht key idx vec)
    156168  (and (pht-used-slot? idx vec)
    157169       (pht-key-equal? pht key (pht-key-ref idx vec))) )
     
    207219            (vector-loop (fx+ idx 2))] ) ) ) ) )
    208220
    209 #;(define-inline (pht-needed-count pht extra)
     221#;
     222(define-inline (pht-needed-count pht extra)
    210223  (fxpow2log2 (fx+ extra (pht-size pht))) )
    211224
    212 #;(define-inline (pht-init-rehash pht)
     225#;
     226(define-inline (pht-init-rehash pht)
    213227  (pht-a-set! pht 1)
    214228  (pht-b-set! pht 0)
    215229  (copy-pht-vector pht (pht-needed-count pht 1)) )
    216230
    217 #;(define-inline (pht-next-rehash pht)
     231#;
     232(define-inline (pht-next-rehash pht)
    218233  (let ([nb (fx++ (pht-b pht))]
    219234        [a (pht-a pht)])
     
    232247  (copy-pht-vector! pht (fxmax (pht-count pht) (pht-size pht))) )
    233248
    234 #;(define-inline (pht-next-rehash pht)
     249#;
     250(define-inline (pht-next-rehash pht)
    235251  (new-pht-vector! pht
    236252    (fx+ (perfect-hash-table-grow-bias)
     
    315331        [vec (pht-vector pht)]
    316332        [cnt (pht-count pht)]
    317         #;[a (pht-a pht)]
    318         #;[b (pht-b pht)]
    319         #;[m (pht-mask pht)])
     333        #;
     334        [a (pht-a pht)]
     335        #;
     336        [b (pht-b pht)]
     337        #;
     338        [m (pht-mask pht)])
    320339    (lambda (key)
    321340      (let ([idx (%pht-hash-index (hf key) cnt #;a #;b #;m)])
  • release/3/perfect-hash/trunk/perfect-hash.scm

    r9024 r9028  
    5151    (error loc "not a list" obj)) )
    5252
    53 (define (check-proc obj kind loc)
     53(define (check-procedure obj kind loc)
    5454  (unless (procedure? obj)
    5555    (errorf loc "~S argument not a procedure: ~A" kind obj)) )
     
    6262
    6363(define (make-perfect-hash-table #!optional (eqp equal?) (hshp hash) (size 1))
    64   (check-proc eqp "equal" 'make-perfect-hash-table)
    65   (check-proc hshp "hash" 'make-perfect-hash-table)
     64  (check-procedure eqp "equal" 'make-perfect-hash-table)
     65  (check-procedure hshp "hash" 'make-perfect-hash-table)
    6666  (unless (and (fixnum? size) (fxpos? size))
    6767    (error 'make-perfect-hash-table "size is not a positive fixnum" size))
     
    6969
    7070(define (alist->perfect-hash-table alist #!optional (eqp equal?) (hshp hash))
    71   (check-proc eqp "equal" 'make-perfect-hash-table)
    72   (check-proc hshp "hash" 'make-perfect-hash-table)
     71  (check-procedure eqp "equal" 'make-perfect-hash-table)
     72  (check-procedure hshp "hash" 'make-perfect-hash-table)
    7373  (check-list alist 'make-perfect-hash-table)
    7474  (let ([pht (make-pht hshp eqp (length alist))])
     
    9696(define (make-perfect-hash-table-accessor pht #!optional (thunk (%constantly (error 'perfect-hash-accessor "not found"))))
    9797  (check-pht pht 'make-perfect-hash-table-accessor)
    98   (check-proc thunk "thunk" 'make-perfect-hash-table-accessor)
     98  (check-procedure thunk "thunk" 'make-perfect-hash-table-accessor)
    9999  (*make-pht-ref pht thunk) )
    100100
     
    109109      (check-pht pht 'perfect-hash-table-ref)
    110110      (check-key key 'perfect-hash-table-ref)
    111       (check-proc thunk "thunk" 'perfect-hash-table-ref)
     111      (check-procedure thunk "thunk" 'perfect-hash-table-ref)
    112112      (*pht-ref pht key thunk) )
    113113    perfect-hash-table-set!) )
     
    130130  (check-pht pht 'perfect-hash-table-update!)
    131131  (check-key key 'perfect-hash-table-update!)
    132   (check-proc func "function" 'perfect-hash-table-update!)
    133   (check-proc thunk "thunk" 'perfect-hash-table-update!)
     132  (check-procedure func "function" 'perfect-hash-table-update!)
     133  (check-procedure thunk "thunk" 'perfect-hash-table-update!)
    134134  (*pht-set! pht key (func (*pht-ref pht key thunk))) )
    135135
     
    137137  (check-pht pht 'perfect-hash-table-update!/default)
    138138  (check-key key 'perfect-hash-table-update!/default)
    139   (check-proc func "function" 'perfect-hash-table-update!/default)
     139  (check-procedure func "function" 'perfect-hash-table-update!/default)
    140140  (*pht-set! pht key (func (*pht-ref pht key (%constantly default)))) )
    141141
     
    146146(define (perfect-hash-table-fold pht proc accum)
    147147  (check-pht pht 'perfect-hash-table-fold)
    148   (check-proc proc "function" 'perfect-hash-table-fold)
     148  (check-procedure proc "function" 'perfect-hash-table-fold)
    149149  (*pht-fold proc pht accum) )
    150150
     
    159159(define (perfect-hash-table-walk pht proc)
    160160  (check-pht pht 'perfect-hash-table-walk)
    161   (check-proc proc "procedure" 'perfect-hash-table-walk)
     161  (check-procedure proc "procedure" 'perfect-hash-table-walk)
    162162  (*pht-walk proc pht) )
    163163
     
    173173    (vector-copy (pht-vector pht))
    174174    (pht-size pht)
    175     #;(pht-a pht)
    176     #;(pht-b pht)
    177     #;(pht-mask pht)) )
     175    #;
     176    (pht-a pht)
     177    #;
     178    (pht-b pht)
     179    #;
     180    (pht-mask pht)) )
    178181
    179182(define (perfect-hash-table-merge! pht1 pht2)
  • release/3/perfect-hash/trunk/perfect-hash.setup

    r9024 r9028  
    77  'miscmacros             "2.4")
    88
    9 (install-dynld perfect-hash-parameters "0.1") ; -O3 -d0
    10 (install-dynld perfect-hash-support "0.1") ;  -O3 -d0
    11 (install-dynld+docu perfect-hash "0.1"
     9(install-dynld perfect-hash-parameters *version*) ; -O3 -d0
     10(install-dynld perfect-hash-support *version*) ;  -O3 -d0
     11(install-dynld+docu perfect-hash *version*
    1212        (requires-at-runtime perfect-hash-support))
    1313
Note: See TracChangeset for help on using the changeset viewer.