Plaster
New
List
Login
text
apl
aspx
asterisk
brainfuck
c
c++hdr
c++src
cassandra
ceylon
clojure
clojurescript
cmake
cobol
coffeescript
common-lisp
crystal
csharp
css
cypher-query
cython
d
dart
diff
django
dockerfile
dylan
ebnf
ecl
ecmascript
edn
eiffel
ejs
elm
erb
erlang
ez80
factor
fcl
feature
forth
fortran
fragment
gfm
go
gql
groovy
gss
haml
handlebars-template
haskell
haxe
hive
html
http
httpd-php
httpd-php-open
hxml
ini
java
javascript
json
jsp
jsx
julia
kotlin
latex
less
literate-haskell
lua
mariadb
markdown
mbox
mirc
mscgen
msgenny
mssql
mumps
mysql
n-triples
nesc
nginx-conf
nsis
objectivec
octave
oz
pascal
perl
pgp
pgp-keys
pgp-signature
pgsql
php
pig
plsql
properties
protobuf
puppet
python
q
rpm-changes
rpm-spec
rsrc
ruby
rustsrc
sas
sass
scala
scheme
scss
sieve
slim
smarty
solr
soy
sparql-query
spreadsheet
sql
squirrel
stex
styl
swift
systemverilog
tcl
textile
tiddlywiki
tiki
tlv
tornado
ttcn-asn
ttcn-cfg
turtle
twig
typescript
typescript-jsx
vb
vbscript
velocity
verilog
vertex
vhdl
vue
webidl
xml
xml-dtd
xquery
xu
yaml
z80
default
Visibility:
public
unlisted
private
(in-package :cl-user) (defclass scanner () ()) (defmethod whitespacep ((scanner scanner) (char character)) (loop :for c :across #(#\Space #\Page #\Tab #\Return #\Newline) :thereis (char= char c))) (defmethod make-whitespace-predicate ((scanner scanner)) (lambda (char) (loop :for c :across #(#\Space #\Page #\Tab #\Return #\Newline) :thereis (char= char c)))) (defun test-1 () (loop :with scanner = (make-instance 'scanner) :with char = #\Space :for i :from 0 :to 100000000 :do (whitespacep scanner char))) (defun test-2 () (loop :with scanner = (make-instance 'scanner) :with pred = (make-whitespace-predicate scanner) :with char = #\Space :for i :from 0 :to 100000000 :do (funcall pred char))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CL-USER> (time (test-1)) Evaluation took: 1.528 seconds of real time 1.528682 seconds of total run time (1.528605 user, 0.000077 system) 100.07% CPU 6 lambdas converted 5,033,598,591 processor cycles 229,200 bytes consed CL-USER> (time (test-2)) Evaluation took: 0.596 seconds of real time 0.595393 seconds of total run time (0.595372 user, 0.000021 system) 99.83% CPU 1,960,685,614 processor cycles 0 bytes consed