From cd688a60111853f63413a87ad6632ad57368e886 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Sun, 19 Oct 2014 16:09:38 +0200 Subject: Replace regex methods by string ones since faster and more readable. --- app/models/commit.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 37dd371ec00..baccf286740 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -75,11 +75,11 @@ class Commit return no_commit_message if title.blank? - title_end = title.index(/\n/) + title_end = title.index("\n") if (!title_end && title.length > 100) || (title_end && title_end > 100) title[0..79] << "…".html_safe else - title.split(/\n/, 2).first + title.split("\n", 2).first end end @@ -87,11 +87,11 @@ class Commit # # cut off, ellipses (`&hellp;`) are prepended to the commit message. def description - title_end = safe_message.index(/\n/) + title_end = safe_message.index("\n") @description ||= if (!title_end && safe_message.length > 100) || (title_end && title_end > 100) "…".html_safe << safe_message[80..-1] else - safe_message.split(/\n/, 2)[1].try(:chomp) + safe_message.split("\n", 2)[1].try(:chomp) end end -- cgit v1.2.1