Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Fixed buffer memory issue

  • Loading branch information...
commit 238f01a6cf98b2cf6bd72481e998a5fa9c2b3a54 1 parent 750a7a6
@tj tj authored
View
2  examples/benchmarks.rb
@@ -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
1  lib/dm-forms/base.rb
@@ -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
7 lib/dm-forms/helpers.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.