Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Minor refactor, cleanup

  • Loading branch information...
commit 97cec8ac227ce0f3cf8d9052c38ce641cf037d6e 1 parent 44a4d51
@pmbauer pmbauer authored
View
2  pom.xml
@@ -55,6 +55,8 @@
</goals>
<configuration>
<outputFile>${basedir}/script/maven-classpath</outputFile>
+ <excludeArtifactIds>swank-clojure</excludeArtifactIds>
+ <excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
</executions>
View
4 src/main/clojure/alioth/mandelbrot.clj
@@ -25,7 +25,7 @@
(recur ~adv))))
(deftype MandelbrotBuffer [^bytes out ^long n ^long m])
-(deftype CXB [^doubles crb ^doubles cib])
+(deftype CXB [^doubles crb ^doubles cib]) ; slightly faster than destructuring vector in inner loop
(defn ^CXB make-cxb [^long n]
(let [n+7 (+ n 7)
@@ -86,7 +86,7 @@
(.join thread))
(MandelbrotBuffer. out n m)))
-(defn write-bmp [^MandelbrotBuffer buff ^OutputStream outStream]
+(defn write-bmp [^OutputStream outStream ^MandelbrotBuffer buff]
(let [^bytes out (.out buff) n (.n buff) m (.m buff)
len (* n m)] ; (.length out) <-- won't compile ??
(.write outStream (.getBytes (str "P4\n" n " " n "\n")))
View
11 src/test/clojure/test/alioth/mandelbrot.clj
@@ -25,12 +25,11 @@
(input-stream (ns-resource this-ns file-name)))
(defn- matches-master [dimension mandelbrot-fn write-fn]
- (let [tmp (mandelbrot-fn dimension)]
- (with-open [outStream (write-fn tmp
- (ByteArrayOutputStream.))
- inStream (ByteArrayInputStream. (.toByteArray outStream))
- masterInStream (resource-stream (master-files dimension))]
- (streams= inStream masterInStream))))
+ (with-open [outStream (write-fn (ByteArrayOutputStream.)
+ (mandelbrot-fn dimension))
+ inStream (ByteArrayInputStream. (.toByteArray outStream))
+ masterInStream (resource-stream (master-files dimension))]
+ (streams= inStream masterInStream)))
(deftest test-mandelbrot-correctness
Please sign in to comment.
Something went wrong with that request. Please try again.