From: Richard Fairhurst Date: Wed, 27 Jun 2007 10:18:55 +0000 (+0000) Subject: use render proc to write out results, see if that makes things faster X-Git-Tag: live~8856 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/9d6ae5baae9f86acb8e2d9fcb006d8b81167281b use render proc to write out results, see if that makes things faster --- diff --git a/app/controllers/amf_controller.rb b/app/controllers/amf_controller.rb index 813c0bc7d..72f1dd74e 100644 --- a/app/controllers/amf_controller.rb +++ b/app/controllers/amf_controller.rb @@ -33,12 +33,14 @@ class AmfController < ApplicationController bytes=getlong(req) # | get total size in bytes args=getvalue(req) # | get response (probably an array) + RAILS_DEFAULT_LOGGER.info(" Message: #{message}") + case message - when 'getpresets'; results[index]=putdata(index,getpresets) - when 'whichways'; results[index]=putdata(index,whichways(args)) - when 'getway'; results[index]=putdata(index,getway(args)) - when 'putway'; results[index]=putdata(index,putway(args)) - when 'deleteway'; results[index]=putdata(index,deleteway(args)) + when 'getpresets'; results[index]=putdata(index,getpresets) + when 'whichways'; results[index]=putdata(index,whichways(args)) + when 'getway'; results[index]=putdata(index,getway(args)) + when 'putway'; results[index]=putdata(index,putway(args)) + when 'deleteway'; results[index]=putdata(index,deleteway(args)) end end @@ -48,13 +50,14 @@ class AmfController < ApplicationController RAILS_DEFAULT_LOGGER.info(" Response: start") response.headers["Content-Type"]="application/x-amf" a,b=results.length.divmod(256) - ans=0.chr+0.chr+0.chr+0.chr+a.chr+b.chr - results.each do |k,v| - RAILS_DEFAULT_LOGGER.info(" Response: encode #{k}") - ans+=v - end + render :text => proc { |response, output| + output.write 0.chr+0.chr+0.chr+0.chr+a.chr+b.chr + results.each do |k,v| + RAILS_DEFAULT_LOGGER.info(" Response: encode #{k}") + output.write(v) + end + } RAILS_DEFAULT_LOGGER.info(" Response: end") - render :text => ans end