Skip to content
This repository
Browse code

Extracted string size check so that it's only run once at most.

  • Loading branch information...
commit 5c61c5f9b14052e2553d85356b5dac6bc9189715 1 parent 60dfffe
Richard Lyman authored August 04, 2012

Showing 1 changed file with 3 additions and 2 deletions. Show diff stats Hide diff stats

  1. 5  src/com/lithinos/amotoen/core.clj
5  src/com/lithinos/amotoen/core.clj
@@ -30,11 +30,12 @@
30 30
      The function 'charAt' is part of the mechanism to walk through the string."
31 31
     ([#^String s] (wrap-string s 0))
32 32
     ([#^String s j] ; 'j' is where we currently are in the input... 'i' was skipped since it was too close to 'i'nput
33  
-        (let [a (int-array 1 j)]
  33
+        (let [a     (int-array 1 j)
  34
+              size  (count s)]
34 35
             (reify IAmotoen
35 36
                 (gp     [t]     (aget a 0))
36 37
                 (sp     [t k]   (aset-int a 0 k))
37  
-                (end    [t]     (= (aget a 0) (count s)))
  38
+                (end    [t]     (= (aget a 0) size))
38 39
                 (c      [t]     (try (.charAt s (aget a 0)) (catch Exception e nil)))
39 40
                 (m      [t]     (let [r (c t)]
40 41
                                     (when (nil? r) (throw (Exception. "Consuming nil")))

0 notes on commit 5c61c5f

Please sign in to comment.
Something went wrong with that request. Please try again.