Skip to content
Browse files

Use gsub instead of gsub! as it's marginally simpler.

  • Loading branch information...
1 parent 7637a22 commit 8dcdf3a97ebcabef67174ea358de8fc6ba6ac00d @threedaymonk committed Mar 29, 2011
Showing with 4 additions and 5 deletions.
  1. +4 −5 lib/htmlentities/encoder.rb
View
9 lib/htmlentities/encoder.rb
@@ -13,10 +13,9 @@ def initialize(flavor, instructions)
end
def encode(source)
- string = prepare(source)
- string.gsub!(basic_entity_regexp){ encode_basic($&) }
- string.gsub!(extended_entity_regexp){ encode_extended($&) }
- string
+ prepare(source).
+ gsub(basic_entity_regexp){ encode_basic($&) }.
+ gsub(extended_entity_regexp){ encode_extended($&) }
end
private
@@ -27,7 +26,7 @@ def prepare(string) #:nodoc:
end
else
def prepare(string) #:nodoc:
- string.to_s.dup
+ string.to_s
end
end

0 comments on commit 8dcdf3a

Please sign in to comment.
Something went wrong with that request. Please try again.