Changeset 9434 in project


Ignore:
Timestamp:
03/11/08 09:13:51 (12 years ago)
Author:
Jim Ursetto
Message:

uri: small optimization to uri-decode

Location:
release/3/uri/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/3/uri/trunk/uri.html

    r7003 r9434  
    558558<h3>Version:</h3>
    559559<ul>
     560<li>3.402 Optimization to uri-decode.</li>
    560561<li>3.401 Applied patch by Hans Bulfone - no ':' w/o a valid scheme.</li>
    561562<li>3.4 Added line-break encoding. Applied patch by Hans Bulfone - '!' is not "unreserved", '+' & '&' are escaped in a query. [Kon Lovett]
  • release/3/uri/trunk/uri.scm

    r7003 r9434  
    416416
    417417(define (uri-decode estr)
    418   (let loop ([idx 0] [lst '()])
    419     (match (string-search-positions "%[0-9a-fA-F][0-9a-fA-F]" estr idx)
    420       [((start-idx end-idx))
    421         (loop end-idx
    422               (cons* (string
     418  (let ((re (regexp "%[0-9a-fA-F][0-9a-fA-F]")))
     419    (let loop ([idx 0] [lst '()])
     420      (match (string-search-positions re estr idx)
     421        [((start-idx end-idx))
     422         (loop end-idx
     423               (cons* (string
    423424                       (integer->char
    424                          (string->number
    425                            (substring/shared estr (add1 start-idx) end-idx)
    426                            16)))
    427                      (substring/shared estr idx start-idx) lst))]
    428       [_
    429         (apply string-append
    430           (reverse! (cons (substring/shared estr idx) lst)))] ) ) )
     425                        (string->number
     426                         (substring/shared estr (add1 start-idx) end-idx)
     427                         16)))
     428                      (substring/shared estr idx start-idx) lst))]
     429        [_ (if (null? lst)
     430               estr
     431               (string-concatenate-reverse
     432                (cons (substring/shared estr idx) lst)))] ) )) )
    431433
    432434;; Splits a string form of a path into a list.
Note: See TracChangeset for help on using the changeset viewer.