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

ruby-changes:24479

From: naruse <ko1@a...>
Date: Wed, 25 Jul 2012 09:29:40 +0900 (JST)
Subject: [ruby-changes:24479] naruse:r36530 (trunk): * lib/cgi/html.rb: Use << instead of +=.

naruse	2012-07-25 09:29:30 +0900 (Wed, 25 Jul 2012)

  New Revision: 36530

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

  Log:
    * lib/cgi/html.rb: Use << instead of +=.
      `a += b` is syntax sugar of `a = a + b`; it creates a new string
      object. `a << b` is concatenation and doesn't create new object.

  Modified files:
    trunk/ChangeLog
    trunk/lib/cgi/html.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36529)
+++ ChangeLog	(revision 36530)
@@ -1,3 +1,9 @@
+Wed Jul 25 09:26:32 2012  NARUSE, Yui  <naruse@r...>
+
+	* lib/cgi/html.rb: Use << instead of +=.
+	  `a += b` is syntax sugar of `a = a + b`; it creates a new string
+	  object. `a << b` is concatenation and doesn't create new object.
+
 Wed Jul 25 09:16:26 2012  NARUSE, Yui  <naruse@r...>
 
 	* lib/cgi/html.rb (element_init): suppress redefine warning.
Index: lib/cgi/html.rb
===================================================================
--- lib/cgi/html.rb	(revision 36529)
+++ lib/cgi/html.rb	(revision 36530)
@@ -334,7 +334,7 @@
         body = ""
       end
       if @output_hidden
-        body += @output_hidden.collect{|k,v|
+        body << @output_hidden.collect{|k,v|
           "<INPUT TYPE=\"HIDDEN\" NAME=\"#{k}\" VALUE=\"#{v}\">"
         }.join
       end
@@ -420,18 +420,18 @@
 
       if attributes.has_key?("DOCTYPE")
         if attributes["DOCTYPE"]
-          buf += attributes.delete("DOCTYPE")
+          buf << attributes.delete("DOCTYPE")
         else
           attributes.delete("DOCTYPE")
         end
       else
-        buf += doctype
+        buf << doctype
       end
 
       if block_given?
-        buf += super(attributes){ yield }
+        buf << super(attributes){ yield }
       else
-        buf += super(attributes)
+        buf << super(attributes)
       end
 
       if pretty
@@ -853,7 +853,7 @@
           APPLET PRE XMP LISTING DL OL UL DIR MENU SELECT TABLE TITLE
           STYLE SCRIPT H1 H2 H3 H4 H5 H6 TEXTAREA FORM BLOCKQUOTE
           CAPTION ]
-        methods += <<-BEGIN + nn_element_def(element) + <<-END
+        methods << <<-BEGIN + nn_element_def(element) + <<-END
           def #{element.downcase}(attributes = {})
         BEGIN
           end
@@ -863,7 +863,7 @@
       # - O EMPTY
       for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT
           ISINDEX META ]
-        methods += <<-BEGIN + nOE_element_def(element) + <<-END
+        methods << <<-BEGIN + nOE_element_def(element) + <<-END
           def #{element.downcase}(attributes = {})
         BEGIN
           end
@@ -873,7 +873,7 @@
       # O O or - O
       for element in %w[ HTML HEAD BODY P PLAINTEXT DT DD LI OPTION TR
           TH TD ]
-        methods += <<-BEGIN + nO_element_def(element) + <<-END
+        methods << <<-BEGIN + nO_element_def(element) + <<-END
           def #{element.downcase}(attributes = {})
         BEGIN
           end
@@ -904,7 +904,7 @@
         H1 H2 H3 H4 H5 H6 PRE Q INS DEL DL OL UL LABEL SELECT OPTGROUP
         FIELDSET LEGEND BUTTON TABLE TITLE STYLE SCRIPT NOSCRIPT
         TEXTAREA FORM A BLOCKQUOTE CAPTION ]
-        methods += <<-BEGIN + nn_element_def(element) + <<-END
+        methods << <<-BEGIN + nn_element_def(element) + <<-END
           def #{element.downcase}(attributes = {})
         BEGIN
           end
@@ -913,7 +913,7 @@
 
       # - O EMPTY
       for element in %w[ IMG BASE BR AREA LINK PARAM HR INPUT COL META ]
-        methods += <<-BEGIN + nOE_element_def(element) + <<-END
+        methods << <<-BEGIN + nOE_element_def(element) + <<-END
           def #{element.downcase}(attributes = {})
         BEGIN
           end
@@ -923,7 +923,7 @@
       # O O or - O
       for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY
           COLGROUP TR TH TD HEAD]
-        methods += <<-BEGIN + nO_element_def(element) + <<-END
+        methods << <<-BEGIN + nO_element_def(element) + <<-END
           def #{element.downcase}(attributes = {})
         BEGIN
           end
@@ -955,7 +955,7 @@
           INS DEL DL OL UL DIR MENU LABEL SELECT OPTGROUP FIELDSET
           LEGEND BUTTON TABLE IFRAME NOFRAMES TITLE STYLE SCRIPT
           NOSCRIPT TEXTAREA FORM A BLOCKQUOTE CAPTION ]
-        methods += <<-BEGIN + nn_element_def(element) + <<-END
+        methods << <<-BEGIN + nn_element_def(element) + <<-END
           def #{element.downcase}(attributes = {})
         BEGIN
           end
@@ -965,7 +965,7 @@
       # - O EMPTY
       for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT
           COL ISINDEX META ]
-        methods += <<-BEGIN + nOE_element_def(element) + <<-END
+        methods << <<-BEGIN + nOE_element_def(element) + <<-END
           def #{element.downcase}(attributes = {})
         BEGIN
           end
@@ -975,7 +975,7 @@
       # O O or - O
       for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY
           COLGROUP TR TH TD HEAD ]
-        methods += <<-BEGIN + nO_element_def(element) + <<-END
+        methods << <<-BEGIN + nO_element_def(element) + <<-END
           def #{element.downcase}(attributes = {})
         BEGIN
           end
@@ -1001,7 +1001,7 @@
       methods = ""
       # - -
       for element in %w[ FRAMESET ]
-        methods += <<-BEGIN + nn_element_def(element) + <<-END
+        methods << <<-BEGIN + nn_element_def(element) + <<-END
           def #{element.downcase}(attributes = {})
         BEGIN
           end
@@ -1010,7 +1010,7 @@
 
       # - O EMPTY
       for element in %w[ FRAME ]
-        methods += <<-BEGIN + nOE_element_def(element) + <<-END
+        methods << <<-BEGIN + nOE_element_def(element) + <<-END
           def #{element.downcase}(attributes = {})
         BEGIN
           end

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

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