diff options
| author | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2010-10-02 19:57:26 -0400 |
|---|---|---|
| committer | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2010-10-02 19:57:26 -0400 |
| commit | 138e9fef83800fa346fa58f111ef7384fc758041 (patch) | |
| tree | f025595e1eb58f65e41868ba3a79d18f7953da11 /src/utils.clj | |
| parent | e1f00e6df1cc050bc6335ddba23ddb3b71e226fa (diff) | |
timb: maybe-parse-int... don't die if already int
Diffstat (limited to 'src/utils.clj')
| -rwxr-xr-x | src/utils.clj | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/utils.clj b/src/utils.clj index 4c6905c..9460bbc 100755 --- a/src/utils.clj +++ b/src/utils.clj @@ -301,11 +301,15 @@ ;; Parsing +(= (type 0) java.lang.Integer) + (defn maybe-parse-int - ([s] (Integer/parseInt s)) + ([s] (maybe-parse-int s 0)) ([s default] - (try (Integer/parseInt s) - (catch NumberFormatException _ default)))) + (if (= (type s) java.lang.Integer) + s + (try (Integer/parseInt s) + (catch NumberFormatException _ default))))) (defn maybe-parse-long [s f] (if s (Long/parseLong s) f)) @@ -416,4 +420,4 @@ (let [result (apply function arguments)] (swap! cached-results assoc arguments { :result result :time (System/currentTimeMillis)}) - result)))))
\ No newline at end of file + result))))) |
