   (let [buffer (StringBuffer.)
         length (.-length s)]
     (loop [index 0]
-      (if (= length index)
+      (if (== length index)
         (. buffer (toString))
-        (let [ch (.charAt s index)]
-          (if-let [replacement (get cmap ch)]
+        (let [ch (.charAt s index)
+              replacement (get cmap ch)]
+          (if-not (nil? replacement)
             (.append buffer (str replacement))
             (.append buffer ch))
           (recur (inc index)))))))

  (split s #"\n|\r\n"))

(defn trim
    "Removes whitespace from both ends of string."
    [s]
    (gstring/trim s))

(defn triml
    "Removes whitespace from the left side of string."
    [s]
    (gstring/trimLeft s))

(defn trimr
    "Removes whitespace from the right side of string."
    [s]
    (gstring/trimRight s))

(defn trim-newline
  "Removes all trailing newline \\n or return \\r characters from

  [s limit]
  (if (or (<= limit 0) (>= limit (+ 2 (count s))))
    (conj (vec (cons "" (map str (seq s)))) "")
    (condp == limit
      1 (vector s)
      2 (vector "" s)
      (let [c (- limit 2)]
