提交 803e9bab 编写于 作者: S Sergey Nartimov

remove useless call to mb_chars

上级 4d08324a
......@@ -162,15 +162,15 @@ def excerpt(text, phrase, *args)
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
......
......@@ -54,7 +54,7 @@ def find_finder_class_for(record) #:nodoc:
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册