Skip to content

Instantly share code, notes, and snippets.

@marktriggs
Created December 12, 2009 03:51
Show Gist options
  • Select an option

  • Save marktriggs/254723 to your computer and use it in GitHub Desktop.

Select an option

Save marktriggs/254723 to your computer and use it in GitHub Desktop.
;; now even dumber :P
(defn dumbest-split [#^String s c #^"[Ljava.lang.String;" tokens]
(loop [start (int 0)
i (int 0)]
(let [idx (int (.indexOf s (int c) (int start)))]
(if (neg? idx)
(do (aset tokens i (.substring s start))
tokens)
(do (aset tokens i (.substring s start idx))
(recur (inc idx) (inc i)))))))
.split
"Elapsed time: 1852.914773 msecs"
dumb split
"Elapsed time: 1136.352235 msecs"
dumber split
"Elapsed time: 691.229164 msecs"
dumbest split
"Elapsed time: 418.799226 msecs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment