Permalink
Browse files

* Fast string reversal with three-part loop thanks to @Nami-Doc

  • Loading branch information...
1 parent 57886bf commit 8d1ae98580db247aded0de8c829718e4c3a5b68e @audreyt committed Dec 12, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 rot.ls
View
3 rot.ls
@@ -26,7 +26,8 @@ for p, cs of p2c
#console.log ring
rev = ''
-``for (var i = ring.length - 1; i >= 0; rev += ring[i--]) {}``
+i = ring.length - 1
+while i, rev += ring[i--] then void # Fast string reversal
encode = -> (* '') <| for c in it
idx = ring.index-of c

1 comment on commit 8d1ae98

@vendethiel

Avoiding using js interpolation was my main concern.
I know it's true for C++ but I don't recall if --i is faster than i-- in js

Please sign in to comment.