Changeset 13476 in project


Ignore:
Timestamp:
03/03/09 22:02:21 (11 years ago)
Author:
Jim Ursetto
Message:

tokyocabinet: speed up tc-hdb-get

Location:
release/3/tokyocabinet
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/3/tokyocabinet/tokyocabinet.scm

    r12323 r13476  
    1818  tc-hdb-iter-init tc-hdb-iter-next
    1919  ))
     20
     21(require-extension lolevel) ; free
    2022
    2123(declare
     
    142144  (%tc-hdb-delete! hdb key (string-length key)))
    143145
    144 (define %tc-hdb-get
    145   (foreign-safe-lambda* scheme-object
    146                         ((c-pointer hdb) (pointer kptr) (int ksize))
    147     "int size;"
    148     "void* res;"
    149     "if (! (res=tchdbget((TCHDB*) hdb, kptr, ksize, &size))) {"
    150     "    return(C_SCHEME_FALSE);"
    151     "} else {"
    152     "    return(make_string_with_len(res, size));"
    153     "}"))
    154 
    155146(define (tc-hdb-get hdb key)
    156   (%tc-hdb-get hdb key (string-length key)))
     147  (define tchdbget
     148    (foreign-lambda c-pointer "tchdbget"
     149                    c-pointer scheme-pointer int (c-pointer int)))
     150  (let-location ((size int))
     151    (let ((valptr (tchdbget hdb key
     152                            (string-length key) (location size))))
     153      (and valptr
     154           (let ((val (make-string size)))
     155             (##core#inline "copy_string_result" valptr size val)
     156             (free valptr)
     157             val)))))
    157158
    158159(define tc-hdb-iter-init
     
    172173          (let ((val (tc-hdb-get hdb key)))
    173174            (lp (kons key val acc)))))))
    174 
    175 (define-external (make_string_with_len (c-pointer ptr) (int len)) scheme-object
    176   (and ptr
    177        (let ((str (make-string len)))
    178          (##core#inline "copy_string_result" ptr len str)
    179          str)))
  • release/3/tokyocabinet/tokyocabinet.setup

    r12323 r13476  
    77 'tokyocabinet
    88 "tokyocabinet.so"
    9  '((version 1.0)
     9 '((version 1.01)
    1010   (exports "tokyocabinet.exports")))
Note: See TracChangeset for help on using the changeset viewer.