1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2012-07-25 00:29:30 +00:00
parent 347c554f7e
commit ba22341854
2 changed files with 22 additions and 16 deletions

View file

@ -1,3 +1,9 @@
Wed Jul 25 09:26:32 2012 NARUSE, Yui <naruse@ruby-lang.org>
* 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@ruby-lang.org> Wed Jul 25 09:16:26 2012 NARUSE, Yui <naruse@ruby-lang.org>
* lib/cgi/html.rb (element_init): suppress redefine warning. * lib/cgi/html.rb (element_init): suppress redefine warning.

View file

@ -334,7 +334,7 @@ class CGI
body = "" body = ""
end end
if @output_hidden if @output_hidden
body += @output_hidden.collect{|k,v| body << @output_hidden.collect{|k,v|
"<INPUT TYPE=\"HIDDEN\" NAME=\"#{k}\" VALUE=\"#{v}\">" "<INPUT TYPE=\"HIDDEN\" NAME=\"#{k}\" VALUE=\"#{v}\">"
}.join }.join
end end
@ -420,18 +420,18 @@ class CGI
if attributes.has_key?("DOCTYPE") if attributes.has_key?("DOCTYPE")
if attributes["DOCTYPE"] if attributes["DOCTYPE"]
buf += attributes.delete("DOCTYPE") buf << attributes.delete("DOCTYPE")
else else
attributes.delete("DOCTYPE") attributes.delete("DOCTYPE")
end end
else else
buf += doctype buf << doctype
end end
if block_given? if block_given?
buf += super(attributes){ yield } buf << super(attributes){ yield }
else else
buf += super(attributes) buf << super(attributes)
end end
if pretty if pretty
@ -853,7 +853,7 @@ class CGI
APPLET PRE XMP LISTING DL OL UL DIR MENU SELECT TABLE TITLE APPLET PRE XMP LISTING DL OL UL DIR MENU SELECT TABLE TITLE
STYLE SCRIPT H1 H2 H3 H4 H5 H6 TEXTAREA FORM BLOCKQUOTE STYLE SCRIPT H1 H2 H3 H4 H5 H6 TEXTAREA FORM BLOCKQUOTE
CAPTION ] CAPTION ]
methods += <<-BEGIN + nn_element_def(element) + <<-END methods << <<-BEGIN + nn_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -863,7 +863,7 @@ class CGI
# - O EMPTY # - O EMPTY
for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT
ISINDEX META ] ISINDEX META ]
methods += <<-BEGIN + nOE_element_def(element) + <<-END methods << <<-BEGIN + nOE_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -873,7 +873,7 @@ class CGI
# O O or - O # O O or - O
for element in %w[ HTML HEAD BODY P PLAINTEXT DT DD LI OPTION TR for element in %w[ HTML HEAD BODY P PLAINTEXT DT DD LI OPTION TR
TH TD ] TH TD ]
methods += <<-BEGIN + nO_element_def(element) + <<-END methods << <<-BEGIN + nO_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -904,7 +904,7 @@ class CGI
H1 H2 H3 H4 H5 H6 PRE Q INS DEL DL OL UL LABEL SELECT OPTGROUP H1 H2 H3 H4 H5 H6 PRE Q INS DEL DL OL UL LABEL SELECT OPTGROUP
FIELDSET LEGEND BUTTON TABLE TITLE STYLE SCRIPT NOSCRIPT FIELDSET LEGEND BUTTON TABLE TITLE STYLE SCRIPT NOSCRIPT
TEXTAREA FORM A BLOCKQUOTE CAPTION ] TEXTAREA FORM A BLOCKQUOTE CAPTION ]
methods += <<-BEGIN + nn_element_def(element) + <<-END methods << <<-BEGIN + nn_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -913,7 +913,7 @@ class CGI
# - O EMPTY # - O EMPTY
for element in %w[ IMG BASE BR AREA LINK PARAM HR INPUT COL META ] 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 = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -923,7 +923,7 @@ class CGI
# O O or - O # O O or - O
for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY
COLGROUP TR TH TD HEAD] COLGROUP TR TH TD HEAD]
methods += <<-BEGIN + nO_element_def(element) + <<-END methods << <<-BEGIN + nO_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -955,7 +955,7 @@ class CGI
INS DEL DL OL UL DIR MENU LABEL SELECT OPTGROUP FIELDSET INS DEL DL OL UL DIR MENU LABEL SELECT OPTGROUP FIELDSET
LEGEND BUTTON TABLE IFRAME NOFRAMES TITLE STYLE SCRIPT LEGEND BUTTON TABLE IFRAME NOFRAMES TITLE STYLE SCRIPT
NOSCRIPT TEXTAREA FORM A BLOCKQUOTE CAPTION ] NOSCRIPT TEXTAREA FORM A BLOCKQUOTE CAPTION ]
methods += <<-BEGIN + nn_element_def(element) + <<-END methods << <<-BEGIN + nn_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -965,7 +965,7 @@ class CGI
# - O EMPTY # - O EMPTY
for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT
COL ISINDEX META ] COL ISINDEX META ]
methods += <<-BEGIN + nOE_element_def(element) + <<-END methods << <<-BEGIN + nOE_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -975,7 +975,7 @@ class CGI
# O O or - O # O O or - O
for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY
COLGROUP TR TH TD HEAD ] COLGROUP TR TH TD HEAD ]
methods += <<-BEGIN + nO_element_def(element) + <<-END methods << <<-BEGIN + nO_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -1001,7 +1001,7 @@ class CGI
methods = "" methods = ""
# - - # - -
for element in %w[ FRAMESET ] for element in %w[ FRAMESET ]
methods += <<-BEGIN + nn_element_def(element) + <<-END methods << <<-BEGIN + nn_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end
@ -1010,7 +1010,7 @@ class CGI
# - O EMPTY # - O EMPTY
for element in %w[ FRAME ] for element in %w[ FRAME ]
methods += <<-BEGIN + nOE_element_def(element) + <<-END methods << <<-BEGIN + nOE_element_def(element) + <<-END
def #{element.downcase}(attributes = {}) def #{element.downcase}(attributes = {})
BEGIN BEGIN
end end