From: "Mehr, Assaph (Assaph)" Date: 2004-09-17T10:45:19+09:00 Subject: Re: Tidy binding using DL > Go it. The extern statement was correct, but the buffer string still wasn't > big enough to hold the results. The following takes care of it: > buffer = String.new # string buffer > 8192.times { buffer << ' ' } # must be long enough to hold results > Tidylib.tidySaveString(@doc, buffer, buffer.length) > output = buffer.strip You are much better off doing: buffer = ' ' * 8192 This way you don't invoke a method 8192 times. Here's a sample benchmark: c:\Temp>cat t.rb require 'benchmark' include Benchmark bm(3) do |x| x.report("<<") { 1000.times { s = String.new(); 8192.times { s << ' ' } } } x.report("* ") { 1000.times { s = ' '*8192 } } end c:\Temp>t.rb user system total real << 5.703000 0.000000 5.703000 ( 5.719000) * 0.219000 0.000000 0.219000 ( 0.219000)