Details
-
Type:
Defect
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Completed
-
Affects Version/s: Release 1.4
-
Fix Version/s: Release 1.5
-
Component/s: None
-
Labels:
-
Environment:Mac OS X 10.8.1, Java 1.7.0_06
-
Patch:Code
-
Approval:Ok
Description
The when-first macro will evaluate the xs expression twice. Admittedly, it does exactly what the doc string says, but that seems undesirable to me. Even without side effects, there's a potential performance issue if xs is some expensive operation.
Patch attached. The main diff is:
- `(when (seq ~xs)
- (let [~x (first ~xs)]
- ~@body))))
+ `(when-let xs# (seq ~xs)
+ (let ~x (first xs#)
+ ~@body))))
Screened.