aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Nartimov <just.lest@gmail.com>2012-01-05 22:36:04 +0300
committerSergey Nartimov <just.lest@gmail.com>2012-01-05 22:36:04 +0300
commit803e9bab84df9a93ca5f4613f710b6e088fbe64b (patch)
tree7084ae17c95bc7eb316cda10f3232ee2be51b8ed
parent4d08324aac7a50bbaa8f6200f50e8a7f6ff3ce48 (diff)
downloadrails-803e9bab84df9a93ca5f4613f710b6e088fbe64b.tar.gz
rails-803e9bab84df9a93ca5f4613f710b6e088fbe64b.tar.bz2
rails-803e9bab84df9a93ca5f4613f710b6e088fbe64b.zip
remove useless call to mb_chars
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb8
-rw-r--r--activerecord/lib/active_record/validations/uniqueness.rb2
2 files changed, 5 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index 209360ee82..ce79a3da48 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -162,15 +162,15 @@ module ActionView
options.reverse_merge!(:radius => 100, :omission => "...")
phrase = Regexp.escape(phrase)
- return unless found_pos = text.mb_chars =~ /(#{phrase})/i
+ return unless found_pos = text =~ /(#{phrase})/i
start_pos = [ found_pos - options[:radius], 0 ].max
- end_pos = [ [ found_pos + phrase.mb_chars.length + options[:radius] - 1, 0].max, text.mb_chars.length ].min
+ end_pos = [ [ found_pos + phrase.length + options[:radius] - 1, 0].max, text.length ].min
prefix = start_pos > 0 ? options[:omission] : ""
- postfix = end_pos < text.mb_chars.length - 1 ? options[:omission] : ""
+ postfix = end_pos < text.length - 1 ? options[:omission] : ""
- prefix + text.mb_chars[start_pos..end_pos].strip + postfix
+ prefix + text[start_pos..end_pos].strip + postfix
end
# Attempts to pluralize the +singular+ word unless +count+ is 1. If
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb
index 2e2ea8c42b..d56248b928 100644
--- a/activerecord/lib/active_record/validations/uniqueness.rb
+++ b/activerecord/lib/active_record/validations/uniqueness.rb
@@ -54,7 +54,7 @@ module ActiveRecord
def build_relation(klass, table, attribute, value) #:nodoc:
column = klass.columns_hash[attribute.to_s]
- value = column.limit ? value.to_s.mb_chars[0, column.limit] : value.to_s if column.text?
+ value = column.limit ? value.to_s[0, column.limit] : value.to_s if column.text?
if !options[:case_sensitive] && value && column.text?
# will use SQL LOWER function before comparison, unless it detects a case insensitive collation