Permalink
Browse files

- Fixed buffer memory issue

  • Loading branch information...
1 parent 750a7a6 commit 238f01a6cf98b2cf6bd72481e998a5fa9c2b3a54 @tj tj committed Mar 2, 2009
Showing with 7 additions and 3 deletions.
  1. +1 −1 examples/benchmarks.rb
  2. +1 −0 lib/dm-forms/base.rb
  3. +5 −2 lib/dm-forms/helpers.rb
View
@@ -11,7 +11,7 @@ def params
end
public :params
-benchmark 'Entire forms', :times => 30 do
+benchmark 'Entire forms', :times => 10 do
report 'Login' do
form :action => '/login' do
textfield :name, :id => 'username'
View
@@ -17,6 +17,7 @@ def initialize model = nil, origin = nil
end
def form attrs = {}, &block
+ origin.clear_buffer
captured = origin.capture &block
faux_method = process_form_attrs attrs
origin.buffer << tag(:form, faux_method + captured, attrs)
View
@@ -50,8 +50,7 @@ def form_context *args
end
def with_form_context model, attrs = {}, &block
- last_context = form_context
- @__form_context = new_form_context(model, self)
+ last_context, @__form_context = form_context, new_form_context(model, self)
captured = instance_eval &block
@__form_context = last_context
captured
@@ -61,6 +60,10 @@ def bound? *args
args.first.is_a? Symbol
end
+ def clear_buffer
+ @buffer = ''
+ end
+
def buffer string = nil
@buffer ||= ''
end

0 comments on commit 238f01a

Please sign in to comment.