[前][次][番号順一覧][スレッド一覧]

ruby-changes:34990

From: naruse <ko1@a...>
Date: Wed, 6 Aug 2014 04:09:06 +0900 (JST)
Subject: [ruby-changes:34990] naruse:r47072 (trunk): * lib/uri/http.rb (URI::HTTP#request_uri): optimized.

naruse	2014-08-06 04:09:01 +0900 (Wed, 06 Aug 2014)

  New Revision: 47072

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47072

  Log:
    * lib/uri/http.rb (URI::HTTP#request_uri): optimized.
      decrease object allocation, and ensure always create at least one new
      object for return value.

  Modified files:
    trunk/ChangeLog
    trunk/lib/uri/http.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47071)
+++ ChangeLog	(revision 47072)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Aug  6 00:15:10 2014  NARUSE, Yui  <naruse@r...>
+
+	* lib/uri/http.rb (URI::HTTP#request_uri): optimized.
+	  decrease object allocation, and ensure always create at least one new
+	  object for return value.
+
 Wed Aug  6 03:41:21 2014  Aaron Patterson <aaron@t...>
 
 	* ext/psych/lib/psych/visitors/to_ruby.rb: backwards compatibility for
Index: lib/uri/http.rb
===================================================================
--- lib/uri/http.rb	(revision 47071)
+++ lib/uri/http.rb	(revision 47072)
@@ -93,12 +93,12 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/http.rb#L93
     # Otherwise, the path is simply URI#path.
     #
     def request_uri
-      r = path_query
-      if r && r[0] != ?/
-        r = '/' + r
+      return nil unless @path
+      if @path.start_with?(?/.freeze)
+        @query ? "#@path?#@query" : @path.dup
+      else
+        @query ? "/#@path?#@query" : "/#@path"
       end
-
-      r
     end
   end
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]