-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fewer allocated objects on each request #737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,8 +55,8 @@ def call(env) | |
|
|
||
| def _call(env) | ||
| @env = env | ||
| @script_name = env['SCRIPT_NAME'] | ||
| @path_info = Utils.unescape(env['PATH_INFO']) | ||
| @script_name = env[SCRIPT_NAME] | ||
| @path_info = Utils.unescape(env[PATH_INFO]) | ||
|
|
||
| if forbidden = check_forbidden | ||
| forbidden | ||
|
|
@@ -72,7 +72,7 @@ def check_forbidden | |
| body = "Forbidden\n" | ||
| size = Rack::Utils.bytesize(body) | ||
| return [403, {"Content-Type" => "text/plain", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missed opportunity to replace "Content-Type" with CONTENT_TYPE. Also on line 132
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RIght you are. I love open source, thanks for pointing this out! Updated in #742 |
||
| "Content-Length" => size.to_s, | ||
| CONTENT_LENGTH => size.to_s, | ||
| "X-Cascade" => "pass"}, [body]] | ||
| end | ||
|
|
||
|
|
@@ -101,7 +101,7 @@ def list_directory | |
| @files << [ url, basename, size, type, mtime ] | ||
| end | ||
|
|
||
| return [ 200, {'Content-Type'=>'text/html; charset=utf-8'}, self ] | ||
| return [ 200, { CONTENT_TYPE =>'text/html; charset=utf-8'}, self ] | ||
| end | ||
|
|
||
| def stat(node, max = 10) | ||
|
|
@@ -130,7 +130,7 @@ def entity_not_found | |
| body = "Entity not found: #{@path_info}\n" | ||
| size = Rack::Utils.bytesize(body) | ||
| return [404, {"Content-Type" => "text/plain", | ||
| "Content-Length" => size.to_s, | ||
| CONTENT_LENGTH => size.to_s, | ||
| "X-Cascade" => "pass"}, [body]] | ||
| end | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 1.9, respond_to takes 2 arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right you are: http://ruby-doc.org/core-2.1.3/Object.html#method-i-respond_to-3F Looks like 1.8.7 & 2+ also take multiple arguments. I did this because the
*argscauses us to have an extra array allocation. If we match the method signaturerespond_to?(string, include_all=false)then theinclude_allwould be an extra object. If I remember this only decreased the overall count by around 100. I'm going to open a new PR to revert these changes, I don't think we can do better than the previous case and still maintain compatibility.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix is here: #739 sorry about that, should have known better. Thanks for the catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but
false.object_id == 0, include_all in your example only takes a reference slot, not an RObject structure.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in #742 also can get rid of a string allocation in
method_missing