diff options
author | Alejandro RodrÃguez <alejorro70@gmail.com> | 2017-06-14 12:11:03 -0400 |
---|---|---|
committer | Alejandro RodrÃguez <alejorro70@gmail.com> | 2017-06-14 19:53:46 -0400 |
commit | ec0b82311fa2b5ae484e3825d169a3958ad43061 (patch) | |
tree | aa26c662724be7429cc7bd3bdb03ffb06960081a | |
parent | 5468bf7e0b2c6bf39f5a9b43b5b3864e7e57556d (diff) | |
download | gitlab-ce-encoding-helper-performance.tar.gz |
Avoind unnecesary `force_encoding` operationsencoding-helper-performance
They're costly
-rw-r--r-- | lib/gitlab/encoding_helper.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/gitlab/encoding_helper.rb b/lib/gitlab/encoding_helper.rb index 781f9c56a42..83a1020e54e 100644 --- a/lib/gitlab/encoding_helper.rb +++ b/lib/gitlab/encoding_helper.rb @@ -17,6 +17,10 @@ module Gitlab return nil unless message.respond_to? :force_encoding # if message is utf-8 encoding, just return it + if message.encoding == Encoding::UTF_8 && message.valid_encoding? + return message + end + message.force_encoding("UTF-8") return message if message.valid_encoding? |