From 6ce26c83ad851bf19741d9682633c6517764e8b0 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 8 Feb 2013 13:50:15 +0900 Subject: [PATCH] Reduce Strings --- lib/haml/util.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/haml/util.rb b/lib/haml/util.rb index 5ba897e1..7dcf2ef0 100644 --- a/lib/haml/util.rb +++ b/lib/haml/util.rb @@ -101,7 +101,8 @@ module Haml # @return [String] `str`, potentially with encoding gotchas like BOMs removed if RUBY_VERSION < "1.9" def check_encoding(str) - str.gsub(/\A\xEF\xBB\xBF/, '') # Get rid of the UTF-8 BOM + str.gsub!(/\A\xEF\xBB\xBF/, '') # Get rid of the UTF-8 BOM + str end else @@ -109,7 +110,8 @@ module Haml if str.valid_encoding? # Get rid of the Unicode BOM if possible if str.encoding.name =~ /^UTF-(8|16|32)(BE|LE)?$/ - return str.gsub(Regexp.new("\\A\uFEFF".encode(str.encoding)), '') + str.gsub!(Regexp.new("\\A\uFEFF".encode(str.encoding)), '') + return str else return str end