Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use `sub` as we only need to substitute once. #595

Merged
merged 1 commit into from

2 participants

@benpickles

I hope you like micro optimisations...

           user     system      total        real
gsub   0.030000   0.000000   0.030000 (  0.024439)
sub    0.000000   0.000000   0.000000 (  0.008700)

https://gist.github.com/benpickles/6286953

@spastorino spastorino merged commit 53e927c into rack:master

1 check passed

Details default The Travis CI build passed
@benpickles benpickles deleted the benpickles:use-sub-not-gsub branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 20, 2013
  1. @benpickles

    Use `sub` as we only need to substitute once.

    benpickles authored
    (Hence the use of `\z`)
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/rack/request.rb
View
2  lib/rack/request.rb
@@ -109,7 +109,7 @@ def port
def host
# Remove port number.
- host_with_port.to_s.gsub(/:\d+\z/, '')
+ host_with_port.to_s.sub(/:\d+\z/, '')
end
def script_name=(s); @env["SCRIPT_NAME"] = s.to_s end
Something went wrong with that request. Please try again.