Changeset 32961 in project


Ignore:
Timestamp:
12/07/15 22:01:28 (5 years ago)
Author:
sjamaan
Message:

uri-generic: Another small but noticeable performance improvement

Instead of using char-set-contains? with char-set:uri-unreserved,
which is the obvious and clean thing to do, we expand it manually to a
check of char-alphabetic?, char-numeric? and the four additional
characters that are in the list. These checks are inlineable, while
char-set-contains? isn't.

This shaves off about 20% of parsing a full URI, so it's definitely
worthwhile. The other predicates don't have nearly as much impact on
the overall time to parse an URI, so we keep them the way they are.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/uri-generic/trunk/uri-generic.scm

    r32958 r32961  
    304304(define (hexdigit-char? c)    (and (char? c) (char-set-contains? char-set:hex-digit c)))
    305305
    306 (define (unreserved-char? c)  (and (char? c) (char-set-contains? char-set:uri-unreserved c)))
     306(define (unreserved-char? c)
     307  ;; (and (char? c) (char-set-contains? char-set:uri-unreserved c))
     308  ;; The following is inlineable (much faster), and this
     309  ;; procedure is called a LOT
     310  (and (char? c)
     311       (or (char-alphabetic? c)
     312           (char-numeric? c)
     313           (char=? c #\-)
     314           (char=? c #\.)
     315           (char=? c #\_)
     316           (char=? c #\~))))
    307317
    308318(define (scheme-char? c)      (and (char? c) (char-set-contains? char-set:scheme c)))
Note: See TracChangeset for help on using the changeset viewer.