Skip to content

Commit

Permalink
Use svref indeed of aref.
Browse files Browse the repository at this point in the history
  • Loading branch information
davazp committed Jul 13, 2010
1 parent 9e6f772 commit 3d147c4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
6 changes: 3 additions & 3 deletions types-date.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
(let ((days-before-month #(0 0 31 59 90 120 151 181 212 243 273 304 334))
(days-before-month-leap #(0 0 31 60 91 121 152 182 213 244 274 305 335)))
(if (leap-year-p year)
(+ day (elt days-before-month-leap month))
(+ day (elt days-before-month month)))))
(+ day (svref days-before-month-leap month))
(+ day (svref days-before-month month)))))

(defun make-date (day month year)
(declare (day day) (month month) (year year))
Expand Down Expand Up @@ -121,7 +121,7 @@
;; Note 1 of January of 1900 was Monday.
(let* ((nwkst (position wkst *weekday*))
(nday (mod7 (day-from-1900 x)))
(day (elt *weekday* (mod7 (1- nday)))))
(day (svref *weekday* (mod7 (1- nday)))))
(values day (1+ (mod7 (- nday nwkst 1))))))

;;; Begins in 1
Expand Down
10 changes: 5 additions & 5 deletions types-recur.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
(if (leap-year-p year)
#(0 31 29 31 30 31 30 31 31 30 31 30 31)
#(0 31 28 31 30 31 30 31 31 30 31 30 31))))
(mod* day (elt monthdays month))))
(mod* day (svref monthdays month))))

;;; Return the nth DAY in year. This handles negative days propertily.
(defun yearday (day year)
Expand Down Expand Up @@ -948,7 +948,7 @@
(%parse-error "~a is not a weekday." string)
(let* ((str (subseq string end)))
(aif (position str #("MO" "TU" "WE" "TH" "FR" "SA" "SU") :test #'string-ci=)
(cons (elt *weekday* it) n)
(cons (svref *weekday* it) n)
(%parse-error "~a is not a weekday." str))))))

(defun parse-rule-part (string)
Expand Down Expand Up @@ -1043,7 +1043,7 @@
(let ((nday (position value *weekday-names* :test #'string-ci=)))
(when (null nday)
(%parse-error "~a is not a weekday." value))
(elt *weekday* nday))))
(nth *weekday* nday))))
(t
(%parse-error "Unknown recurrence component ~a" key)))))

Expand All @@ -1068,15 +1068,15 @@
(dolist (day (recur-byday recur))
(destructuring-bind (wday . n) day
(collect n)
(collect (elt *weekday-names* (position wday *weekday*)))))))
(collect (svref *weekday-names* (position wday *weekday*)))))))
(format s "~@[;BYMONTH=~{~A~^,~}~]" (recur-bymonth recur))
(format s "~@[;BYMONTHDAY=~{~A~^,~}~]" (recur-bymonthday recur))
(format s "~@[;BYYEARDAY=~{~A~^,~}~]" (recur-byyearday recur))
(format s "~@[;BYWEEKNO=~{~A~^,~}~]" (recur-byweekno recur))
(format s "~@[;BYSETPOS=~{~A~^,~}~]" (recur-bysetpos recur))
(unless (eq (recur-wkst recur) :monday)
(let ((nwkst (position (recur-wkst recur) *weekday*)))
(format s ";WKST=~a" (elt *weekday-names* nwkst))))))
(format s ";WKST=~a" (svref *weekday-names* nwkst))))))


;;; Local variables:
Expand Down
11 changes: 4 additions & 7 deletions types.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,8 @@
;;; objects to strings and vice versa.

(deftype ical-value ()
'(or
boolean integer float text binary
uri cal-address utc-offset date time date-time
duration period recur
;; x-type??
;; A (satisfies x-typep) be placed here soon.
))
'(or boolean integer float text binary uri cal-address utc-offset date
time date-time duration period recur x-ical-value))

;;; Like `check-type' but it signals an error with %parse-error.
(defmacro check-ical-type (place type)
Expand Down Expand Up @@ -211,6 +206,8 @@

;; User-defined iCalendar data types

(defclass x-ical-value ()
nil)


;;; types.lisp ends here

0 comments on commit 3d147c4

Please sign in to comment.