Changeset 22447 in project for release/4/sqlite3/trunk/sqlite3.scm


Ignore:
Timestamp:
01/16/11 22:46:12 (9 years ago)
Author:
Thomas Chust
Message:

[sqlite3] More fixnum arithmetic tweaks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/sqlite3/trunk/sqlite3.scm

    r22421 r22447  
    575575    (thread-sleep! (/ ms 1000)))
    576576  (let* ([delays '#(1 2 5 10 15 20 25 25 25 50 50 100)]
    577   [totals '#(0 1 3  8 18 33 53 78 103 128 178 228)]
    578   [ndelay (vector-length delays)])
     577        [totals '#(0 1 3  8 18 33 53 78 103 128 178 228)]
     578        [ndelay (vector-length delays)])
    579579    (lambda (db count)
    580       (let* ([delay (vector-ref delays (min count (- ndelay 1)))]
    581        [prior (if (fx< count ndelay)
    582          (vector-ref totals count)
    583          (+ (vector-ref totals (- ndelay 1))
    584            (* delay (- count (- ndelay 1)))))])
    585   (let ([delay (if (fx> (+ prior delay) timeout)
    586                 (- timeout prior)
    587                 delay)])
    588     (cond
    589       [(fx<= delay 0) #f]
    590       [else
    591         (thread-sleep!/ms delay)
    592         #t]))))))
     580      (let* ([delay (vector-ref delays (fxmin count (fx- ndelay 1)))]
     581             [prior (if (fx< count ndelay)
     582                        (vector-ref totals count)
     583                        (fx+ (vector-ref totals (fx- ndelay 1))
     584                             (fx* delay (fx- count (fx- ndelay 1)))))])
     585        (let ([delay (if (fx> (fx+ prior delay) timeout)
     586                         (fx- timeout prior)
     587                        delay)])
     588          (cond
     589           [(fx<= delay 0) #f]
     590           [else
     591            (thread-sleep!/ms delay)
     592            #t]))))))
    593593
    594594;; Cancel any running database operation as soon as possible
Note: See TracChangeset for help on using the changeset viewer.