title: Looking for a replace-in-string function in elisp
body: <p>I'm looking for an equivalent of <code>replace-regexp-in-string</code> that just uses literal strings, no regular expressions.</p>
  
  <pre><code>(replace-regexp-in-string "." "bar" "foo.buzz") =&gt; "barbarbarbarbarbarbarbar"
  </code></pre>
  
  <p>But I want</p>
  
  <pre><code>(replace-in-string "." "bar" "foo.buzz") =&gt; "foobarbuzz"
  </code></pre>
  
  <p>I tried various <code>replace-*</code> functions but can't figure it out.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>In return for the elaborate answers I decided to benchmark them (yea, I know all benchmarks are wrong, but it's still interesting). </p>
  
  <p>The output of <code>benchmark-run</code> is <code>(time, # garbage collections, GC time)</code>:</p>
  
  <pre><code>(benchmark-run 10000
    (replace-regexp-in-string "." "bar" "foo.buzz"))
  
    =&gt; (0.5530160000000001 7 0.4121459999999999)
  
  (benchmark-run 10000
    (haxe-replace-string "." "bar" "foo.buzz"))
  
    =&gt; (5.301392 68 3.851943000000009)
  
  (benchmark-run 10000
    (replace-string-in-string "." "bar" "foo.buzz"))
  
    =&gt; (1.429293 5 0.29774799999999857)
  </code></pre>
  
  <p>replace-regexp-in-string with a quoted regexp wins. Temporary buffers do remarkably well.</p>
  
  <p><strong>Edit 2</strong></p>
  
  <p>Now with compilation! Had to do 10x more iteration:</p>
  
  <pre><code>(benchmark-run 100000
    (haxe-replace-string "." "bar" "foo.buzz"))
  
    =&gt; (0.8736970000000001 14 0.47306700000000035)
  
  (benchmark-run 100000
    (replace-in-string "." "bar" "foo.buzz"))
  
    =&gt; (1.25983 29 0.9721819999999983)
  
  (benchmark-run 100000
    (replace-string-in-string "." "bar" "foo.buzz"))
  
    =&gt; (11.877136 86 3.1208540000000013)
  </code></pre>
  
  <p>haxe-replace-string is looking good</p>