summaryrefslogtreecommitdiff
path: root/api.lisp
diff options
context:
space:
mode:
authorRobert Smith <robert@rigetti.com>2018-08-04 19:58:24 -0700
committerStas Boukarev <stassats@gmail.com>2018-08-05 15:15:24 +0300
commit211563241b92dc518e179c461326a1bef2ba835f (patch)
tree8e0b30430317aa023d003960d71c5b9eca251357 /api.lisp
parentd01bbf70cdf1f15ee3734fe80572276caa482e77 (diff)
add internal control *LOOK-AHEAD-FOR-SUFFIX*v2.1.0
This allows better performance for some scanning use-cases. We also bump the minor version to 2.1.0.
Diffstat (limited to 'api.lisp')
-rw-r--r--api.lisp7
1 files changed, 6 insertions, 1 deletions
diff --git a/api.lisp b/api.lisp
index 4c11c45..f440361 100644
--- a/api.lisp
+++ b/api.lisp
@@ -31,6 +31,10 @@
(in-package :cl-ppcre)
+(defvar *look-ahead-for-suffix* t
+ "Controls whether scanners will optimistically look ahead for a
+ constant suffix of a regular expression, if there is one.")
+
(defgeneric create-scanner (regex &key case-insensitive-mode
multi-line-mode
single-line-mode
@@ -120,7 +124,8 @@ modify its first argument \(but only if it's a parse tree)."))
(end-string (end-string regex))
;; if we found a non-zero-length end-string we create an
;; efficient search function for it
- (end-string-test (and end-string
+ (end-string-test (and *look-ahead-for-suffix*
+ end-string
(plusp (len end-string))
(if (= 1 (len end-string))
(create-char-searcher